njGetMotionScale
ノード・モーション情報関数(スケール)

書 式

#include <Ninja.h>
void    njGetMotionScale( Float *scl, Int spline_flag );
Float   *scl
Int     spline_flag

引 数

scl
スケール情報(ただし、scl[3])
spline_flag
スプライン属性フラグ(0:リニア、1:スプライン)

返 値

なし

エラー

なし

機 能

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

用 例

#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 );
}

...........

備 考

この関数は親子階層をたどる(プッシュ・ポップ)関数中で使用するための関数です。

関 連

njSetCurrentMotion
njMotionTransform
njMotionTransformZXY
njMotionTranslate
njMotionRotateXYZ
njMotionRotateZXY
njMotionScale
njGetMotionTranslate
njGetMotionRotate
njSetNextMotionNode

njGetMotionScale

Copyright SEGA ENTERPRISES, LTD., 1998