Hello,
I hope someone can help me, I have been looking at this for a while, and have managed to confuse myself with this little problem. I have a program that succefully(well almost) provides 6 degrees of movement(rotation around x, y, and z axis of camera and movement in x, y, and z axis of camera).
When I rotate up and down(around x axis) and left to right(around z axis) things work fine for a bit, but then the camera seems to start to rotate around the y axis. There is no way to do a y axis rotation in my code. I think it comes from the fact that I do some transformations to write some text to the screen, and exit out of these transfomation incorrectly. I am going to try an show the relevant snippets of code.
Thanks for any help or ideas.
-Drew
==================================
glViewport( 0, 0, width, height);
Vector3 eVec( eye.x, eye.y, eye.z );
m[0] = u.x; m[4] = u.y; m[8] = u.z; m[12] = -eVec.dot( u );
m[1] = v.x; m[5] = v.y; m[9] = v.z; m[13] = -eVec.dot( v );
m[2] = n.x; m[6] = n.y; m[10] = n.z; m[14] = -eVec.dot( n );
m[3] = 0; m[7] = 0; m[11] = 0; m[15] = 1.0;
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( m );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( viewAngle, aspect, nearDist, farDist );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
displayPoints();
createFloor();
createHead();
createBody();
createRightArm();
createLeftArm();
createWaist();
createLeftLeg();
createRightLeg();
createClub();
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
gluOrtho2D( 0, width, 0, height );
glScalef( 1, -1, 1 );
glTranslatef( 0, -height, 0 );
glMatrixMode( GL_MODELVIEW );
// start doing transformation to write text
// to screen
glPushMatrix();
glLoadIdentity();
if( showFrame == 1 )
{
outputText.renderBitMapString( width * 0.8, 20, GLUT_BITMAP_HELVETICA_10, string );
}
showInfo(); //writes more text to screen
// done writing to screen. Now undo
// transformations to set up for next redraw
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glutSwapBuffers();
redisplay();