Pimitive Loading

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Gam3r GEEk
Posts: 3
Joined: Mon Aug 10, 2009 11:03 pm

Pimitive Loading

Post 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
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Pimitive Loading

Post 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.
Post Reply