njDrawTriangle3D Japanese
<-|INDEX|--
Draws triangles in 3D space.

FORMAT

#include <Ninja.h>
void njDrawTriangle3D(*p, n, attr)
NJS_POINT3COL *p
Int n
Uint32 attr

PARAMETERS

*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 VALUE

None

FUNCTION


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);
Since this function draws in 3D, the view, screen, and matrix stack settings must be made before using it.

NOTES


RELATED TOPICS


njDrawTriangle3D
<-|INDEX|--

Copyright SEGA ENTERPRISES, LTD., 1997