• ### Announcements

#### Archived

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

# Rotating Robot

## Recommended Posts

Aggrix    122
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 on other sites
Anozireth    122
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 on other sites
Aggrix    122
I just tried but it didnt work. Any more ideas?

Thanx

##### Share on other sites
mkaltner    122
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