Function:ns2vf3na

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:40, 29 August 2011
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 1: Line 1:
==ns2vf3na== ==ns2vf3na==
-3-vertex facet with coloured vertices, normals and alpha given.+Transparent 3-vertex facet with coloured vertices, normals and alpha given.
==Prototype== ==Prototype==

Current revision

ns2vf3na

Transparent 3-vertex facet with coloured vertices, normals and alpha given.

Prototype

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

Description

Function for drawing a 3-vertex facet with coloured vertices, with normals, and a single alpha transparency value for the facet. The vertices are given by the array P, normals are in the array N, and the RGB colours for vertices are in col. Transparency parameter trans is one of 'o' (opaque), 't' (addition blend - never gets dimmer) or 's' (standard blend, can get dimmer), and the alpha value is in the range [0,1].

See Also

ns2vf3 3-vertex facet with single colour and automatic normals.
ns2vf3n 3-vertex facet with single colour and normals given.
ns2vf3c 3-vertex facet with coloured vertices and autmoatic normals.
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 */
   XYZ normal[3];                               /* 3 vertices */
   COLOUR col;                                  /* Polygon colour */
   char trans = 't';                            /* Transparency type */
   float alpha = 0.7;                           /* Alpha channel value */
   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;
      normal[i].x = drand48()*2.0 - 1.0;        /* Random normal for facet */
      normal[i].y = drand48()*2.0 - 1.0;
      normal[i].z = drand48()*2.0 - 1.0;
   }
   col.r = drand48();                           /* Random colour for polygon*/
   col.g = drand48();
   col.b = drand48();
   ns2vf3na(vertex, normal, col, trans, alpha);
                        /* Draw polygon with specified vertices, normals, */
                        /*  colour and single alpha channel */

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

   return 1;
}

Back to S2PLOT function list.


Personal tools