From: Bram Stolk (bram++at++sara.nl)
Date: 02/28/2001 09:44:43
Chris Scharver wrote:
>
> Hi.
>
> What's the correct process to extract data from a pfGeoSet? I cannot seem
> to get the vertex data for the PFGS_COORD3 attribute. I check the number
> of primitives, I get the attribute rangem and then I call getAttrLists;
>
> int numgsets = gd->getNumGSets();
> pfGeoSet *gs = ((pfGeode*) obj)->getGSet( 0 );
> int bind = gs->getAttrBind( PFGS_COORD3 );
> int rMax;
> int nverts = gs->getAttrRange( PFGS_COORD3, NULL, &rMax );
> void **verts;
> ushort **vindex;
> gs->getAttrLists( PFGS_COORD3, verts, vindex );
> for (int i=0; i<gs->getNumPrims(); i++)
> {
> cout << "Length of prim "<<i<<": "<<gs->getPrimLength( i )<<endl;
> for (int j=0; j<gs->getPrimLength( i ); j++)
> {
> cout << "("
> << ((pfVec3*)verts)[i+j][0] << " "
> << ((pfVec3*)verts)[i+j][1] << " "
> << ((pfVec3*)verts)[i+j][2] << ") ";
> }
> cout << endl;
> }
I don't trust your print loop.
'i' is the prim nr, j is a index within a primitive.
you cannot add those to form a single subscript.
Simply use:
pfVec3 *vertices = verts;
for (int i=0; i<nverts; i++)
cout << vertices[i][0] <<
....
Also, you may want to discriminate the indexed/non-indexed cases.
It will make it easier to understand, if you handle 1 case at a time.
A code fragment that is guaranteed to work
(well, it works for me anyway :-) is here:
static bool ExtractVertices
(
pfGeode *geode,
int geosetnr,
int &numverts,
pfVec3 *&verts
)
{
assert(geode);
int numsets = geode->getNumGSets();
if (geosetnr >= numsets)
return false;
pfGeoSet *geoset = geode->getGSet(geosetnr);
assert(geoset);
int min, max;
int vertcount;
vertcount = geoset->getAttrRange(PFGS_COORD3, &min, &max);
bool indexed = (max != -1);
if (indexed)
{
assert(min==0);
numverts = max + 1;
}
else
{
numverts = vertcount;
}
void *alist=0;
ushort *ilist=0;
geoset->getAttrLists(PFGS_COORD3, &alist, &ilist);
verts = (pfVec3 *) alist;
return (numverts != 0);
}
>
> Right now I'm just trying to print out the vertices as I parse through the
> geoset. However, I'm getting all 0's. Do I need to allocate memory for
> the pointer before I call getAttrLists, or does Performer directly pass
No need to allocate.
See the code fragment above.
> the base pointer from within the geoset? The man pages aren't too clear
> a,d I couldn't find anything useful in the Insight books.
>
> Thanks,
> Chris
Bram
> __________________________________________________________________________
> Chris Scharver EECS Graduate Student
> Electronic Visualization Laboratory EVL Phone: 312-996-3002
> The University of Illinois at Chicago EVL FAX: 312-413-7585
> 1998-1999 UIC Men's Swimming and Diving
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
-- ------------------------------------------------------------------------------ Bram Stolk, VR Specialist. SARA Academic Computing Services Amsterdam, PO Box 94613, 1090 GP AMSTERDAM email: bram++at++sara.nl Phone +31-20-5923059 Fax +31-20-6683167"I heard if you play the NT-4.0-CD backwards, you get a satanic message." "Thats nothing, if you play it forward, it installs NT-4.0" ------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Wed Feb 28 2001 - 09:45:05 PST