*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) |
-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.
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);