PDA

View Full Version : simple rotation



mikethebike
01-10-2012, 08:31 AM
Maybe it's too late....I simply want to flip that triangle 180' so I can see it from behind. Now I've tried to add 180 to the rotations below (mpPsi+180 etc.)without success:

glBegin(GL_TRIANGLES); //position glTranslatef(floc3DX, floc3DY, floc3DZ);
glRotatef( mpPsi, 0.0f, -1.0f, 0.0f ); //heading?
glRotatef( mpTheta, 1.0f, 0.0f, 0.0f); //pitch?
glRotatef( mpPhi, 0.0f, 0.0f, -1.0f); //roll

glColor3f(0.0, 0.0, 1.0); /* blue */
glVertex3f(floc3DX, floc3DY, floc3DZ-2);
glColor3f(0.0, 1.0, 0.0); /* green */
glVertex3f(floc3DX+1, floc3DY+1, floc3DZ-2);
glColor3f(1.0, 0.0, 0.0); /* red */
glVertex3f(floc3DX-1, floc3DY+1, floc3DZ-1);
glEnd();

Many thanks

dorbie
01-10-2012, 01:15 PM
Do not put your glTranslate & glRotate calls inside your glBegin glEnd code block. Move them before the glBegin.

mikethebike
01-11-2012, 01:40 AM
if i do that nothing is visible, probably drawn to far away.
if i only move glrotate before glbegin triangles are drawn randomly around (for loop but those x,y,z values do not change)
but anyway the rotations etc. are not done at all.

dorbie
01-11-2012, 11:30 AM
Start mpPs etc at 0.0, and ingrement by small values.

The location you have these is close to the polygon and is in the correct location to rotate the triangle .

Remember that the modelview matrix is state and is persistent over time, it will begin where you left it at the end of the previous frame.

You should be using:
glMatrixMode
glLoadIdentity

To manage which matrix you edit and ensure you start with a clean slate each frame.