Ninja Library - 3D Graphics Function

njDrawPolygon3D

Draws a polygon in 3D space

FORMAT

void njDrawPolygon3D( *p, n, attr )
NJS_POINT3COL *p
Int n
Uint32 attr

PARAMETER

 *p  List of coordinates of vertices of a polygon to be drawn 
 n  Number of vertices of a polygon 
 attr  Attributes (specifies the drawing method) 

RETURN

None

DESCRIPTION

Draws n squares in 3D space. The maximum number of vertices is 32. The following attributes are used. To specify the conditions for drawing n squares:

 NJD_DRAW_NORMAL  Draws n squares. 
To specify the drawing method for n squares:
 not specified  Wire frame 
 NJD_FILL  Interior of n squares filled. 
 NJD_TRANSPARENT  Transparent drawing. 
 NJD_USE_TEXTURE  Drawing with texture. 

These 4 attributes can be used in mutually consistent combinations by using the "|" character as a delimiter.


EXAMPLE

The following draws 100 squares at random.
int i;
int i;
NJS_POINT3 point[4];
NJS_COLOR color[4];
NJS_POINT3COL p;
p.p = point;
p.col = color;
p.tex = NULL;
p.num = 4;
for(i = 0; i< 100; i++){
  int j;
  p.p[0].x = njRandom()*1000.f-500.f;
  p.p[0].y = njRandom()*1000.f-500.f;
  p.p[0].z = -3000.f+(float)i;
  p.p[1].x = p.p[0].x-polysize;
  p.p[1].y = p.p[0].y;
  p.p[1].z = p.p[0].z;
  p.p[2].x = p.p[0].x-polysize;
  p.p[2].y = p.p[0].y-polysize;
  p.p[2].z = p.p[0].z;
  p.p[3].x = p.p[0].x;
  p.p[3].y = p.p[0].y-polysize;
  p.p[3].z = p.p[0].z;
  for(j = 0; j < 4; j++){
    p.col[j].argb.a = (Uint8)(0x80*njRandom());
    p.col[j].argb.r = (Uint8)(0x80*njRandom());
    p.col[j].argb.g = (Uint8)(0x80*njRandom());
    p.col[j].argb.b = (Uint8)(0x80*njRandom());
  }
  njDrawPolygon3D(&p, 4, NJD_DRAW_NORMAL|NJD_FILL);

NOTE

Since this function draws in 3D, be sure to make appropriate view, screen, and matrix stack settings before calling this function. The NJD_DRAW_NORMAL may be omitted when it is used in combination with other attributes.

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