Switching the animation data
Load multiple animation data in advance, in order to switch the model's animation in the middle of rendering process.
In order to load multiple animation data, prepare the necessary number of ActionTable, and pass the animation data to be used to the Figure.setPosture( ActionTable act, int action, int frame ) method.
In this sample, the action is switched every time the soft key is pressed-down.
private ActionTable actWalk; // Model action data
private ActionTable actBack; // Model action data
private ActionTable[] actTable = new ActionTable[ 2 ]; // Model action data array
/* MascotCapsule MascotCapsule work data for controlling the action */
private int frame;
private int[] max_frame = new int[ 2 ];
private int actID = 0;
actWalk = new ActionTable( "/walk.mtra" );
actBack = new ActionTable( "/back.mtra" );
actTable[ 0 ] = actWalk;
actTable[ 1 ] = actBack;
/* Maximum frame value ( actidx = 0 ) */
max_frame[ 0 ] = actTable[ 0 ].getNumFrame( 0 );
max_frame[ 1 ] = actTable[ 1 ].getNumFrame( 0 );
/* Specifying the action setting */
if ( actID >= 2 )
frame %= max_frame[ actID ];
figure.setPosture( actTable[ actID ], 0, frame );
/* Switching the animation */
public void commandAction( Command c, Displayable d ) {
private ActionTable actBack; // Model action data
private ActionTable[] actTable = new ActionTable[ 2 ]; // Model action data array
/* MascotCapsule MascotCapsule work data for controlling the action */
private int frame;
private int[] max_frame = new int[ 2 ];
private int actID = 0;
actWalk = new ActionTable( "/walk.mtra" );
actBack = new ActionTable( "/back.mtra" );
actTable[ 0 ] = actWalk;
actTable[ 1 ] = actBack;
/* Maximum frame value ( actidx = 0 ) */
max_frame[ 0 ] = actTable[ 0 ].getNumFrame( 0 );
max_frame[ 1 ] = actTable[ 1 ].getNumFrame( 0 );
/* Specifying the action setting */
if ( actID >= 2 )
actID = 0;
frame += 65536;frame %= max_frame[ actID ];
figure.setPosture( actTable[ actID ], 0, frame );
/* Switching the animation */
public void commandAction( Command c, Displayable d ) {
String label = c.getLabel();
if( label.equals( "CHANGE" ) ){
} // End of commandActionif( label.equals( "CHANGE" ) ){
actID++;
frame = 0;
}
frame = 0;

SampleAnimation3D screenshots
(Left: walking action; right: back somersault action)
Quick Links
- MIDP + com.mascotcapsule package (MascotCapsule V3 API)
- Basic rendering
- Rendering a 3D model / Semi-transparency using BlendHalf / Additive and subtractive blending effects / Switching the animation data / Switching the pattern using dynamic polygons / Lighting / Shading / Using the environment map / Rendering the primitives / Reducing the texture distortion / Preventing Z-sort rendering mistakes under certain circumstances / Coordinate systems and the camera / Projection methods
- Basic rendering
- Go back to Samples index

