Spliting geoSets

New Message Reply Date view Thread view Subject view Author view

Allen Bierbaum (allenb++at++icemt.iastate.edu)
Thu, 18 Jul 1996 12:46:52 -0500


I am having some problems in one of my latest programs. I want to write a
routine to take a PFGS_TRIS geoset and split it into multiple geosets of a
maimum defined size and another geoset containing the "left over" triangles.
 The problem is that I can't seem to get the routine to work. ;)

I have included the code below, if anyone has any ideas or has code that does
this type of thing, please help!

-A

Allen Bierbaum
ISU Vislab

------------------------ CODE --------------------------------

#define MAX_GEOSET_SIZE 5
...

void decomposeGeoSet(pfGeoSet* geoSet, pfGeode* parentGeode)
{
    int numTris = geoSet->getNumPrims(); // Need to know how many triangles
it currently has
    if (numTris <= MAX_GEOSET_SIZE) // Do we need to decompose????
        return;

    ushort* vIndexList=NULL; // Array of indexes for
vertexes
    pfVec3* vVertexList=NULL; // Array of vertexes
    geoSet->getAttrLists(PFGS_COORD3, (void**)&vVertexList, &vIndexList);
    ushort* cIndexList=NULL; // array of indexes for
colors
    pfVec4* cColorList=NULL; // Array of colors
    geoSet->getAttrLists(PFGS_COLOR4, (void**)&cColorList, &cIndexList);
    radElement** elementList = (radElement**)geoSet->getUserData();

    for (long offset=(numTris-MAX_GEOSET_SIZE);offset>0;offset -=
MAX_GEOSET_SIZE) {
        pfGeoSet* newGeoSet = new pfGeoSet; // The geoset to add
            newGeoSet->setPrimType(PFGS_TRIS);
        newGeoSet->setNumPrims(MAX_GEOSET_SIZE);
        newGeoSet->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, cColorList,
&cIndexList[(offset*3)]);
        newGeoSet->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, vVertexList,
&vIndexList[(offset*3)]);
        newGeoSet->setUserData((elementList+offset));
        parentGeode->addGSet(newGeoSet);
    }

    // Now we must update the original geoSet, it has an "off" number of tris
    // It makes up the extra, numTris mod MAX_GEOSET_SIZE
    geoSet->setPrimType(PFGS_TRIS);
    geoSet->setNumPrims(numTris%MAX_GEOSET_SIZE);
    geoSet->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, cColorList, cIndexList);
    geoSet->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, vVertexList, vIndexList);
    geoSet->setUserData(elementList);
}

-- 
 Allen Bierbaum
=======================================================================
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:53:11 PDT

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