Function:ns2vf3a

From S2PLOT

(Difference between revisions)
Jump to: navigation, search

Current revision

ns2vf3a

3-vertex facet with transparency

Prototype

void ns2vf3(XYZ *P, COLOUR col, char trans, float alpha);

Description

Draw a transparent 3-vertex facet with a single colour. The vertices are given by the array P, normals are calculated automatically, and the RGB colour is col. Transparency is controlled by the alpha channel, with value in the range [0,1] and trans:

  • trans = 'o' opaque vertex;
  • trans = 't' addition blending - never gets dimmer; and
  • trans = 's' standard blending - can get dimmer.


See Also

ns2vf3 3-vertex facet with single colour and automatic normals.
ns2vf3c 3-vertex facet with coloured vertices and autmoatic normals.
ns2vf3n 3-vertex facet with single colour and normals given.
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 vertexA[3];				/* 3 vertices */
   XYZ vertexB[3];				/* 3 vertices */
   COLOUR colA = { 1.0, 1.0, 0.1 };		/* Yellowish */
   COLOUR colB = { 1.0, 0.0, 0.9 };		/* Magentaish */
   char trans = 's';				/* Transparency type */
   float alphaA = 0.3;				/* Alpha channel */
   float alphaB = 0.8;				/* Alpha channel */
   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++) {
      vertexA[i].x = drand48()*2.0 - 1.0;	/* Random corners to facet */
      vertexA[i].y = drand48()*2.0 - 1.0;
      vertexA[i].z = drand48()*2.0 - 1.0;
      vertexB[i].x = drand48()*2.0 - 1.0;	/* Random corners to facet */
      vertexB[i].y = drand48()*2.0 - 1.0;
      vertexB[i].z = drand48()*2.0 - 1.0;
   }
   ns2vf3a(vertexA, colA, trans, alphaA);	/* Draw 3-vertex facet */
   ns2vf3a(vertexB, colB, trans, alphaB);	/* Draw 3-vertex facet */

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

}

Back to S2PLOT function list.


Personal tools