Japanese | English | Korean

Samples

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 )
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" ) ){
actID++;
frame = 0;
}
} // End of commandAction


SampleAnimation3D screenshots
(Left: walking action; right: back somersault action)