Page 1 of 1

Pimitive Loading

Posted: Thu Aug 13, 2009 4:49 am
by Gam3r GEEk
I have beeing going through the example of how to load a model into the phsyics engine, but I have a custom made 3d primitive. How can I load that into the StaticModel class?

Thanks,
Gam3r GEEk

Re: Pimitive Loading

Posted: Thu Aug 13, 2009 3:15 pm
by Norbo
A StaticTriangleGroup requires a TriangleMesh, and a TriangleMesh requires a listing of vertices and indices. It doesn't matter how you go about getting these vertices and indices; you could use a custom content processor, or you could just use the pre-existing StaticTriangleGroup.getVerticesAndIndicesFromModel function.

Once you construct a TriangleMesh, you can construct a StaticTriangleGroup with it. Add that to the space and it will work.

However, if you mean that you want to have a custom dynamic object that has some arbitrary triangulation, I suggest you use a ConvexHull object. This takes a list of vertices and computes its outer convex shell. The point set used to create a ConvexHull shouldn't be overly detailed to avoid speed and robustness issues.

If you need a concave dynamic object, you can use a CompoundBody. Compound bodies have a set of children shapes which are rigidly connected. You could technically create a compound body from a triangle mesh directly, but it is recommended that you use a simpler approximation- either normal primitives or a set of ConvexHulls.