Hi everyone. I am trying to rotate an object around its local axes. With the following code, I can get it to rotate around its local x axis, but it rotates around the world y and z axes.
glTranslatef(0.0f, 0.0f, trans);
glRotatef(rotz, 0.0f, 0.0f, 1.0f);
glRotatef(roty, 0.0f, 1.0f, 0.0f);
glRotatef(rotx, 1.0f, 0.0f, 0.0f);
glBegin( GL_TRIANGLES );
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f ); glVertex3f( 0.0f, 0.0f, 0.87f );
glVertex3f( -0.57f, 0.0f, -0.87f );
glVertex3f( 0.57f, 0.0f, -0.87f );
glEnd();
I tried to switch the order of the rotate functions, but the last one called would be the axes that was rotated around correctly. If anyone knows what I am doing wrong, or what I should do instead, please explain.
Thanks.