[info-performer] Question pertaining to pfFlux and pfGeoBuilder

New Message Reply Date view Thread view Subject view Author view

From: J. Andreas Baerentzen (jab++at++imm.dtu.dk)
Date: 04/07/2003 07:45:55


Hi,

I am trying to write a program which polygonizes an implicit surface,
producing a pfGeoSet from the polygons.

For each frame I change the implicit surface and update the pfGeoSet using a
pfdGeoBuilder. The new pfGeoSet is added to the appropriate geode and the old
geoset is deleted using pfDelete.

This crashes.

I assume it crashes because it is dangerous to modify geometry unless the
pfFlux functionality is used to make things safe?

I assume again that one needs to use a pfFlux to get the memory for the
pfGeoSet?!

There are some pfFlux examples, (e.g. pfluxed_gset.C) but I am still not quite
sure how to use the pfFlux memory in concert with a pfdGeoBuilder. Mostly
this is because the examples allocate memory for the fluxed gset and then
change it. Since I am using a builder, I simply get a list of gsets using
pfdBuildGSets(bldr) ... so then what ?! Do I copy to a fluxed pfGeoSet?!
Using pfCopy?!

If anyone has an example illustrating how to use fluxes with geobuilder, I'd
be most grateful if it could be posted to this list or sent to jab 'at'
imm.dtu.dk

Thanks!

Andreas

ps: I include the code for reference

Here I create the pfGeoSet
------------------------------------
pfGeoSet* create()
{
        pfVec3* vertices = 0;
                vector<ushort> indices(0);
                
                Morph t;
                Polygonizer pol(&t, 0.2, 15);
                pol.march(NOTET, 0.,0.,0.);

                // Create primitive, add pointer to vertices.
                pfdPrim *prim = new pfdPrim;
                prim->flags = 0;
                prim->coordList= reinterpret_cast<pfVec3*>(&pol.get_vertex(0));
                prim->normList = reinterpret_cast<pfVec3*>(&pol.get_normal(0));
                prim->nbind = PFGS_PER_VERTEX;
                prim->cbind = PFGS_OFF;
                for(int t=0 ; t < PF_MAX_TEXTURES ; ++t)
                        prim->tbind[t] = PFGS_OFF;

                // Create builder
                pfdGeoBuilder *bldr = pfdNewGeoBldr();
        
                for(int i=0;i<pol.no_triangles();++i)
                        {
                                TRIANGLE t = pol.get_triangle(i);
                                prim->icoords[0] = t.v0;
                                prim->icoords[1] = t.v1;
                                prim->icoords[2] = t.v2;
                                prim->inorms[0] = t.v0;
                                prim->inorms[1] = t.v1;
                                prim->inorms[2] = t.v2;
                                pfdAddIndexedTri(bldr, prim);
                        }
                // generate optimized triangle mesh GeoSet
                const pfList* gsetList = pfdBuildGSets(bldr);

                pfGeoSet* gs = static_cast<pfGeoSet*>(gsetList->get(0));
                // release pfdGeoBuilder and pfdGeom storage
                 pfdDelGeoBldr(bldr);
                pfDelete(prim);

                return gs;
}

Here is the loop:
------------------------
        while (true)
                {
                        pfuGetMouse(&mouse);
                        pfuGetEvents(&events);
                        
                        handleEvents(events);
                        if(model->getNumGSets()>0)
                                {
                                         pfGeoSet *gset = model->getGSet(0);
                                         model->removeGSet(gset);
                                         pfDelete(gset);
                                }
                        pfGeoSet* gset = create();
                        model->addGSet(gset);
                        xformer->update();
                        pfSync();
                        pfFrame();

                }


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Apr 07 2003 - 07:48:20 PDT

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