Game Development Reference
In-Depth Information
//rotateM(float[] m, int mOffset, float a, float x, float y, float z)
//Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z)
Matrix.rotateM(m_RotationMatrix, 0,
AngleIncrementDegrees,
m_RotationAxis.x,
m_RotationAxis.y,
m_RotationAxis.z);
}
What occurs here is the angle for the object to be rotated is added to the m_RotationAngle variable,
which holds the current angle of rotation of the object. The rotation matrix, which is m_RotationMatrix ,
is then modified to reflect the addition of the new angle delta. Run the program and you see the
cube rotating as in Figure 3-24 .
Figure 3-24. Cube rotating
Moving an Object in 3D Space
Now, we will guide you through moving the cube back and forth along the z axis. Because the z axis
is facing toward you, the cube will be getting larger and smaller.
First, we should stop the cube from rotating. Comment out the AddRotation() function, as shown in
Listing 3-12.
 
Search WWH ::




Custom Search