I have a trivial piece of code to load a dae file and report on the geometries in it. getElementCount reports 3 geometries for each one in the file, and getElement loops over each 3 times. What am I doing wrong? Or am I mis-understanding something fundamental?
The output from this snippet when run on sample/data/cube.dae is:
Geometry 0 name box has id box
Geometry 1 name box has id box
Geometry 2 name box has id box
int
Collada::ReadColladaDoc(const char * filename)
{
int error;
DAE doc;
error = doc.load(filename);
assert(error == DAE_OK);
unsigned int geometryElementCount =
doc.getDatabase()->getElementCount(NULL,
COLLADA_ELEMENT_GEOMETRY, NULL);
for (unsigned int i = 0; i < geometryElementCount; ++i) {
domGeometry *curGeom;
error = doc.getDatabase()->getElement(
(daeElement **)&curGeom, i, NULL,
COLLADA_ELEMENT_GEOMETRY, NULL);
assert(error == DAE_OK);
printf("Geometry %i name %s has id %s
", i,
curGeom->getName(), curGeom->getId());
}
return geometryElementCount;
}