Rotating Robot

Started by
2 comments, last by Aggrix 22 years, 2 months ago
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
Advertisement
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
I just tried but it didnt work. Any more ideas?



Thanx
It seems to me that it should be done like so:

  // 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
"The important thing to remember when programming is: When you're 90% complete, there's still 50% more to go."

This topic is closed to new replies.

Advertisement