Ninja Library - Motion Function

njCnkGetShape

Stores node motion information

FORMAT

Int njCnkGetShape( *cnkobj, *buffer, spline_flag )
NJS_CNK_OBJECT *cnkobj
Float *buffer
Int spline_flag

PARAMETER

 *cnkobj  Object 
 *buffer  Buffer stored in the peak list (however, limited to maximum size of the model's peak list) 
 spline_flag  Spline attribute flag (0: linear, 1: spline) 

RETURN

 1  Stored peak list information of specified node in buffer 
 0  Failed to store peak list information of specified node due to no information 

DESCRIPTION

Stores each node's chunk peak list information in the allotted parameter. The buffer specified by njlnitShape() function is used when the parameter is NULL. It may be necessary to call the njCnkSetCurrentShape() function before 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 obtaining object information */
NJS_MDATA3 *mdata;
	:
Sint32 njUserMain(void)
{
 	:
 mdata = MDATA3;
 njSetCurrentMotion(MOTION, ff );
 njCnkSetCurrentShape(shape, NJD_CV_VN, ff );
 PushPopMotion( OBJECT );
 ff+=0.2f;
 if( ff >= (MOTION->nbFrame-1) ) ff=0.f;
 	:
}
void
PushPopMotion( NJS_CNK_OBJECT *cnkobj )
{
    Float	pos[3], scl[3];
    Angle	ang[3];
    Sint32	*vlist;
    
    do {
        njPushMatrix( NULL );
    
        if (mdata->p[0] != NULL) {
    	    njGetMotionTranslate( pos, spline_flg );
        } else {
    	    pos[0] = cnkobj->pos[0];
    	    pos[1] = cnkobj->pos[1];
    	    pos[2] = cnkobj->pos[2];
        }
    
        if (mdata->p[1] != NULL) {
    	    njGetMotionRotate( ang, spline_flg );
        } else {
    	    ang[0] = cnkobj->ang[0];
    	    ang[1] = cnkobj->ang[1];
    	    ang[2] = cnkobj->ang[2];
        }
    
        if (mdata->p[2] != NULL) {
    	    njGetMotionScale( scl, spline_flg );
        } else {
    	    scl[0] = cnkobj->scl[0];
    	    scl[1] = cnkobj->scl[1];
    	    scl[2] = cnkobj->scl[2];
        }
    
        njTranslate( NULL, pos[0], pos[1], pos[2] );
        njRotateZXY( NULL, ang[0], ang[1], ang[2] );
        njScale( NULL, scl[0], scl[1], scl[2] );
        njSetNextMotionNode();
        mdata++;
        if ( cnkobj->model != NULL )
	    vlist = cnkobj->model->vlist;
    
        if ( !(cnkobj->evalflags & NJD_EVAL_SHAPE_SKIP)) {
    	    if (njCnkGetShape(cnkobj, NULL, spline_flg))
		cnkobj->model->vlist = (Sint32*)sbuf;
        }
    
        if( (cnkobj->model != NULL)
		&& (!(cnkobj->evalflags & NJD_EVAL_HIDE)) ) {
    	    njCnkEasyDrawModel( cnkobj->model );
    	    cnkobj->model->vlist = vlist;
        }
    
        if( cnkobj->child != NULL )
    	    PushPopMotion( (NJS_CNK_OBJECT*)cnkobj->child );
    
        njPopMatrix( 1 );
    
        cnkobj = cnkobj->sibling;
    } while( cnkobj != NULL );
}
	:

NOTE

This function is for use during tracing (push-pop) of the chunk model's parent hierarchy.

REFERENCE

njCnkSetCurrentShape()

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