Archived

This topic is now archived and is closed to further replies.

Rotating Robot

This topic is 5798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
It seems to me that it should be done like so:

  
// get a new matrix to muck with

glPushMatrix();
// 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

Share this post


Link to post
Share on other sites