Function:ns2vf3c

From S2PLOT

Jump to: navigation, search

ns2vf3c

3-vertex facet with coloured vertices and autmoatic normals.

Prototype

void ns2vf3c(XYZ *P, COLOUR *col);

Description

Draw a 3-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

ns2vf3 3-vertex facet with single colour and automatic normals.
ns2vf3n 3-vertex facet with single colour and normals given.
ns2vf3nc 3-vertex facet with coloured vertices and normals given.
ns2vf3a 3-vertex facet with transparency
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[3];				/* 3 vertices */
   COLOUR col[3];				/* 3 vertices */
   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 */

   for (i=0;i<3;i++) {
      vertex[i].x = drand48()*2.0 - 1.0;	/* Random corners to facet */
      vertex[i].y = drand48()*2.0 - 1.0;
      vertex[i].z = drand48()*2.0 - 1.0;
      col[i].r = drand48();			/* Random colour for vertex */
      col[i].g = drand48();
      col[i].b = drand48();
   }
   ns2vf3c(vertex, col);				/* Draw 3-vertex facet */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}

Back to S2PLOT function list.


Personal tools