Rotation demo
Home Up Care and Feeding Library Docs Rotation demo

 

3D Free rotation demo

Torus model demo

The following file is intended to demonstrate the basic axes of rotation for an object, and the difference between rotating around the game's axes and rotation around the object's axes. I have the x axis going away from the screen into the room, the y axis pointing to the right and the z axis pointing up.

There are thirteen keys to rotate the object as follows:

Q and A rotate around the object's x axis.
W and S rotate around the object's y axis
E and D rotate around the object's z axis.
R and F rotate around the room x axis.
T and G rotate around the room y axis.
Y and H rotate around the room z axis.
Enter resets to the starting orientation.

In addition Space toggles between a few different models. The second model is a torus generated by the donut.gml script.

In order to see the difference between the object's axes and the rooms axes try a simple experiment:

Start with the object in default position and see that the Q, A keys and the R and F keys have the same effect.

Press enter to reset position.

Press W until the object is tipped over by 90 degrees.

Observe that now the Q, A keys now turn the object around the z axis, the same as the Y, H keys. Because the object has been turned around it's y axis its x axis is now in line with the room's z axis.

Amazingly enough when we use quaternions it is not necessary to keep track of this or transform our rotations to take into account the effect of previous orientation. There are two ways to apply the rotation as described here, and one way applies it using the room's orientation, the other applies it using the object's orientation. I can't say why, it just does.

q_demo.gm6 q_demo.zip

 

Home Up Care and Feeding Library Docs Rotation demo