Advertisement

Rotating Cube Problem.

Started by October 11, 2001 06:26 AM
1 comment, last by Ada 23 years, 4 months ago
Hello, I want to create a 3d cube rotating on a plane. I set one of the angel of the cube at 0,0,0. And I try to rotate the cube along z . After it rotate 90''. How can I make the cube start the second rotation on other side, so that it can move forward? The question in graphic... http://tenthousand.uhome.net/question.jpg Sorry for my poor English, Hope you know what I mean. Thank you!!
To roll a cube to the right do you not have to change the point it is rotating around. Just rotate and move it.

To change the point you turn your object around should you switch the order of the rotate and translate calls. You probably need a much better explenation than this so I recommend the red book.
Advertisement
You must translate the cube "l" units to the left (where "l" is the length of the side) so the rotation axis is placed on the other side, rotate the cube and then translate it 2*l units to the right to get the real position.

An easier way is to draw the cube with the origin matching its center, then rotate the amount you want, then translate it to the desired position:

Picture 1: LoadIdentity(), Rotate 90º, translate l/2 to the right.
Picture 2: LoadIdentity(), Rotate 180º, translate 3*l/2 to the right.

Edited by - azdo on October 11, 2001 3:02:26 PM

This topic is closed to new replies.

Advertisement