   asteroid ship question #2 - code included
  here is the code to draw the ship, rotate around center and translate. it rotates fine around the center in each direction but once i start translating and then try to rotate again, it rotates around the original matrix coordinates from where it started when the program ran... instead of rotating at the center to its "new" translate matrix coordinates if you will which is what i want. i know this is the problem just not sure how to solve it..everytime i translate basically that needs to become my center so i will rotate around that not the original that i started out with.  here is the code.. thanks in advance!//global variablesGLfloat rot = 0.0;GLfloat rotate = 0.0;GLfloat y = -0.018;GLfloat x = -0.03125;GLfloat up_down = 0.0;**************************************... ... .. ... .. glRotatef(rot, 0, 0, 1);glTranslatef(x, y, -2.0);glBegin(GL_LINE_LOOP);  glVertex2f(0,0);  glVertex2f(0.03125, 0.0625); glVertex2f(0.0625, 0);glEnd();rot += rotate; y += up_down;glFlush();return TRUE; // Everything Went OK//this is called in WinMainvoid keyBoardStuff(){   if (keys[VK_DOWN])    up_down += -0.000005;   if (keys[VK_UP])   up_down += 0.0000005; if (keys[VK_LEFT])rotate -= -0.0005; if (keys[VK_RIGHT])  rotate -= 0.0005;} 
  Thats how matrix multiplication works, I''m afraid.The simple solution is to do all your rotations before your translations. ;  well that is what i am doing -- i am doing my rotate before my translate, although the translate is done first in openGL if thats what you were referring to then i would need to swap my rot and trans calls.  ;quote:Original post by OpenGL_Guru   well that is what i am doing -- i am doing my rotate before my translate, although the translate is done first in openGL if thats what you were referring to then i would need to swap my rot and trans calls.    Yes, flip the order and it should be OK. (I forgot you're transforming the world rather than the object) [edited by - Sandman on February 4, 2004 11:12:32 AM];  sandman -- ok that did solve the problem. i rememeber why i didnt do that b4, was b/c now what happens is that i am no longer rotating around the center point but rather one of the point that connect the line loop, it just happens to be the last point drawn. also now i have to figure out a way to move according to where the front of my ship is pointing. so if i turn left 45 degrees the up is no longer up but up + -45Degrees? is this the right idea? the code i had b4 kept up with where i was pointing but i was losing my original translation matrix. so how can i fix this now to where i rotate around the center point which is x,y globally declared? and did i have the right idea about updated what my translate variables are. so if i turn to the left 45 degrees my new x,y should be..im guesssing.. up_down + cos(45degrees) , same thing with left and right. .....thanks so much!   [edited by - opengl_guru on February 4, 2004 12:44:35 PM];quote:Original post by OpenGL_Guru  sandman -- ok that did solve the problem. i rememeber why i didnt do that b4, was b/c now what happens is that i am no longer rotating around the center point but rather one of the point that connect the line loop, it just happens to be the last point drawn.No, it''s rotating around the origin, which just so happens to be the first point (and the last point) in your line loop.Rewrite your ship drawing code so that the ship is CENTERED on 0,0, and it will rotate around the center.quote:also now i have to figure out a way to move according to where the front of my ship is pointing. so if i turn left 45 degrees the up is no longer up but up + -45Degrees? is this the right idea? the code i had b4 kept up with where i was pointing but i was losing my original translation matrix. so how can i fix this now to where i rotate around the center point which is x,y globally declared? and did i have the right idea about updated what my translate variables are. so if i turn to the left 45 degrees my new x,y should be..im guesssing.. up_down + cos(45degrees) , same thing with left and right. .....thanks so much!Yes, you need to transform your movement vector by your rotation matrix before updating your position. So you''d end up with something like: // note that in practice, you''ll probably need to convert rotate // from degrees to radians for the standard sin and cos implementations.dx = up_down * sin(rotate);// (* not +)dy = up_down * cos(rotate);x += dx;y += dy;;  thanks sandman: i will update my code and try that for sure. thanks for the update on my transforms tidbit. yes it defintely will need to be converted to radians. ill just have to play around with numbers to get the ship drawn around the CENTER of 0,0 to get it rotated as close as i can get. thanks again ;  being that i am drawing around my center now, my init x and y should 0.0 right?? so after subsitution on first frame with no rotates or updated translates it would be (0.0, 0.0, -2.0). after a rotate then translate a couple of times thinhs start to get crazy. the reason i am trying to make sure is b/c it is not quite rotating around the center. i wanted to get as close as possible b/c i fear if i dont my rotates could easily give mt the wrong result. thanks again