Ninjaライブラリ - モーション関数

njGetMotionRotate

ノード・モーション情報関数(回転)

書式

void njGetMotionRotate( Float *rot, Int spline_flag );
Float *rot
Int spline_flag

引数

*rot回転情報(ただし、rot[3])
spline_flagスプライン属性フラグ(0:リニア、1:スプライン)

戻値

なし

解説

ノード毎の回転情報を与えられた引数に格納します。 この関数は、フレーム・モーション等の情報を得るために、使用前にnjSetCurrentMotion関数を呼ぶこと、 また必要であれば(階層構造中であれば)使用後にノード情報を更新するために njSetNextMotionNodeを呼ぶ必要があります(用例参照)。

用例

#include <Shinobi.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 );
}
	:

参照

njSetCurrentMotion()
njMotionTransform()
njMotionTransformZXY()
njMotionTranslate()
njMotionRotateXYZ()
njMotionRotateZXY()
njMotionScale()
njGetMotionTranslate()
njGetMotionScale()
njSetNextMotionNode()

njGetMotionRotate
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998