Samples

Switching the animation data

Load multiple animation data in advance in order to switch the model's animation during the 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 IMICRO3D_Figure_setPosture() method.

In this sample, the action is switched every time the key 5 is pressed-down.

/* Initializing the action data array */
IMICRO3D_ActTable_initialize( pMe  -> pIM3D,
   &pMe -> mc_data.act [ 0 ] , pMe -> pAlc );
IMICRO3D_ActTable_initialize( pMe -> pIM3D,
  &pMe -> mc_data.act [ 1 ] , pMe -> pAlc );


/* Specifying the action data path */
STRCPY( pMe -> mc_data.mbactraFile [ 1 ] , "\\data\\walk.mtra" );
STRCPY( pMe -> mc_data.mbactraFile [ 2 ] , "\\data\\back.mtra" );


/*----- Loading the action data (*.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;
}

/* Associating the Figure and the action data */
IMICRO3D_ActTable_setFigure( pMe -> pIM3D,&pMe -> mc_data.act[ loop ], &pMe -> mc_data.figure );
}

/*----- Animation setting by the key check -----*/
/* Switching the action index */
if( pMe -> mc_data.index > = 2 )
{
pMe -> mc_data.index = 0;
}

/* Obtaining the number of frames */
maxfrm = IMICRO3D_ActTable_getMaxFrame( pMe -> pIM3D,
          &pMe -> mc_data.act[ pMe -> mc_data.index ],
          pMe   -> mc_data.act_idx );

/* Animation loop setting */
if ( maxfrm != 0 )
{
if ( pMe -> mc_data.act_frame > maxfrm )
{
pMe -> mc_data.act_frame -= maxfrm;
}
else
{
pMe -> mc_data.act_frame = 0;
}
}

/* Specifying the model posture */
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 );

/* Specifying the speed */
pMe -> mc_data.act_frame += 65536;
SampleAnimation3D screenshots : walking action SampleAnimation3D screenshots : back somersault action
SampleAnimation3D screenshots
( Left: walking action; right: back somersault action )


Page TopBack