Number of vertices
The 3d model teeth in your resources folder has a total of 109.291 vertices counted in 3d Studio Max.
But, when I load it as a MultiMesh in chai3d with the loadFromFile function and then print its number of vertices (with getNumVertices()) I get 576.000 vertices.
Any idea why is that ?
For optimization reasons related to the way objects are rendered in OpenGL, each vertex in CHAI3D is defined by a position, surface normal, texture coordinate, color, etc...
With 3DS files, vertices are typically shared among neighbor triangles and therefore different surface normals can be defined for a single vertex when shared among different triangles. For these reasons, the number of vertices created in CHAI3D will typically correspond to three times the number of triangles of the model, and not to the number of vertices defined in the original 3DS file.
All right, thank you for explaining.
A quick follow-up question:
We have 3x the number of the vertices, but the number of the triangles/faces is exactly the same (getNumTriangles()) as in the 3ds max.
So is there any performance decrease in chai3d because of importing a .3ds file compared to an .obj ?
Since graphic cards offer large amounts of memory these days, the increased number of vertices has a limited impact on the overall performance.
Make sure however to enable display lists so that the entire mesh object is uploaded in GPU memory once and not at every frame. See example 21-object for more information.
// enable display list for faster graphic rendering object->setUseDisplayList(true);
I have two more questions and I don't want to spam your forum by creating new threads.
So here goes :
I was looking into the documentation looking for ways to get the contact/intersection points from 2 colliding objects and I read that the parent class cGenericCollision does not support collision detection between objects themselves.
1. Is the line segment the only shape I can use to detect collisions ? If yes, I would have to call the computeCollision function three times (once per triangle edge) to get the contacts points of a specific triangle and then repeat that for all the triangles of a mesh ?
2. Is there an example that uses CollisionRecorders ?