More Billboard problems

New Message Reply Date view Thread view Subject view Author view

Prakash Mahesh (prakash++at++DRAWCOMP.COM)
Tue, 17 Nov 1998 16:16:41 -0500


Hello performers,
In additon to my previous posting about Transparency/Billboard problems,
there seems to be pure Billboard problems too. It always works on one
axis only. Attached is a simple loader to show the problem. It loads
three objects, actually the axis-of-rotation are different for the
three, but you can see that it all works on the same axis.

Thanks in advance for any help.

PS : Also attached is a wrl loader (just load a non-existing .wrl file
that loads up the actual problematic billboards)

-- 
  Prakash Mahesh                                     
  prakash++at++drawcomp.com
  	--or--
  prakash++at++openworlds.com

/* *This loader creates three overlapping boxes, each slightly a different size. *Each box's billboard is created with a different axis of rotation, but all *are rotating the exact same way. * *run with perfly and a non-existing "wrl" file: * perfly -W800,800 a.wrl * *To build: CC -n32 -all -shared -check_registry /usr/lib/so_locations -exceptions -D_OWEXCEPTIONS_ -D_OWNOLICENSE_ -set_version sgi4.0.440 badbill2.C -o libpfwrl_ogl.so * */ #include <iostream.h> #include <Performer/pf.h> #include <Performer/pf/pfScene.h>

#include <malloc.h> #include <stdio.h> #include <Performer/pr/pfMaterial.h>

#include <Performer/pf/pfDCS.h> #include <Performer/pf/pfGeode.h> #include <Performer/pf/pfBillboard.h>

pfDCS *topSceneGraph; pfGeode *addBox(float xV, float yV, float zV); pfGeode *addBillboardBox(float xV, float yV, float zV); pfDCS *addDCS(float x, float y, float z);

//the main loader routine extern "C" pfNode *pfdLoadFile_wrl(char *fileName) { fprintf(stderr,"\n\n--------------------DUMMY WRLLOADER-----------------\n"); topSceneGraph = new pfDCS();

//add group pfDCS *dcs2= addDCS(0.,0.,0.); dcs2->addChild(addBillboardBox(10.,2.,.4)); dcs2->addChild(addBillboardBox(11.,1.5,.3)); dcs2->addChild(addBillboardBox(12.,1.,.2)); pfDCS *sceneMatrix = new pfDCS();

sceneMatrix->addChild(dcs2); // topSceneGraph->addChild(sceneMatrix); topSceneGraph->addChild(dcs2); return topSceneGraph; }

//adds a material for the geoset //the turning on transparency is causing problems for billboard void addmat(pfGeoSet *gset){ void *arena = pfGetSharedArena(); pfGeoState *gst = new(arena) pfGeoState; gset->setGState(gst); //fprintf(stderr,"\n\n------------------BOTH\n\n"); pfMaterial *mtl= new pfMaterial; static float c=0.; c+=1.; mtl->setSide(PFMTL_BOTH); mtl->setColor(PFMTL_EMISSION,.4*c,.2,.4); #if 0 //fprintf(stderr,"\n\n------------------BOTH\n\n"); mtl->setColor(PFMTL_DIFFUSE, .2,.2,.2); mtl->setColor(PFMTL_SPECULAR, .2,.2,.2); mtl->setColor(PFMTL_AMBIENT, .2,.2,.2); #endif mtl->setColorMode(PFMTL_BOTH, PFMTL_CMODE_OFF); mtl->setAlpha(1.); mtl->setShininess(0.); gst->setAttr(PFSTATE_FRONTMTL, mtl); gst->setAttr(PFSTATE_BACKMTL, mtl);

gst->setMode(PFSTATE_ENLIGHTING, 1); #if 0 gst->setMode(PFSTATE_ALPHAFUNC, PFAF_GREATER); gst->setVal(PFSTATE_ALPHAREF, .01); #endif #ifdef FAIL gst->setMode(PFSTATE_TRANSPARENCY, PFTR_ON); #endif }

