PDA

View Full Version : 3d rotaion and translation



Fred F
08-16-2008, 11:52 AM
I have the following code

glLoadIdentity();
glTranslatef(x,y,z);
gluLookAt(sin(angle*0.0174532925),0.0,cos(angle*0. 0174532925),0.0,0.0,0.0,0.0,1.0,0.0);
glTranslatef(sidedistance,0.0,distance);
glColor3fv(color);
if ((armsraised)&&(!walking)&&(!sidestep))
DrawRobotArmsRaised();
if ((armslowered)&&(!walking)&&(!sidestep))
DrawRobotArmsLowered();
if ((walking)&(!sidestep))
DrawRobotWalking();
if ((sidestep)&&(!walking))
DrawRobotSideStep();
if ((!walking)&&(!armsraised)&&(!armslowered)&&(!side step))
DrawRobotStanding();
I am trying to get the models to be able to walk forward and backwards and sidestep left and right using the arrow keys and rotate using the mouse. The problem is with the rotation no matter what I do they always rotate around the origin and if I put the gltranslates before the glulookat then they rotate correctly but do not move correctly.
Can anyone help me fix this problem?

tanzanite
08-17-2008, 06:10 AM
Lots of advanced threads you spawn :p