#include <NINJA.H>
#define OBJECT object_sample
#define MOTION motion_sample
#define MDATA3 ((NJS_MDATA3 *) MOTION->mdata)
#define LINEAR 0
#define SPLINE 1
extern NJS_MOTION MOTION[];
extern NJS_OBJECT OBJECT[];
Float ff = 0.f;
Int spline_flg = SPLINE;
/*このmdataはオブジェクト情報取得のため*/
NJS_MDATA3 *mdata;
...........
Sint32 njUserMain(void)
{
...........
mdata = MDATA3;
njSetCurrentMotion(MOTION, ff );
PushPopMotion( OBJECT );
ff+=0.2f;
if( ff >= (MOTION->nbFrame-1) ) ff=0.f;
...........
}
PushPopMotion(NJS_OBJECT *obj)
{
float pos[3], scl[3];
Angle ang[3];
njPushMatrix( NULL );
/* モーション関数の実行 */
/* 下記の関数の処理と同意義 */
/* njMotionTranslate( NULL, obj, spline_flg ); */
/* njMotionRotateXYZ( NULL, obj, spline_flg ); */
/* njMotionScale( NULL, obj, spline_flg ); */
/* njSetNextMotionNode(); */
if (mdata->p[0] != NULL) {
njGetMotionTranslate( pos, spline_flg );
} else {
pos[0] = obj->pos[0];
pos[1] = obj->pos[1];
pos[2] = obj->pos[2];
}
if (mdata->p[1] != NULL) {
njGetMotionRotate( ang, spline_flg );
} else {
ang[0] = obj->ang[0];
ang[1] = obj->ang[1];
ang[2] = obj->ang[2];
}
if (mdata->p[2] != NULL) {
njGetMotionScale( scl, spline_flg );
} else {
scl[0] = obj->scl[0];
scl[1] = obj->scl[1];
scl[2] = obj->scl[2];
}
njTranslate( NULL, pos[0], pos[1], pos[2] );
njRotateXYZ( NULL, ang[0], ang[1], ang[2] );
njScale( NULL, scl[0], scl[1], scl[2] );
njSetNextMotionNode();
mdata++;
/* モデルの描画 */
if( obj->model != NULL )
njDrawModel( obj->model );
if( obj->child != NULL )
PushPopMotion( (NJS_OBJECT*)obj->child );
njPopMatrix( 1 );
if( obj->sibling != NULL )
PushPopMotion( (NJS_OBJECT*)obj->sibling );
}
...........