| njDrawTriangle3D | Japanese |
|---|---|
<-|INDEX|-- | |
| Draws triangles in 3D space. | |
#include <Ninja.h> void njDrawTriangle3D(*p, n, attr) NJS_POINT3COL *p Int n Uint32 attr
| NJD_DRAW_NORMAL | Normal drawing. |
| NJD_DRAW_CONNECTED | Draws connected triangles. |
| NJD_DRAW_FAN | Draws triangles radially. |
| NJD_FILL | Drawing with filled interior. |
| NJD_TRANSPARENT | Transparent drawing. |
| NJD_USE_TEXTURE | Drawing with texture. |
#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. |
| njDrawTriangle3D | <-|INDEX|-- |
|---|