rotating model

I am working on a program that displays 4 robots drawn using cylinders and spheres and they move foward and backward and side to side using the arrow keys and the mouse rotates them. I am having trouble geting them to rotate around the point they are standing at. After I move them away from their starting position when I rotate them they rotate around the starting point but I want them to rotate around the point they are standing at. If I reverse the glrotate and gltranslate they rotate correctly but no longer move in the direction they are facing. Is there even a way to get the robots to walk the way they are facing and still rotate around the point they are standing?
Here is some of my code
[ code ]
void Robot::DrawHead()//draws the head of the character
{
glPushMatrix();
glTranslatef(sidedistance,1.3,distance);//sidedistance is distance up and down x axis and distance is distance up and down z axis
glRotatef(90.0,1.0,0.0,0.0);
GLUquadricObj* head=gluNewQuadric();
gluSphere(head,0.3,20,20);
glPopMatrix();
}
//Other parts drawn and omitted

void Robot::DrawRobot(float x, float y, float z)//draws the character
{
glLoadIdentity();
glTranslatef(x,y,z);
gluLookAt(sin(angle0.0174532925),0.0,cos(angle0.0174532925),0.0,0.0,0.0,0.0,1.0,0.0);// angle is the amount of rotation
glColor3fv(color);
if ((armsraised)&&(!walking)&&(!sidestep))
DrawRobotArmsRaised();
if ((armslowered)&&(!walking)&&(!sidestep))
DrawRobotArmsLowered();
if ((walking)&(!sidestep))
DrawRobotWalking();
if ((sidestep)&&(!walking))
DrawRobotSideStep();
if ((!walking)&&(!armsraised)&&(!armslowered)&&(!sidestep))
DrawRobotStanding();
}
[ /code ]

I’m not 100% sure but I think your solution is to rotate both before and after translation.

Thanks Y-tension but rotating both before and after did not help the problem.

try doing what you did that made it translate and rotate correctly. you just need to fiddle with the code that moves it in the right direction. This involves trig.
To better understand how to solve your problem try making
the arrow keys rotate the camera and use WSAD to move forward back etc. you will have to keep track of the increase in angles x,y components.

and using trig you will be able to make the camera move forward when you press W. if your trig is wrong it won’t move forward. Now you have to do a similar thing with your robot. this exercise will just help you to understand how

I only want the camera to move left and right so it looks like the robots are rotating is why I use the mouse moving right increases the angle to rotate and left decreases the angle. I am not sure what trig you mean Nyad can you explain more. I am probally not looking at the big picture and missing something small since I am focused on simple opengl commands since I am learning opengl still.

Trig. means trigonometry. You have to change distance and sidedistance based on the angle of rotation. For example if fangle is the angle of counterclockwise rotation of your model around the y axis, you have to modify distance by cos(fangle) and distance by sin(fangle). And remember, OpenGL counts angles by degrees while most c library cos and sin functions use radians. so radians = (2PIdegrees)/360.0 .