njGetMotionScale Japanese
|INDEX|
This is a node motion information function (scale).

Syntax

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

Arguments

scl
Information on scale (but scl[3])
spline_flag
Spline attribute flag (0: linear and 1:spline)

Return Value

None

Error

None

Description

Information on scale at each node is stored in the argument.
To obtain information such as frame motion, this function must call the njSetCurrentMotion function
before use, and, if necessary (if within the hierarchical structure), must call njSetNextMotionNode
to update the node information after use. (See example.)

Usage Example

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

/* This mdata is for getting object information */
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 );

  /* Execute motion function */

  /* Same as processing of the following function */
  /* 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++;

  /* Draw picture of model */
  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 );
}

...........

Remark

This function is used as one of the functions for navigating the parent-child hierarchy (push/pop).

Related Items

njSetCurrentMotion
njMotionTransform
njMotionTransformZXY
njMotionTranslate
njMotionRotateXYZ
njMotionRotateZXY
njMotionScale
njGetMotionTranslate
njGetMotionRotate
njSetNextMotionNode

njGetMotionScale
|INDEX|

Copyright SEGA ENTERPRISES, LTD., 1997