Rotating Robot
I made a little robot out of cubes.(kind of like the one in OpenGL Game Programming[Great Book]) Anyway, I have it move backward and forward based on the direction he is facing. I also have him spin(rotate) left and right to give him a new direction to move. The problem is, when I move him farther away from his starting position and spin him, he spins in a wide circle around his starting position instead of being still and spinning. I do i make it so he stands still and spins? I hope this is not confusing.
Thanx
It sounds like you have your matrix transformations out of order. I think you need to put rotation before translation to get what you want. I may be wrong though, I''m no expert
It seems to me that it should be done like so:
- Mike
Edited by - mkaltner on January 30, 2002 8:14:49 PM
// get a new matrix to muck withglPushMatrix(); // translate to the position of the robot glTranslatef(robotX, robotY, robotZ); // rotate at that position glRotatef(robotRot, 0.0f, 1.0f, 0.0f); // draw the robot DrawRobot();glPopMatrix();
- Mike
Edited by - mkaltner on January 30, 2002 8:14:49 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement