
|
Creating 3D effects can be simple, and if you have the right tools, it is not difficult to create complex 3D animations. In this example, the dice and animations are created using 3D Studio Max. Instead of calculating the movement of a mesh, the movement can be pre-created and stored in a mtra file for Mascot Capsule v3 or in the m3g file for JSR184. In the example below, six animations are created, one for each dice face.
To ensure that each throw of the dice is different, the z-axis rotation is randomized. The code example for this animation is below: Store the number of frames each animation is built of. private final int []frameLength = new int[] {80,65,70,80,55,75}; Load the dice model. diceFigure = new Figure("/res/dice.mbac"); Instead of using six different animation files they could all be merged into one file. action[0] = new ActionTable("/res/one.mtra"); Keep updating the frame of the animation in the gameloop. if(diceOneFrame < action[diceOneIndex].getNumFrames(0)){ |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.