Japanese | English | Korean

Samples

アニメーションデータの切り替え

あらかじめ複数個のアニメーションデータを読み込んでおくことで、モデルのアニメーションを描画中に切り替えることができます。


複数個のアニメーションデータを読み込む場合も、必要数の ActionTable を準備し、使用するアニメーションデータを Figure.setPosture( ActionTable act, int action, int frame ) メソッドに対し渡します。
サンプルでは5キーを押すごとにアクションが切り替わります。

private ActionTable actWalk; // モデルアクションデータ
private ActionTable actBack; // モデルアクションデータ
private ActionTable[] actTable = new ActionTable[2]; // モデルアクションデータ用配列

/* MascotCapsule アクション制御用ワークデータ */
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;

/* 最大フレーム値 ( actidx = 0 ) */
max_frame[0] = actTable[0].getNumFrame( 0 );
max_frame[1] = actTable[1].getNumFrame( 0 );

/* アクション動作設定 */
if ( actID >= 2 )
actID = 0;
frame += 65536;
frame %= max_frame[actID];
figure.setPosture( actTable[actID], 0, frame );

/* アニメーション切り替え */
protected void keyPressed( int keyCode ) {
if ( keyCode == KEY_NUM5 ) {
actID++;
frame = 0;
}
} // End of keyPressed()


SampleAnimation3D 実行画面
(左:歩きのアクション,右:バク宙のアクション)