Ninja Library - Motion Function

njGetMotionTranslate

Stores move information

FORMAT

void njGetMotionTranslate( *pos, spline_flag )
Float *pos
Int spline_flag

PARAMETER

 *pos  Information on move (but pos[3]) 
 spline_flag  Spline attribute flag (0: linear and 1:spline) 

RETURN

None

DESCRIPTION

Stores information on move at each node in the parameter. 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() function to update the node information after use. (See example.)

EXAMPLE

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

NOTE

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

REFERENCE

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

njGetMotionTranslate
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999