Function:ns2vf4c
From S2PLOT
(Difference between revisions)
Revision as of 01:29, 30 October 2007 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
Current revision
ns2vf4c
4-vertex facet with coloured vertices and automatic normals.
Prototype
void ns2vf4c(XYZ *P, COLOUR *col);
Description
Draw a 4-vertex facet with a coloured vertices. The vertices are given by the array P, normals are calculated automatically, and the RGB colours for each vertex are stored in the array col.
See Also
ns2vf4 | 4-vertex facet with single colour and automatic normals. |
ns2vf4n | 4-vertex facet with single colour and normals given. |
ns2vf4nc | 4-vertex facet with coloured vertices and normals given. |
ns2vf4t | Textured 4-vertex facet, scale in [0,1]; trans = 'o' or 't'. |
struct_COLOUR | Data structure for (r,g,b) colour indices. |
struct_XYZ | Data structure for (x,y,z) coordinates. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
int main(int argc, char *argv[])
{
XYZ vertex[4]; /* 4 vertices */
COLOUR col[4]; /* Colours */
int i;
srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/?",argc, argv); /* Open the display */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
vertex[0].x = 0.0; vertex[0].y = 0.0; vertex[0].z = 0.0;
vertex[1].x = 0.5; vertex[1].y = 0.0; vertex[1].z = 0.0;
vertex[2].x = 0.5; vertex[2].y = -0.4; vertex[2].z = 1.0;
vertex[3].x = 0.0; vertex[3].y = -0.4; vertex[3].z = 1.0;
for (i=0;i<4;i++) {
col[i].r = drand48();
col[i].g = drand48();
col[i].b = drand48();
}
ns2vf4c(vertex, col); /* Draw the polygon */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.