Rotation help needed...
So, im trying to create a triangle that can move around on a quad... fLook is his heading, 0.0f - 360.0f, and this is where i want him too point when i move the mouse (incressed/decressed when moving the mouse ;)) if i dont move him he stands in the middle of the quad, and the rotation works perfect, but, as i move him forward/backwards he starts to rotate in a circle around the center of the quad...
thanks for reading...
<CODE>
g_Me.GetPos(unit);
g_Me.GetHeading(fLook);
glRotatef(fLook, 0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex3f( 0.0f + unit.fX, 0.1f + unit.fY, 0.1f + unit.fZ);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.1f + unit.fX,-0.1f + unit.fY, 0.1f + unit.fZ);
glVertex3f( 0.1f + unit.fX,-0.1f + unit.fY, 0.1f + unit.fZ);
glEnd();
glLoadIdentity ();
glTranslatef (0.0f, 0.0f, -7.0f);
glBegin(GL_QUADS);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f( 2.0f, 2.0f, 0.0f);
glVertex3f(-2.0f, 2.0f, 0.0f);
glVertex3f(-2.0f,-2.0f, 0.0f);
glVertex3f( 2.0f,-2.0f, 0.0f);
glEnd();
</CODE>
The more you know, the more you know that you dont know.
Try translating him back to the origin, rotating him, then translating him to the new position.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement