Japanese | English | Korean

Samples

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

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


複数個のアニメーションデータを読み込む場合も、必要数の ActionTable を準備し、使用するアニメーションデータを IMICRO3D_Figure_setPosture() に渡します。

サンプルでは5キーを押すごとにアクションが切り替わります。

/* アクションデータ用配列の初期化 */ IMICRO3D_ActTable_initialize( pMe  -> pIM3D,
     &pMe -> mc_data.act [ 0 ] , pMe -> pAlc );
IMICRO3D_ActTable_initialize( pMe -> pIM3D,
  &pMe -> mc_data.act [ 1 ] , pMe -> pAlc );


/* アクションデータへのパス指定 */
STRCPY( pMe -> mc_data.mbactraFile [ 1 ] , "\\data\\walk.mtra" );
STRCPY( pMe -> mc_data.mbactraFile [ 2 ] , "\\data\\back.mtra" );


/*----- アクションデータの読み込み(*.mtra)-----*/
for(loop = 0; loop < 2; loop++)
{
FileIstream_initialize( &fis , pMe  -> pIFileMgr, pMe -> mc_data.mbactraFile [ loop+1 ] );

rval = IMICRO3D_ActTable_loadMtraData( pMe  -> pIM3D,
     &pMe -> mc_data.act[loop],
      ( IIstream* ) FileIstream_getIIstream( &fis ) );
FileIstream_finalize( &fis );

if ( rval == HI_FALSE ) {
return HI_FALSE;
}

/* Figureとアクションデータを関連付ける */
IMICRO3D_ActTable_setFigure( pMe -> pIM3D,&pMe -> mc_data.act[ loop ], &pMe -> mc_data.figure );
}

/*----- キーチェックによるアニメーションの設定 -----*/
/* アクションインデックスの切り替え */
if( pMe -> mc_data.index > = 2 )
{
pMe -> mc_data.index = 0;
}

/* フレーム数取得 */
maxfrm = IMICRO3D_ActTable_getMaxFrame( pMe -> pIM3D,
          &pMe -> mc_data.act[ pMe -> mc_data.index ],
          pMe   -> mc_data.act_idx );

/* アニメーションのループ設定 */
if ( maxfrm != 0 )
{
if ( pMe -> mc_data.act_frame > maxfrm )
{
pMe -> mc_data.act_frame -= maxfrm;
}
else
{
pMe -> mc_data.act_frame = 0;
}
}

/* モデルの姿勢決定 */
IMICRO3D_Figure_setPosture( pMe   -> pIM3D,
    &pMe -> mc_data.figure,
    &pMe -> mc_data.act[ pMe -> mc_data.index ],
    pMe   -> mc_data.act_idx,
    pMe   -> mc_data.act_frame );

/* スピードの設定 */
pMe -> mc_data.act_frame += 65536;

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