Re: Billboards and fluxed gsets

New Message Reply Date view Thread view Subject view Author view

From: Volley, Axel (AXEL.VOLLEY++at++ca.com)
Date: 07/31/2000 18:32:14


Sorry, attached the wrong file.

Axel Volley wrote:
>
> Yair Kurzion wrote:
> >
> > Hello Axel !
> >
> > pfBillboard does not support fluxed geosets.
>
> I guess there is a difference between a "fluxed gset" and a pfGeoSet, that I
> convert into flux-data ?
> Attached is a simple performer-app based on "simple.C" from
> "/usr/share/Performer/src/pguide/libpf/C++/". If you define GSETFLUX, than it
> compiles the version, which "fluxes" the whole pfGeoSet, otherwise it only
> fluxes the color-attributes. It crashes in both cases on an O2 (in
> "pfBillboard::pf_draw") but not on an Onyx2.
>
> -- Axel
>
> >
> > The ``working'' version that you observed is probably drawing the same Fluxed
> > copy of the geoset over and over. It gets written over as you modify the GeoSet
> > so it isn't MP-safe. We plan to address this after the 2.4 release.
> >
> > You should be able to use a pfFlux for color attributes on a non-fluxed geoset.
> > If this crashes on O2, please send me a short sample code demonstrating the
> > crash.
> >
> > -yair
> >
> > >
> > > I have a pfBillboard with one pfGeoSet attached. Because I want to modify the
> > > color of the GeoSet I can either flux the color attributes of the pfGeoSet or I
> > > can flux the whole pfGeoSet ( I am not using pfFluxedGSetInit, because the
> > > length of the attributes lists doesn't change).
> > > In both cases it crashes on an O2 but runs fine on an Onyx2. Fluxing a pfGeoSet
> > > in the described ways works fine as long it is not attached to a pfBillboard. I
> > > tested it with Performer 2.2.7 and 2.2.8.
> > >
> > > Axel W. Volley ~ Viewpoint Visualization - A CA Company
> > > ++1-972-960-2301 x227 FAX ++1-972-960-9049
> > > mailto:axel.volley++at++viewpoint.com
> > > -----------------------------------------------------------------------
> > > List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> > > Submissions: info-performer++at++sgi.com
> > > Admin. requests: info-performer-request++at++sgi.com
> > >
> >
> > --
> > \_________ \_____ \__ \__ \_____ Yair Kurzion
> > \_________ \_____ \__ \__ \_____ yair++at++sgi.com
> > \__ \__ \____\__ \__ http://reality.sgi.com/yair
> > \__ \__ \__ Work: (650) 933-6502
> > \__ \__ \__ Home: (408) 226-9771
> > \__ \__ \__
>
> --
> Axel W. Volley ~ MultiGen-Paradigm - A CA Company
> ++1-972-960-2301 x227 FAX ++1-972-960-9049
> mailto:axel.volley++at++ca.com
>
> --------------------------------------------------------------------------------
> //
> // Copyright 1995, Silicon Graphics, Inc.
> // ALL RIGHTS RESERVED
> //
> // UNPUBLISHED -- Rights reserved under the copyright laws of the United
> // States. Use of a copyright notice is precautionary only and does not
> // imply publication or disclosure.
> //
> // U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
> // Use, duplication or disclosure by the Government is subject to restrictions
> // as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
> // in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
> // in similar or successor clauses in the FAR, or the DOD or NASA FAR
> // Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
> // 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
> //
> // Permission to use, copy, modify, distribute, and sell this software
> // and its documentation for any purpose is hereby granted without
> // fee, provided that (i) the above copyright notices and this
> // permission notice appear in all copies of the software and related
> // documentation, and (ii) the name of Silicon Graphics may not be
> // used in any advertising or publicity relating to the software
> // without the specific, prior written permission of Silicon Graphics.
> //
> // THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
> // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
> // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
> //
> // IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
> // INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
> // DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
> // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
> // THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
> // OR PERFORMANCE OF THIS SOFTWARE.
> //
> //
> // simpleC.C: simple Performer program for programmer's guide
> //
> // $Revision: 1.10 $
> // $Date: 1995/11/22 14:35:21 $
> //
>
> #include <stdlib.h>
>
> #include <Performer/pf/pfChannel.h>
> #include <Performer/pf/pfLightSource.h>
> #include <Performer/pf/pfNode.h>
> #include <Performer/pf/pfScene.h>
> #include <Performer/pf/pfBillboard.h>
>
> #include <Performer/pfutil.h>
> #include <Performer/pfdu.h>
>
> static bool billboard = true;
>
> // if defined the whole geoset gets fluxed, otherwise only the color-attributes.
> /*
> #define GSETFLUX 1 */
>
> int
> main (int argc, char *argv[])
> {
> float t = 0.0f;
> int i;
>
>
> // Initialize Performer
> pfInit();
>
> // no billboard
> if (argc > 1) {
> billboard = false;
> // Load all loader DSO's before pfConfig() forks
> pfdInitConverter(argv[1]);
> }
>
> // Use default multiprocessing mode based on number of
> // processors.
> //
> pfMultiprocess( PFMP_APPCULLDRAW );
>
> // initiate multi-processing mode set in pfMultiprocess call
> // FORKs for Performer processes, CULL and DRAW, etc. happen here.
> //
> pfConfig();
>
> // Append to Performer search path, PFPATH, files in
> // /usr/share/Performer/data */
> pfFilePath(".:/usr/share/Performer/data");
>
> // some declarations
> pfNode *p_root = NULL;
> pfBillboard* p_pos = NULL;
> int num_verts = 4;
> pfVec3* p_vtx_buf;
> #ifdef GSETFLUX
> pfVec4* p_clr_buf;
> #else
> pfFlux* p_clr_buf;
> #endif
> pfVec3* tmp_vtx;
> pfVec4* tmp_clr;
> pfFlux* p_fluxgset;
> ushort *index;
>
> // create a billboard by hand
> if (billboard) {
> void *arena = pfGetSharedArena();
> // create a billboard
> p_pos = new pfBillboard;
> p_pos->setName("pos");
> p_pos->setAxis(pfVec3(0.0f, 0.0f, 1.0f));
> p_pos->setMode(PFBB_ROT, PFBB_POINT_ROT_WORLD);
> // make them visible everywhere
> //p_pos->setTravFuncs(PFTRAV_DRAW, preDraw, postDraw);
>
> /// geometry
> int *lengths = (int*)pfMalloc(3*sizeof(int), arena);
> lengths[0]=num_verts;
> pfVec2 *p_tcoords = (pfVec2 *)pfMalloc( sizeof(pfVec2) * num_verts, arena );
> p_tcoords[0].set(0.0f, 0.0f);
> p_tcoords[1].set(1.0f, 0.0f);
> p_tcoords[2].set(0.0f, 1.0f);
> p_tcoords[3].set(1.0f, 1.0f);
>
>
> p_vtx_buf = (pfVec3 *)pfMalloc(num_verts * sizeof(pfVec3));
> #ifdef GSETFLUX
> p_clr_buf = (pfVec4 *)pfMalloc(num_verts * sizeof(pfVec4));
> #else
> p_clr_buf = new(arena) pfFlux(sizeof(pfVec4) * num_verts,
> PFFLUX_DEFAULT_NUM_BUFFERS);
> #endif
>
> tmp_vtx= p_vtx_buf;
> #ifdef GSETFLUX
> tmp_clr= p_clr_buf;
> #else
> tmp_clr= (pfVec4 *) p_clr_buf->getCurData();
> #endif
>
> #define SIZE 200
> tmp_vtx[0][0] = -SIZE/2.0;
> tmp_vtx[0][1] = 0.0;
> tmp_vtx[0][2] = -SIZE/2.0;
>
> tmp_vtx[1][0]= SIZE/2.0;
> tmp_vtx[1][1]= 0.0;
> tmp_vtx[1][2]= -SIZE/2.0;
>
> tmp_vtx[2][0]= -SIZE/2.0;
> tmp_vtx[2][1]= 0.0;
> tmp_vtx[2][2]= SIZE/2.0;
>
> tmp_vtx[3][0]= SIZE/2.0;
> tmp_vtx[3][1]= 0.0;
> tmp_vtx[3][2]= SIZE/2.0;
>
> for (i=0;i<num_verts;i++) {
> tmp_clr[i][0]=1.0; /* r */
> tmp_clr[i][1]=1.0; /* g */
> tmp_clr[i][2]=1.0; /* b */
> tmp_clr[i][3]=1.0; /* a */
> }
>
> // setup the geoset
> pfGeoSet* p_gset = new(arena) pfGeoSet;
> p_gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX,
> (void*)p_vtx_buf, 0);
> p_gset->setAttr(PFGS_TEXCOORD2, PFGS_PER_VERTEX, p_tcoords, 0);
> p_gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX,
> (void*)p_clr_buf, 0);
> //p_gset->setGState(p_gstate);
> p_gset->setPrimType(PFGS_TRISTRIPS);
> p_gset->setNumPrims(1);
> p_gset->setPrimLengths(lengths);
>
> #ifdef GSETFLUX
> // flux the geoset
> p_fluxgset = new(arena) pfFlux(sizeof(*p_gset),
> PFFLUX_DEFAULT_NUM_BUFFERS );
> printf("(**) Init flux gset-data\n");
> p_fluxgset->initData(p_gset);
> #else
> printf("(**) Init flux color-data\n");
> p_clr_buf->initData(p_clr_buf->getCurData());
> #endif
>
> // add it to the billboard
> p_pos->insertGSet(0, p_gset);
> p_root = (pfNode *)p_pos;
> }
> else if (billboard == false) {
> // load
> p_root = pfdLoadFile(argv[1]);
> if (p_root == NULL) {
> exit(-1);
> }
> }
>
> // Attach loaded file to a new pfScene
> pfScene *scene = new pfScene;
> scene->addChild(p_root);
>
>
> // Configure and open GL window
> pfPipe *p = pfGetPipe(0);
> pfPipeWindow *pw = new pfPipeWindow(p);
> pw->setWinType(PFPWIN_TYPE_X);
> pw->setName("IRIS Performer");
> pw->setOriginSize(0,0,500,500);
> pw->open();
>
> // Create and configure a pfChannel.
> pfChannel *chan = new pfChannel(p);
> chan->setScene(scene);
> chan->setFOV(45.0f, 0.0f);
>
>
> // determine extent of scene's geometry
> pfSphere bsphere;
> p_root->getBound(&bsphere);
> chan->setNearFar(1.0f, 10.0f * bsphere.radius);
>
>
> // Create a pfLightSource and attach it to scene
> scene->addChild(new pfLightSource);
>
> #if 0
> FILE* file = fopen ("scene.out","w");
> pfPrint(scene, PFTRAV_SELF | PFTRAV_DESCEND,
> PFPRINT_VB_INFO, file);
> fclose(file);
> #endif
>
> // Simulate for twenty seconds.
> while (t < 20.0f)
> {
> pfCoord view;
> float s, c;
>
> // Go to sleep until next frame time.
> pfSync();
>
> // Initiate cull/draw for this frame.
> pfFrame();
>
> // Compute new view position.
> t = pfGetTime();
> pfSinCos(45.0f*t, &s, &c);
> view.hpr.set(45.0f*t, -10.0f, 0);
> view.xyz.set(2.0f * bsphere.radius * s,
> -2.0f * bsphere.radius *c,
> 0.5f * bsphere.radius);
> chan->setView(view.xyz, view.hpr);
>
> if (billboard) {
> // get a pointer to the billboard's color array
> #ifdef GSETFLUX
> pfGeoSet* p_tmpgset = (pfGeoSet *)p_fluxgset->getWritableData();
> p_tmpgset->getAttrLists(PFGS_COLOR4, (void**)&tmp_clr, &index);
> #else
> pfVec4* tmp_clr = (pfVec4 *)p_clr_buf->getWritableData();
> #endif
> for (int i = 0; i < num_verts; i++) {
> // make it "more" red
> tmp_clr[i][1] -= 0.002;
> tmp_clr[i][2] -= 0.002;
> }
> // end of writing
> p_fluxgset->writeComplete();
> }
> }
>
> // Terminate parallel processes and exit
> pfExit();
> return 0;
> }

