TriangleMeshes

User avatar
cippyboy
Posts: 36
Joined: Fri Aug 25, 2006 1:00 am
Location: Bucharest

TriangleMeshes

Post by cippyboy »

1) I use "Shape[3]=new TriangleMeshShape(Array);" Is there a difference between this and "Shape[3]=new BvhTriangleMeshShape(Array);" ? They're both derived from ConcaveShape, and what if my triangled object is Convex ?

2) TriangleMeshes cannot move as I see, is there any convex mesh that can be moved ?

3) Is there a triangle shape that I can add ? So I can make compounds of more triangles to simulate my object ?

4) As a side question : Does Ageia's PhysX or Havok currently support TriangleMeshe<->TriangleMeshes dynamics ?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: TriangleMeshes

Post by Erwin Coumans »

cippyboy wrote:1) I use "Shape[3]=new TriangleMeshShape(Array);" Is there a difference between this and "Shape[3]=new BvhTriangleMeshShape(Array);" ? They're both derived from ConcaveShape, and what if my triangled object is Convex ?
BvhTriangleMeshShape uses a optimization, a Bounding Volume Hierarchy (a AABB tree, with stackless traversal). The TriangleMeshShape is brute-force slow, but can be useful for very small meshes (< 5 triangles).

For convex meshes, use either ConvexTriangleMeshShape or ConvexHullShape. The latter just takes a point cloud (Bullet's Gjk doesn't requires/benefit from connectivity, no 'hill-climbing').
2) TriangleMeshes cannot move as I see, is there any convex mesh that can be moved ?
ConvexTriangleMeshShape or ConvexHullShape can be moved. So can be compound shapes. For compounds, make sure the inertia has some useable values. Typically the bounding-box can be used as approximation for inertia tensor.
3) Is there a triangle shape that I can add ? So I can make compounds of more triangles to simulate my object ?
Yes, you can add triangle shapes to compounds, but watch the inertia tensor. In the future a better inertia tensor computation will be added for compounds. Also, at the moment compounds don't have an additional midphase BVH/tree optimization, so keep the number of parts small (<10).
4) As a side question : Does Ageia's PhysX or Havok currently support TriangleMeshe<->TriangleMeshes dynamics ?
No they don't. Ageia has a PMAP for that purpose, but that is deprecated for real-time purposes.
User avatar
cippyboy
Posts: 36
Joined: Fri Aug 25, 2006 1:00 am
Location: Bucharest

Post by cippyboy »

Ok, so I kinda understand now and figured that an usual 3d object is not exactly convex, not even a rock is convex... Is there an easy way to test if an object is convex ? or one already in 3DS Max as that is what I use for exporting.

I just marked a concave object as convex, what exactly happens in that situation ? because I see that it kinda emulates some boxes around my object, which would be good in same cases, although their not accurate.
User avatar
SteveBaker
Posts: 127
Joined: Sun Aug 13, 2006 4:41 pm
Location: Cedar Hill, Texas

Post by SteveBaker »

cippyboy wrote:Ok, so I kinda understand now and figured that an usual 3d object is not exactly convex, not even a rock is convex...
Some rocks are convex.
Is there an easy way to test if an object is convex ? or one already in 3DS Max as that is what I use for exporting.
You'd have to calculate the angles between each pair of polygons that share a common edge and only if every edge is convex is the entire mesh convex. However, that only works for closed meshes (ie no holes or disconnected parts). The definition of "concave" and "convex" is really undefined for meshes with holes.
I just marked a concave object as convex, what exactly happens in that situation ? because I see that it kinda emulates some boxes around my object, which would be good in same cases, although their not accurate.
I'm not 100% sure - but in all likelyhood it would act as if the concave parts of it were 'filled in'. Imagine if you had a polygonal model of the letter 'E' - (which has two concavities) it would behave as if it were a solid rectangle...but like I said - I'm not 100% sure.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

SteveBaker wrote:
I just marked a concave object as convex, what exactly happens in that situation ? because I see that it kinda emulates some boxes around my object, which would be good in same cases, although their not accurate.
I'm not 100% sure - but in all likelyhood it would act as if the concave parts of it were 'filled in'. Imagine if you had a polygonal model of the letter 'E' - (which has two concavities) it would behave as if it were a solid rectangle...but like I said - I'm not 100% sure.
Thanks Steve, you are right:
it will fill-in the concave parts.
Also notice that it is recommended to use the ConvexHullShape, and just pass points/vertices. For best performance it's best to keep the number of vertices low (using a low-level of detail or mesh simplification/reduction).
User avatar
cippyboy
Posts: 36
Joined: Fri Aug 25, 2006 1:00 am
Location: Bucharest

Post by cippyboy »

Ok, thanks a bunch, can I ask why is it so hard for cancave meshes to exist ? Or is it just impossible ? :D
User avatar
SteveBaker
Posts: 127
Joined: Sun Aug 13, 2006 4:41 pm
Location: Cedar Hill, Texas

Post by SteveBaker »

cippyboy wrote:Ok, thanks a bunch, can I ask why is it so hard for cancave meshes to exist ? Or is it just impossible ? :D
It makes collision detection math harder because there are more special cases. A convex object hitting a flat surface can only hit it at one point - but an object with concavities can hit it in several places.

It's not impossible - just much harder and hence slower.
User avatar
cippyboy
Posts: 36
Joined: Fri Aug 25, 2006 1:00 am
Location: Bucharest

Post by cippyboy »

Too Slow ? That's why no one tryed ? Well, in the future it's surely gonna be faster, there's must be a better argument.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

performance is one reasons. the other is robustness.

You can already use moving concave compounds in Bullet. But that works most reliable when you add convex pieces with volume. That way there is likely some valid collision normals available. Single triangles can easily get into degeneracies, and it even becomes worse then multiple concave meshes collide. Once continuous collision detection and response without any penetration is fully reliable, it should be easier to allow concave general meshes. But that's one of the areas we are working on.

Erwin