RE: rebuilding a scene graph

New Message Reply Date view Thread view Subject view Author view

From: Dirk Scheffter (scheff++at++iff.fhg.de)
Date: 10/06/2001 04:07:37


Hello Jason,

have worked with fluxes a short time ago and want to give some hints...

Don't worry, you can change all attributes of a geoset completely, if it
is fluxed.

In my app I create all changable geosets with no primitives, no attribute
arrays and so on. Later I fill in attribute arrays, change its sizes on
the fly and so on. No problem!

And so it works:

1st: creation:
- We need a callback for flux initialization:

// ***** CbFluxInitGSet *****
// called by flux buffer to init proper default geosets.
// Geosets are created empty to be filled later with specific data.
int CbFluxInitPfGSet(
  pfFluxMemory *pPfFluxMem) // used flux memory
{
  // the intro is weird but in compliance with Performer samples
  if (!pPfFluxMem) return pfFluxedGSetInit(pPfFluxMem);

  pfFluxedGSetInit(pPfFluxMem);

  // get geoset for the current process/frame
  pfGeoSet *pPfGSet = (pfGeoSet*)pPfFluxMem->getData();

  // from now things go like usual
  pPfGSet->setPrimType(PFGS_POINTS);
  pPfGSet->setNumPrims(0);
  pPfGSet->setPrimLengths(0);
  pPfGSet->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, 0, 0);
  pPfGSet->setAttr(PFGS_NORMAL3, PFGS_OFF, 0, 0);
  pPfGSet->setAttr(PFGS_COLOR4, PFGS_OFF, 0, 0);
  pPfGSet->setAttr(PFGS_TEXCOORD2, PFGS_OFF, 0, 0);
  pPfGSet->setGState(pPfGState); // a global geostate
  pPfGSet->setBound(0, PFBOUND_DYNAMIC);
  pPfGSet->setIsectMask(PFIS_SET_PICK, PFTRAV_SELF | PFTRAV_IS_UNCACHE,
    PF_SET);

  return 0;
}

- now we can use it:
...
pfFlux *pPfFluxGSet = new pfFlux(CbFluxInitPfGSet,
  PFFLUX_DEFAULT_NUM_BUFFERS);

pfGeode *pPfGeode = new pfGeode;
pPfGeode->addGSet((pfGeoSet*)pPfFluxGSet->getCurData());
...

2nd: change a geoset
...
  // get geosets
  pfGeoSet *pPfGSet = (pfGeoSet*)pPfFluxGSet->getWritableData();
...
/*
Do whatever you want with the geoset.
You can even free attribute arrays, alloc new ones and set it.
The only fact you have to consider is that the geoset must be consistent
at the end.
Remember: Strictly speaking, due to fluxing you get multiple geosets.
Each should have its own attribute arrays.
Each should be defined here completely.
*/
...
  // update bounding box (Important!)
  pPfGSet->setBound(0, PFBOUND_DYNAMIC);

  // swap geoset/flux buffers
  pPfFluxGSet->writeComplete();

  // workaround due to geode bug (Important for correct isect!)
  pPfGeode->setBound(0, PFBOUND_DYNAMIC);
  // This is only necessary due to fluxed geosets...
...

To make usage convinient you should pack all necessary stuff in a
suitable class as I did.

pPfFlux and pPfGeode should become class members, pPfGSet need not.

I hope this helps. If any additional questions occur ask me...

Greetings and have a nice weekend,
Dirk.

-----------------------------------------------------------
Dipl.-Inf. Dirk Scheffter scheff++at++iff.fhg.de
Fraunhofer IFF fon: +49 (0) 391/40 90-854
Sandtorstr. 22 fax: +49 (0) 391/40 90-870
D-39106 Magdeburg http://www2.iff.fhg.de/~scheff
Germany
-----------------------------------------------------------


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Oct 06 2001 - 04:06:02 PDT

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