//adds a DCS with translation x,y,z pfDCS * addDCS(float x, float y, float z) { pfDCS *dcs = new pfDCS; pfMatrix TR; TR.makeIdent(); TR.preTrans(x,y,z,TR); dcs->setMat(TR); return dcs; }

//adds a billboarded box pfGeode * addBillboardBox(float xV, float yV, float zV) { pfBillboard *geoDE; void *arena; pfVec3 *normals; pfVec2 *txtCoords; pfVec3 *Coords; ushort *normIndex, *ptIndex, *txtIndex; int i,j; static int count=0; geoDE = new pfBillboard;

if (count==2) geoDE->setAxis(*(new pfVec3(1.,0.,0.))); if (count==1) geoDE->setAxis(*(new pfVec3(0.,1.,0.))); if (count==0) geoDE->setAxis(*(new pfVec3(0.,0.,1.))); fprintf(stderr,"COUNT:%d\n",count); count++; // geoDE->setMode(PFBB_ROT, PFBB_AXIAL_ROT); // geoDE->setMode(PFBB_ROT, PFBB_POINT_ROT_EYE); //geoDE->setMode(PFBB_ROT, PFBB_POINT_ROT_WORLD); arena = pfGetSharedArena(); #if 0 normals = (pfVec3*)pfMalloc(sizeof(pfVec3)*6, arena); normals[0].set( 0.0f, 0.0f, 1.0f); //Front normals[1].set( 0.0f, 0.0f, -1.0f); //Back normals[2].set(-1.0f, 0.0f, 0.0f); //Left normals[3].set( 1.0f, 0.0f, 0.0f); //Right normals[4].set( 0.0f, 1.0f, 0.0f); //Top normals[5].set( 0.0f, -1.0f, 0.0f); //Bottom #endif Coords = (pfVec3*)pfMalloc(sizeof(pfVec3)*8, arena);

float x, y, z; x = xV/2; y = yV/2; z = zV/2; Coords[0].set(-x, -y, z); Coords[1].set( x ,-y, z); Coords[2].set( x, y, z); Coords[3].set(-x, y, z); Coords[4].set(-x, -y, -z); Coords[5].set( x, -y, -z); Coords[6].set( x, y, -z); Coords[7].set(-x, y, -z); #if 0 normIndex = (ushort*)pfMalloc(sizeof(ushort)*24, arena);

j = -1; for (i=0; i<24; i++){ if (i%4 == 0) j++; normIndex[i] = j; } #endif ptIndex = (ushort*)pfMalloc(sizeof(ushort)*24, arena); ptIndex[0] = 0; ptIndex[1] = 1; ptIndex[2] = 2; ptIndex[3] = 3; /* front */ ptIndex[4] = 5; ptIndex[5] = 4; ptIndex[6] = 7; ptIndex[7] = 6; /* left */ ptIndex[8] = 4; ptIndex[9] = 0; ptIndex[10] = 3; ptIndex[11] = 7; /* back */ ptIndex[12]= 1; ptIndex[13] = 5; ptIndex[14] = 6; ptIndex[15] = 2; /* right */ ptIndex[16]= 3; ptIndex[17] = 2; ptIndex[18] = 6; ptIndex[19] = 7; /* top */ ptIndex[20]= 4; ptIndex[21] = 5; ptIndex[22] = 1; ptIndex[23] = 0; /*bottom*/

pfGeoSet *gset; gset = new pfGeoSet; gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, Coords, ptIndex); // gset->setAttr(PFGS_TEXCOORD2, PFGS_PER_VERTEX, txtCoords, txtIndex); // gset->setAttr(PFGS_NORMAL3, PFGS_PER_VERTEX, normals, normIndex); gset->setPrimType(PFGS_QUADS); gset->setNumPrims(6); // gset->setGState(gsStack->top()); geoDE->addGSet(gset);

addmat(gset); return geoDE; }



New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue Nov 17 1998 - 13:26:30 PST

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