Swaminathan N. (swami++at++evl.eecs.uic.edu)
Wed, 28 Aug 1996 18:47:05 -0500 (CDT)
static void *
memdup(void *mem, size_t bytes) {
void *data = pfMalloc(bytes, pfGetSharedArena());
memcpy(data, mem, bytes);
return data;
}
// QvIndexedFaceSet is a class that has data members
// c.values: an array of pfVec3, pfMalloced
// coordIndex.values: an array containing the coordinate indices with -1 as
// end of face markers, pfMalloced
void
QvIndexedFaceSet::makegset() {
QvCoordinate *c = NULL;
if (coord.value) c = (QvCoordinate *)(coord.value);
//coord.value holds the coordinate values as a pfVec3 *
int numVerts = 0, numPrims = 0, numIndex = 0;
int length[1024];
ushort *icoord;
pfGeoSet *g = new pfGeoSet;
icoord = (ushort *)malloc(sizeof(ushort) * coordIndex.num);
// get rid of the -1 which are end of face markers
// coordIndex.num is the number of indices in total
for (int i=0; i<coordIndex.num; i++) {
if (coordIndex.get1Value(i) == -1 || i == coordIndex.num) {
length[numPrims++] = numVerts; // length contains the polygon size
numVerts = 0;
}
else {
// icoord contains the coord indices without the -1's
icoord[numIndex++] = coordIndex.get1Value(i);
numVerts++;
}
}
g->setNumPrims(numPrims);
g->setPrimLengths((int *)memdup(length,sizeof(int)*numPrims));
g->setPrimType(PFGS_POLYS);
g->setAttr(PFGS_COORD3, PFGS_PER_VERTEX,
memdup(c->point.values,sizeof(pfVec3)*c->point.num),
(ushort *)memdup(icoord, sizeof(ushort)*numIndex));
}
// pfPrint output
GeoSet: 0x180b7600 {
Primitive: PFGS_POLYS, INDEXED, pfPrims=800, glPrims=800, verts=2400
Attribute Bindings:
PFGS_COLOR4=PFGS_OFF PFGS_NORMAL3=PFGS_OFF PFGS_TEXCOORD2=PFGS_OFF
Attribute List Pointers:
PFGS_COORD3: 0x18102c90
PFGS_COLOR4: 0x0
PFGS_NORMAL3: 0x0
PFGS_TEXCOORD2: 0x0
Attribute Index List Pointers:
PFGS_COLOR4: 0x0
PFGS_NORMAL3: 0x0
PFGS_TEXCOORD2: 0x0
PFGS_COORD3: 0x18103fc0
Strip Lengths: eight hundred 3's follow here
3669 "Coord Index:" follow here
}
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:26 PDT