I translate an object out say 10 units and then i want to rotate it.
The problem is, is that it doesn’t rotate around itself, but it rotates
around the original origin.
If i rotate first and then translate, it rotates around itself but then
the translation only translates around the original axis.
This is for a simple virtual world i’m making. Say the user presses the
up arrow key to walk forward. I translate the world so it looks like
he’s walking forward. Then he stops and wants to turn left, i rotate
the world to the right but its making a rotation around the original
Basically i think i’m saying i need to translate the world, make that
the new origin and then rotate around that new origin. Or ratate first and then translate in the direction i rotated.
Ugh i hope i explained myself
My render function code will probably explain some more…
// clear the screen and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// enable face culling glEnable(GL_CULL_FACE); // cull back facing triangles glCullFace(GL_BACK); glBindTexture(GL_TEXTURE_2D, tex); // rotate glRotatef(x_rot, 1.0f, 0.0f, 0.0f); glRotatef(y_rot, 0.0f, 1.0f, 0.0f); glRotatef(z_rot, 0.0f, 0.0f, 1.0f); // set object position in scene glTranslatef(move_left_right, move_up_down, move_in_out); Draw_Land_Scape(); //glPopMatrix(); // disable state glDisable(GL_CULL_FACE); // Swap buffers glutSwapBuffers();
I’m sure this is a fundamental thing but i just can’t see it.