Ninja Library - Model Function

njCnkPreLightModel

Pre-calculate of the chunk model light source

FORMAT

void njCnkPreLightModel( *model )
NJS_CNK_MODEL *model

PARAMETER

 *model  Pointer to chunk model structure 

RETURN

None

DESCRIPTION

Calculates the light source for the chunk model in advance.

The light source calculation result is embedded in the apex chunk. Therefore, the apex chunk format is restricted to NJD_CV_VN_D8.

The light source calculation is performed in the same manner as for njCnkDrawModel() function, with the exception that material is calculated as white. Specular is not reflected.


EXAMPLE

sbInitSystem( NJD_RESOLUTION_640x240_NTSCNI, NJD_FRAMEBUFFER_MODE_RGB565, 1 );
njInitVertexBuffer( 500000, 0, 10000, 0, 0 );
njInitMatrix( matrix, 128, 0);
njInit3D( vbuf, 4096 );
njInitView( &view );
njSetView( &view );
njCreateLight(&lt[0], NJD_SPEC_DIR);
njCreateLight(&lt[1], NJD_SPEC_POINT);
njCreateLight(&lt[2], NJD_SPEC_POINT);
njCreateLight(&lt[3], NJD_SPEC_POINT);
njSetLightDirection(&lt[0], 0.f, 0.f, -1.f);
njSetLightLocation(&lt[1], 0.f, 0.f, -12.f);
njSetLightLocation(&lt[2], 0.f, 0.f, -12.f);
njSetLightLocation(&lt[3], 0.f, 0.f, -12.f);
njSetLightRange(&lt[1], 4.f, 16.f);
njSetLightRange(&lt[2], 4.f, 16.f);
njSetLightRange(&lt[3], 4.f, 16.f);
	
njCnkSetAmbient(0.3f, 0.3f, 0.3f);
	
njSetLightColor(&lt[0], 0.3f, 0.2f, 0.1f);
njSetLightColor(&lt[1], 1.f, 0.0f, 0.0f);
njSetLightColor(&lt[2], 0.0f, 1.f, 0.0f);
njSetLightColor(&lt[3], 0.0f, 0.0f, 1.f);
njSetLightIntensity(&lt[0], 0.f, 1.f, 0.f);
njSetLightIntensity(&lt[1], 0.f, 1.f, 0.f);
njSetLightIntensity(&lt[2], 0.f, 1.f, 0.f);
njSetLightIntensity(&lt[3], 0.f, 1.f, 0.f);
	
if( _stop ) {
	njUnitMatrix(&m);
	njTranslate( &m, 0.f, 0.f, zzz );
	njRotateXYZ( &m, xx1,yy1,zz1 );
	njCalcPoint( &m, &p, &p1 );
	
	njUnitMatrix(&m);
	njTranslate( &m, 0.f, 0.f, zzz );
	njRotateXYZ( &m, xx2,yy2,zz2 );
	njCalcPoint( &m, &p, &p2 );
	
	njUnitMatrix(&m);
	njTranslate( &m, 0.f, 0.f, zzz );
	njRotateXYZ( &m, xx3,yy3,zz3 );
	njCalcPoint( &m, &p, &p3 );
	xx1 += 357;
	yy1 += 269;
	zz1 += 211;
	xx2 += 169;
	yy2 += 351;
	zz2 += 223;
	xx3 += 109;
	yy3 += 217;
	zz3 += 273;
	
	njSetLightLocation(&lt[1], p1.x, p1.y, p1.z);
	njSetLightLocation(&lt[2], p2.x, p2.y, p2.z);
	njSetLightLocation(&lt[3], p3.x, p3.y, p3.z);
}
njClearMatrix();
njTranslate( NULL, 0.f, 0.f, -10.f );
njRotateXYZ( NULL, xx,yy,zz );
if( _stop ) njCnkPreLightModel( MODEL );
njCnkEasyDrawModel( MODEL );

REFERENCE

njCnkDrawModel()
njCnkPreLightObject()

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