PDA

View Full Version : Rotating character



Fred F
01-31-2008, 10:15 PM
I am writting a program that moves robots around the screen and I use glulookat to move the camera to make them rotate but once I move them away from the orgin they then rotate around that. I have tried doing the opposite of the translation before the glulookat but then the robots don't move at all. How can I make them rotate around just the spot they are standing?
Here is the code I wrote

[ 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();
}


void Robot::DrawRobot(float x, float y, float z)//draws the character
{
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);// 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 ]