Re: Billboarding

New Message Reply Date view Thread view Subject view Author view

Hilko Hoffmann (hilko++at++geo.unizh.ch)
Fri, 03 Apr 1998 10:14:19 +0100


Zachi Karni wrote:

> Hi All
>
> I am looking for general information about using billboarding,
> especially for drawing clouds and trees.
>
> Thanks
>
> Zachi Karni zachik++at++elbit.co.il
> Software Engineer
> Elbit Systems LTD +972-4-8315660 Direct
> Haifa +972-4-8315739 Fax
> Israel +972-4-8377184 Home
>
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

Look at this fragment of our loader code:

 --------------------------------------

#include <Performer/pf/pfBillboard.h>

   pfBillboard *aBillboard;
   pfVec3 pos, axis;

   /* initialise
pfBuilder */
   pfdResetBldrGeometry();
   pfdResetBldrState();

   /* allocate
memory */
   void *arena = pfGetSharedArena();

   aGeode = new pfGeode();

   aGeoState = new pfGeoState();

   /* define texture and
geostate */
   /* if texCode is set (>= 0) --> copy
filename */
   if (obj->texCode >= 0) {
       strcpy(geoStateInfo->texName,
rslObjTileInfo->textureList[obj->texCode]);
       geoStateInfo->loadTexture = 1;
   }
   aGeoState = getGeoState(geoStateInfo);
   pfdBldrGState(aGeoState);

   aGeom = pfdNewGeom(4);
   aGeom->nbind = PFGS_PER_PRIM;
   aGeom->cbind = PFGS_PER_PRIM;
   aGeom->tbind = PFGS_PER_VERTEX;
   aGeom->primtype = PFGS_POLYS;

   // Color
   aGeom->colors[0].set(obj->color[0], obj->color[1], obj->color[2],
obj->color[3]);

   // Geometry
   if (obj->numberOfPoly == 0) {
       // billboard structure
       if (obj->shape == 3) {
    // triangle shape
    aGeom->numVerts = 3;
       }
       else {
    // quad shape
    aGeom->numVerts = 4;
       }
       // vertices are always set for quads, tris only take first three
vertices
       v1.set(-0.5f, 0.0f, -0.5f);
       v2.set(0.5f, 0.0f, -0.5f);
       v3.set(0.5f, 0.0f, 0.5f);
       v4.set(-0.5f, 0.0f, 0.5f);
       n1.set(0.0f, -1.0f, 0.0f);
       // scale matrix
       scaleMat.makeScale(obj->scale[0], obj->scale[1], obj->scale[2]);
       // scale
       v1 = v1 * scaleMat;
       v2 = v2 * scaleMat;
       v3 = v3 * scaleMat;
       v4 = v4 * scaleMat;

       // set vertices coordinates
       aGeom->coords[0].set(v1[0], v1[1], v1[2]);
       aGeom->coords[1].set(v2[0], v2[1], v2[2]);
       aGeom->coords[2].set(v3[0], v3[1], v3[2]);
       aGeom->coords[3].set(v4[0], v4[1], v4[2]);
       // set Normals
       aGeom->norms[0].set(n1[0], n1[1], n1[2]);
       // set texture coordinates
       aGeom->texCoords[0].set(obj->texCoord[0], obj->texCoord[2]);
       aGeom->texCoords[1].set(obj->texCoord[1], obj->texCoord[2]);
       aGeom->texCoords[2].set(obj->texCoord[1], obj->texCoord[3]);
       aGeom->texCoords[3].set(obj->texCoord[0], obj->texCoord[3]);

       pfdAddBldrGeom(aGeom, 1);
       pfdDelGeom(aGeom);

       aTmpGeode = (pfGeode *)pfdBuild();

       aBillboard = new pfBillboard();
       aBillboard->addGSet(aTmpGeode->getGSet(0));
       // place billboard;
       pos.set(obj->xyzCoord[0] + obj->translate[0],
               obj->xyzCoord[1] + obj->translate[1],
        obj->xyzCoord[2] + obj->translate[2] + obj->scale[2] * 0.5);
       aBillboard->setPos(0, pos);
       aBillboard->setMode(PFBB_ROT, PFBB_AXIAL_ROT);
       axis.set(0.0f, 0.0f, 1.0f); // billboard spinns around z-axis
       aBillboard->setAxis(axis);
       aGeode = aBillboard;
   }

   return aGeode;

--------------------

For best results use semi transparent rgba textures of vegetation or
clouds

Hope this helps

Hilko

--
****************************************************************
Hilko Hoffmann
Remote Sensing Laboratories;    University of Zurich
Winterthurerstrasse 190; CH-8057 Zurich; Switzerland
Phone: +41 - 1 / 63 56519; FAX:   +41 - 1 / 63 56842
mailto:hilko++at++geo.unizh.ch
http://www.geo.unizh.ch/rsl1/lvg/research/
****************************************************************

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:11 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.