-- 
Axel W. Volley ~ MultiGen-Paradigm - A CA Company
++1-972-960-2301 x227 FAX ++1-972-960-9049
mailto:axel.volley++at++ca.com

// // Copyright 1995, Silicon Graphics, Inc. // ALL RIGHTS RESERVED // // UNPUBLISHED -- Rights reserved under the copyright laws of the United // States. Use of a copyright notice is precautionary only and does not // imply publication or disclosure. // // U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: // Use, duplication or disclosure by the Government is subject to restrictions // as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights // in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or // in similar or successor clauses in the FAR, or the DOD or NASA FAR // Supplement. Contractor/manufacturer is Silicon Graphics, Inc., // 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. // // Permission to use, copy, modify, distribute, and sell this software // and its documentation for any purpose is hereby granted without // fee, provided that (i) the above copyright notices and this // permission notice appear in all copies of the software and related // documentation, and (ii) the name of Silicon Graphics may not be // used in any advertising or publicity relating to the software // without the specific, prior written permission of Silicon Graphics. // // THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. // // IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, // INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY // DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY // THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE // OR PERFORMANCE OF THIS SOFTWARE. // // // simpleC.C: simple Performer program for programmer's guide // // $Revision: 1.10 $ // $Date: 1995/11/22 14:35:21 $ //

