Ninja Library - 2D Drawing Function

njDrawSprite3D

Draws a 3D sprite

FORMAT

void njDrawSprite3D( *sp, n, attr )
NJS_SPRITE *sp
Int n
Uint32 attr

PARAMETER

 *sp  Pointer to sprite structure 
 n  Sprite number 
 attr  Attribute 

RETURN

None

DESCRIPTION

Draws 3D sprite. Sprite can draw textures and its animations easily. Sprite draws in the XYZ space.

The following attributes can be set:

 -NJD_SPRITE_ANGLE  Validate texture rotation. 
 -NJD_SPRITE_COLOR  Validate texture color operation. Values set by njSetConstantMaterial() used for color data. 
 -NJD_SPRITE_HFLIP  Reverse texture horizontally (right/left). 
 -NJD_SPRITE_VFLIP  Reverse texture vertically (up/down). 
 -NJD_SPRITE_ALPHA  Set if transparency or extract texture is used. 
 -NJD_SPRITE_SCALE  Turn towards screen front. 


EXAMPLE

The following uses two 256x256 textures, divides each texture into 4 patterns 
and makes 8 texture animation patterns.

NJS_TEXANIM anim[] = {
 { 128,128, 64, 64, 0, 0,127,127, 0, 0 },
 { 128,128, 64, 64,128, 0,255,127, 0, 0 },
 { 128,128, 64, 64, 0,128,127,255, 0, 0 },
 { 128,128, 64, 64,128,128,255,255, 0, 0 },
 { 128,128, 64, 64, 0, 0,127,127, 1, 0 },
 { 128,128, 64, 64,128, 0,255,127, 1, 0 },
 { 128,128, 64, 64, 0,128,127,255, 1, 0 },
 { 128,128, 64, 64,128,128,255,255, 1, 0 },
};
main() {
 NJS_SPRITE sprite;
/* Initial setup of each type */
 sprite.tlist = &texlist;
 sprite.tanim = anim;
 sprite.ang = 0;
 sprite.sx = 1.0f;
 sprite.sy = 1.0f;
 sprite.p.x = 0.0f;
 sprite.p.y = 0.0f;
 sprite.p.z = 0.0f;
 sbInitSystem( NJD_RESOLUTION_640x480_NTSCNI, NJD_FRAMEBUFFER_MODE_RGB565, 1 );
 njInitMatrix( matrix, 128, 0 );
 njInit3D( vbuf, 4096 );
 njInitView( &view );
 njCreateLight( &light, NJD_DIR_LIGHT );
 njSetView( &view );
 
 njInitTexture( texmemlist,20);
 njLoadTexture(&texlist);
 
 while(1) {
  njClearMatrix();
  njTranslate( NULL, 0.f, 0.f, -400.f );
  njDrawSprite3D( &sprite, 2, NJD_SPRITE_ANGLE );
  sprite.angle += 100;
  	:
 }
}

REFERENCE

njDrawSprite2D()
njSetConstantMaterial()
njLoadTexture()
njDrawModel()

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