
|
April 2005 |
[Back] | ||||||||||||||||||||||
|
| |||||||||||||||||||||||
|
There are a few ways to rotate objects in Mascot Capsule v3 and here we explain how you can perform rotation around an arbitrary axis. Mascot Capsule v3 uses an Affine transformation matrix to move, scale and rotate objects. It is possible to set the values directly, but in this example we use the rotation methods in the AffineTrans class. Rotation should always be made with values within ± 2880 degrees. In Mascot Capsule the value 4096 = 360 degrees. An example of an AffineTrans matrix for handling rotation and translation of an animation:
In this example we have one main transformation class that is used with the layout.
layout = new FigureLayout();
trans = new AffineTrans(); trans.setIdentity();
layout.setAffineTrans( trans ); We also use three AffineTrans classes to do the rotation:
rotationX = new AffineTrans(); rotationY = new AffineTrans(); rotationZ = new AffineTrans(); The reason for using separate matrices is that the rotation methods simply set the appropriate values in the matrix. The application of a second rotation method to the same matrix simply overwrites the values of the previous rotation. Each rotation must be applied to a separate matrix, and then these matrices are multiplied with each other to produce the final result.
In the main thread we multiply them with the main transformation:
rotationX.rotationX(23);
rotationY.rotationY(23); rotationZ.rotationZ(23); trans.mul(rotationX); trans.mul(rotationY); trans.mul(rotationZ); | |||||||||||||||||||||||
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.