#include <stdlib.h>

#include <Performer/pf/pfChannel.h> #include <Performer/pf/pfLightSource.h> #include <Performer/pf/pfNode.h> #include <Performer/pf/pfScene.h> #include <Performer/pf/pfBillboard.h>

#include <Performer/pfutil.h> #include <Performer/pfdu.h>

static bool billboard = true;

// if defined the whole geoset gets fluxed, otherwise only the color-attributes. /* #define GSETFLUX 1 */

int main (int argc, char *argv[]) { float t = 0.0f; int i;

// Initialize Performer pfInit(); // no billboard if (argc > 1) { billboard = false; // Load all loader DSO's before pfConfig() forks pfdInitConverter(argv[1]); }

// Use default multiprocessing mode based on number of // processors. // pfMultiprocess( PFMP_APPCULLDRAW ); // initiate multi-processing mode set in pfMultiprocess call // FORKs for Performer processes, CULL and DRAW, etc. happen here. // pfConfig(); // Append to Performer search path, PFPATH, files in // /usr/share/Performer/data */ pfFilePath(".:/usr/share/Performer/data");

// some declarations pfNode *p_root = NULL; pfBillboard* p_pos = NULL; int num_verts = 4; pfVec3* p_vtx_buf; #ifdef GSETFLUX pfVec4* p_clr_buf; #else pfFlux* p_clr_buf; #endif pfVec3* tmp_vtx; pfVec4* tmp_clr; pfFlux* p_fluxgset; ushort *index;

// create a billboard by hand if (billboard) { void *arena = pfGetSharedArena(); // create a billboard p_pos = new pfBillboard; p_pos->setName("pos"); p_pos->setAxis(pfVec3(0.0f, 0.0f, 1.0f)); p_pos->setMode(PFBB_ROT, PFBB_POINT_ROT_WORLD); // make them visible everywhere //p_pos->setTravFuncs(PFTRAV_DRAW, preDraw, postDraw);

/// geometry int *lengths = (int*)pfMalloc(3*sizeof(int), arena); lengths[0]=num_verts; pfVec2 *p_tcoords = (pfVec2 *)pfMalloc( sizeof(pfVec2) * num_verts, arena ); p_tcoords[0].set(0.0f, 0.0f); p_tcoords[1].set(1.0f, 0.0f); p_tcoords[2].set(0.0f, 1.0f); p_tcoords[3].set(1.0f, 1.0f);

p_vtx_buf = (pfVec3 *)pfMalloc(num_verts * sizeof(pfVec3)); #ifdef GSETFLUX p_clr_buf = (pfVec4 *)pfMalloc(num_verts * sizeof(pfVec4)); #else p_clr_buf = new(arena) pfFlux(sizeof(pfVec4) * num_verts, PFFLUX_DEFAULT_NUM_BUFFERS); #endif

tmp_vtx= p_vtx_buf; #ifdef GSETFLUX tmp_clr= p_clr_buf; #else tmp_clr= (pfVec4 *) p_clr_buf->getCurData(); #endif

#define SIZE 200 tmp_vtx[0][0] = -SIZE/2.0; tmp_vtx[0][1] = 0.0; tmp_vtx[0][2] = -SIZE/2.0;

tmp_vtx[1][0]= SIZE/2.0; tmp_vtx[1][1]= 0.0; tmp_vtx[1][2]= -SIZE/2.0;

tmp_vtx[2][0]= -SIZE/2.0; tmp_vtx[2][1]= 0.0; tmp_vtx[2][2]= SIZE/2.0;

tmp_vtx[3][0]= SIZE/2.0; tmp_vtx[3][1]= 0.0; tmp_vtx[3][2]= SIZE/2.0;

for (i=0;i<num_verts;i++) { tmp_clr[i][0]=1.0; /* r */ tmp_clr[i][1]=1.0; /* g */ tmp_clr[i][2]=1.0; /* b */ tmp_clr[i][3]=1.0; /* a */ }

// setup the geoset pfGeoSet* p_gset = new(arena) pfGeoSet; p_gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, (void*)p_vtx_buf, 0); p_gset->setAttr(PFGS_TEXCOORD2, PFGS_PER_VERTEX, p_tcoords, 0); p_gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, (void*)p_clr_buf, 0); //p_gset->setGState(p_gstate); p_gset->setPrimType(PFGS_TRISTRIPS); p_gset->setNumPrims(1); p_gset->setPrimLengths(lengths);

#ifdef GSETFLUX // flux the geoset p_fluxgset = new(arena) pfFlux(sizeof(*p_gset), PFFLUX_DEFAULT_NUM_BUFFERS ); printf("(**) Init flux gset-data\n"); p_fluxgset->initData(p_gset); #else printf("(**) Init flux color-data\n"); p_clr_buf->initData(p_clr_buf->getCurData()); #endif

// add it to the billboard p_pos->insertGSet(0, p_gset); p_root = (pfNode *)p_pos; } else if (billboard == false) { // load p_root = pfdLoadFile(argv[1]); if (p_root == NULL) { exit(-1); } }

// Attach loaded file to a new pfScene pfScene *scene = new pfScene; scene->addChild(p_root);

// Configure and open GL window pfPipe *p = pfGetPipe(0); pfPipeWindow *pw = new pfPipeWindow(p); pw->setWinType(PFPWIN_TYPE_X); pw->setName("IRIS Performer"); pw->setOriginSize(0,0,500,500); pw->open(); // Create and configure a pfChannel. pfChannel *chan = new pfChannel(p); chan->setScene(scene); chan->setFOV(45.0f, 0.0f); // determine extent of scene's geometry pfSphere bsphere; p_root->getBound(&bsphere); chan->setNearFar(1.0f, 10.0f * bsphere.radius);

// Create a pfLightSource and attach it to scene scene->addChild(new pfLightSource);

#if 0 FILE* file = fopen ("scene.out","w"); pfPrint(scene, PFTRAV_SELF | PFTRAV_DESCEND, PFPRINT_VB_INFO, file); fclose(file); #endif

// Simulate for twenty seconds. while (t < 20.0f) { pfCoord view; float s, c; // Go to sleep until next frame time. pfSync(); // Initiate cull/draw for this frame. pfFrame(); // Compute new view position. t = pfGetTime(); pfSinCos(45.0f*t, &s, &c); view.hpr.set(45.0f*t, -10.0f, 0); view.xyz.set(2.0f * bsphere.radius * s, -2.0f * bsphere.radius *c, 0.5f * bsphere.radius); chan->setView(view.xyz, view.hpr);

if (billboard) { // get a pointer to the billboard's color array #ifdef GSETFLUX pfGeoSet* p_tmpgset = (pfGeoSet *)p_fluxgset->getWritableData(); p_tmpgset->getAttrLists(PFGS_COLOR4, (void**)&tmp_clr, &index); #else pfVec4* tmp_clr = (pfVec4 *)p_clr_buf->getWritableData(); #endif for (int i = 0; i < num_verts; i++) { // make it "more" red tmp_clr[i][1] -= 0.002; tmp_clr[i][2] -= 0.002; }

#ifdef GSETFLUX // end of writing p_fluxgset->writeComplete(); #else p_clr_buf->writeComplete(); #endif

} } // Terminate parallel processes and exit pfExit(); return 0; }


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 18:02:26 PDT

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