Function:ds2vbbp

From S2PLOT

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

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

Line 1: Line 1:
==ds2vbbp== ==ds2vbbp==
-Draw a "billboard" with aspect ratio.+Draw a "billboard" with aspect ratio - vector input.
==Prototype== ==Prototype==
Line 13: Line 13:
==See Also== ==See Also==
 +<table>
 +<tr><td>[[Function:ds2vbbpr | ds2vbbpr]]</td><td>Billboard with aspect ratio, offset in screen coords, and rotation of texture - 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:ds2vbb | ds2vbb ]]</td><td>Draw a (dynamic) billboard: a textured facet that always faces the camera - vector input </td></tr>
 +<tr><td>[[Function:ds2vbbr | ds2vbbr ]]</td><td>Draw a (dynamic) billboard texture with specified rotation.</td></tr>
 +<tr><td>[[Function:ds2tb | ds2tb ]]</td><td>Draw text that always faces the camera </td></tr>
 +<tr><td>[[Function:ds2vtb | ds2vtb ]]</td><td>Draw text that always faces the camera - vector input </td></tr>
 +</table>
==Code Example== ==Code Example==
<code><pre> <code><pre>
-</pre></code>+#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +#include "s2plot.h"
-[[S2PLOT:Function List | Back]] to S2PLOT function list.+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 */
 + ds2vbbp(xyz, offset, aspect, isize, col, tid, alpha, trans);
 + /* Billboard with aspect ratio and offset */
 + ns2vthpoint(xyz, col, 3); /* Plot texture reference point */
-__NOTOC__+ xyz.y = -0.3; /* Change the y value */
-__NOEDITSECTION__+ XYZ str = { 0.0, 0.0, 0.0 }; /* No stretch */
 + ds2vbb(xyz, str, isize, col, tid, alpha, trans); /* Standard billboard */
 + 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 */
-Back to [[Function:Template | template]] page.+ 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>
 + 
 +[[S2PLOT:Function List | Back]] to S2PLOT function list.
 + 
 +__NOTOC__
 +__NOEDITSECTION__

Current revision

ds2vbbp

Draw a "billboard" with aspect ratio - vector input.

Prototype

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

Description

Draw a "billboard" with aspect ratio: width:height instead of stretch, and offset in screen coords (x,y) [offset.z ignored].

See Also

ds2vbbprBillboard with aspect ratio, offset in screen coords, and rotation of texture - vector input.
ds2bbset Draw a set of billboards.
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

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 */

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

   xyz.y = -0.3;                        /* Change the y value */
   XYZ str = { 0.0, 0.0, 0.0 };         /* No stretch */
   ds2vbb(xyz, str, isize, col, tid, alpha, trans); /* Standard billboard */
   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