View Full Version : Rotating character
01-19-2008, 10:27 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?
01-20-2008, 05:51 AM
You probably ordered your transformation calls incorrectly. The last matrix operation call is performed first, so
first rotates about the origin and then translates the object, while
first translates the object away from the origin and then rotates about the origin.
01-20-2008, 10:15 PM
Thanks and I have tried changing the order but then after I rotate the character and try to have then walk in the direction they are facing they still walk straight at the camera and not in the direction they are facing. How can I get them to rotate around the spot they are standing and still walk in the direction they are facing?
01-21-2008, 11:31 AM
We're going to need to see some code to find out what you're doing wrong at this point. Don't forget the [ code ][ /code ] tags.
01-21-2008, 05:35 PM
Here is the code I wrote
[ code ]
void Robot::DrawHead()//draws the head of the character
glTranslatef(sidedistance,1.3,distance);//sidedistance is distance up and down x axis and distance is distance up and down z axis
void Robot::DrawRobot(float x, float y, float z)//draws the character
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
[ /code ]
01-24-2008, 09:16 AM
Does anyone have any ideas how I can get the robots to rotate around whatever point they are at and not the orgin and still move in the direction they are facing?
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.