##### Ninja Library - 3D Graphics Function

# njDrawTriangle3D

Draws triangles in 3D space

### FORMAT

`

  void njDrawTriangle3D( *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 triangles to be drawn
  `attr` | Attributes (specifies the drawing method)

### RETURN

  None

### DESCRIPTION

  Draws n number of triangles. The following attributes can be used. To specify conditions for drawing triangles:

  -NJD_DRAW_NORMAL | Independent triangle drawn.
  -NJD_DRAW_CONNECTED | Connected triangles drawn.

  To set triangle drawing method:

  -not set | wire frame
  -NJD_FILL | Interior of triangle filled.
  -NJD_TRANSPARENT | Transparent drawing.
  -NJD_USE_TEXTURE | Drawing with texture.

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

### EXAMPLE

      The following draws 100 triangles at random.
      #define TRI_NUM 100
      #define trisize 50.f
      int i;
      NJS_POINT3COL p;
      NJS_POINT3 point[TRI_NUM*3];
      NJS_COLOR color[TRI_NUM*3];
      float trisize_half = trisize/2.f;
      float trihight;
      p.p = point;
      p.col = color;
      p.tex = NULL;
      p.num = TRI_NUM*3;
      trihight = trisize_half*njSqrt(3.f);
      i = 0;
      do{
        p.p[i].x = njRandom()*1000.f-500.f;
        p.p[i].y = njRandom()*1000.f-500.f;
        p.p[i].z = -3000.f+(float)i;
        p.col[i].argb.a = (Uint8)(0x80*njRandom());
        p.col[i].argb.r = (Uint8)(0x80*njRandom());
        p.col[i].argb.g = (Uint8)(0x80*njRandom());
        p.col[i++].argb.b = (Uint8)(0x80*njRandom());
        p.p[i].x = p[i-1].p.x+trisize_half;
        p.p[i].y = p[i-1].p.y+trihight;
        p.p[i].z = p[i-1].p.z;
        p.col[i].argb.a = (Uint8)(0x80*njRandom());
        p.col[i].argb.r = (Uint8)(0x80*njRandom());
        p.col[i].argb.g = (Uint8)(0x80*njRandom());
        p.col[i++].argb.b = (Uint8)(0x80*njRandom());
        p.p[i].x = p[i-2].p.x-trisize_half;
        p.p[i].y = p[i-2].p.y+trihight;
        p.p[i].z = p[i-2].p.z;
        p.col[i].argb.a = (Uint8)(0x80*njRandom());
        p.col[i].argb.r = (Uint8)(0x80*njRandom());
        p.col[i].argb.g = (Uint8)(0x80*njRandom());
        p.col[i++].argb.b = (Uint8)(0x80*njRandom());
      } while(i < TRI_NUM*3);
      njDrawTriangle3D(&p,TRI_NUM, 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.

njDrawTriangle3D

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999