Function:ds2vbbp

From S2PLOT

Jump to: navigation, search

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