Function:ds2vbbpr

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:54, 7 January 2009
S2plot admin (Talk | contribs)

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

Line 3: Line 3:
==Prototype== ==Prototype==
- 
<code><pre> <code><pre>
void ds2vbbpr(XYZ iP, XYZ offset, float aspect, float isize, void ds2vbbpr(XYZ iP, XYZ offset, float aspect, float isize,
Line 10: Line 9:
==Description== ==Description==
- Billboard with aspect ratio, offset in screen coords, and rotation of the texture about the view direction.+Billboard with aspect ratio, offset in screen coords, and rotation of the texture about the view direction.
==See Also== ==See Also==
<table> <table>
<tr><td>[[Function:ds2vbbp | ds2vbbp]]</td><td>Billboard with aspect ratio - vector input.</td></tr> <tr><td>[[Function:ds2vbbp | ds2vbbp]]</td><td>Billboard with aspect ratio - vector input.</td></tr>
-<tr><td>[[Function:ds2bbset | ds2bbset ]]</td><td>Draw a set of billboards. </td></tr> 
<tr><td>[[Function:ds2bb | ds2bb ]]</td><td>Draw a (dynamic) billboard: a textured facet that always faces the camera. </td></tr> <tr><td>[[Function:ds2bb | ds2bb ]]</td><td>Draw a (dynamic) billboard: a textured facet that always faces the camera. </td></tr>
<tr><td>[[Function:ds2vbb | ds2vbb ]]</td><td>Draw a (dynamic) billboard: a textured facet that always faces the camera - vector input </td></tr> <tr><td>[[Function:ds2vbb | ds2vbb ]]</td><td>Draw a (dynamic) billboard: a textured facet that always faces the camera - vector input </td></tr>
Line 27: Line 25:
<code><pre> <code><pre>
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +#include "s2plot.h"
 +
 +unsigned int tid;
 +
 +void cb(double *t, int *kc)
 +{
 + XYZ xyz = {0.0, 0.3, 0.4}; /* Location */
 + float isize = 0.05; /* Texture scale */
 + XYZ offset = { 0.2, 0.1, 0.0}; /* Texture offset to reference point */
 + float aspect = 2.2; /* Aspect ratio */
 + COLOUR col = { 1.0, 1.0, 0.0 }; /* Yellow */
 + float alpha = 0.9; /* Alpha channel */
 + char trans = 's'; /* Transparency */
 + float pangle = 45.0;
 +
 + ds2vbbpr(xyz, offset, aspect, isize, pangle, col, tid, alpha, trans);
 +
 + /* Billboard with aspect ratio and offset */
 + ns2vthpoint(xyz, col, 3); /* Plot texture reference point */
 +
 +}
 +
 +int main(int argc, char *argv[])
 +{
 + int width = 16, height = 16; /* Dimensions of texture */
 + int i, j; /* Loop variables */
 + int idx; /* Index into texture array */
 + unsigned char *tex; /* Array of texture values */
 +
 + srand48((long)time(NULL)); /* Seed random numbers */
 + s2opend("/?",argc,argv); /* Open the display */
 + s2svp(-1.0,1.0, -1.0,1.0, -1.0,1.0); /* Set the viewport coords */
 + s2swin(-1.0,1.0, -1.0,1.0, -1.0,1.0); /* Set the window coordinates */
 + s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0); /* Draw a bounding box */
 +
 + tid = ss2ct(width, height); /* Create a new texture */
 + tex = ss2gt(tid, &width, &height); /* Get the texture */
 +
 + for (j=0;j<height;j++) {
 + for (i=0;i<width;i++) {
 + idx = (j*width + i) * 4; /* Stored as (r,g,b,alpha) */
 + tex[idx ] = 127*drand48()+128; /* Randomish red */
 + tex[idx+1] = 0; /* Green */
 + tex[idx+2] = 0; /* Blue */
 + /* Do nothing to alpha */
 + }
 + }
 + ss2pt(tid); /* Push texture for usage */
 +
 + cs2scb(&cb); /* Install a callback */
 +
 + s2show(1); /* Open the s2plot window */
 +
 + return 1;
 +}
</pre></code> </pre></code>

Current revision

ds2vbbpr

Billboard with aspect ratio, offset in screen coords, and rotation of texture - vector input.

Prototype

void ds2vbbpr(XYZ iP, XYZ offset, float aspect, float isize,
	      float ipangle, COLOUR iC, unsigned int itexid, float alpha, char trans);

Description

Billboard with aspect ratio, offset in screen coords, and rotation of the texture about the view direction.

See Also

ds2vbbpBillboard with aspect ratio - vector input.
ds2bb Draw a (dynamic) billboard: a textured facet that always faces the camera.
ds2vbb Draw a (dynamic) billboard: a textured facet that always faces the camera - vector input
ds2vbbr Draw a (dynamic) billboard texture with specified rotation.
ds2tb Draw text that always faces the camera
ds2vtb Draw text that always faces the camera - vector input
ss2ct Create a texture with specified width and height

Code Example

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"

unsigned int tid;

void cb(double *t, int *kc)
{
   XYZ xyz = {0.0, 0.3, 0.4};           /* Location */
   float isize = 0.05;                  /* Texture scale */
   XYZ offset = { 0.2, 0.1, 0.0};       /* Texture offset to reference point */
   float aspect = 2.2;                  /* Aspect ratio */
   COLOUR col = { 1.0, 1.0, 0.0 };      /* Yellow */
   float alpha = 0.9;                   /* Alpha channel */
   char trans = 's';                    /* Transparency */
   float pangle = 45.0;

   ds2vbbpr(xyz, offset, aspect, isize, pangle, col, tid, alpha, trans);

                                /* Billboard with aspect ratio and offset */
   ns2vthpoint(xyz, col, 3);            /* Plot texture reference point */

}

int main(int argc, char *argv[])
{
   int width = 16, height = 16;         /* Dimensions of texture */
   int i, j;                            /* Loop variables */
   int idx;                             /* Index into texture array */
   unsigned char *tex;                          /* Array of texture values */

   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/?",argc,argv);                     /* Open the display */
   s2svp(-1.0,1.0, -1.0,1.0, -1.0,1.0);         /* Set the viewport coords */
   s2swin(-1.0,1.0, -1.0,1.0, -1.0,1.0);        /* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw a bounding box */

   tid = ss2ct(width, height);          /* Create a new texture */
   tex = ss2gt(tid, &width, &height);   /* Get the texture */

   for (j=0;j<height;j++) {
      for (i=0;i<width;i++) {
         idx = (j*width + i) * 4;               /* Stored as (r,g,b,alpha) */
         tex[idx  ] = 127*drand48()+128;        /* Randomish red */
         tex[idx+1] = 0;                        /* Green */
         tex[idx+2] = 0;                        /* Blue */
                                                /* Do nothing to alpha */
      }
   }
   ss2pt(tid);                          /* Push texture for usage */

   cs2scb(&cb);                         /* Install a callback */

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

   return 1;
}

Back to S2PLOT function list.


Personal tools