Tuesday, August 21, 2018

Tools to generate convex collision geometry


Does anyone know tools to generate convex collision geometry from given 3D model?


For example, UDK's Static Mesh Editor can do this; Valve instead recommends to use smoothing in 3D editor.


Desired features:




  1. The tool could convert concave geometry into convex shape automatically and remove unnecessary model data.

  2. Could allow us to specify number of vertices/triangles in generated collision shape.

  3. Could export that shape to some interchange file format (like COLLADA or FDX).


Does that tool exist? (it even can be commercial, not free, but could be obtained separately, without particular engine/SDK/bundle...)



Answer



I suggest automatically generating, and maybe caching, the convex collision meshes instead of creating them by an external tool. However, I am not sure which of the following ideas is what you want.


Do you want to end up with a single convex shape for a single model? That would be a convex hull around all vertices. Of course that simplification results in not that accurate collisions but on the other hand it is very fast compute them. Moreover, you have only one physics body per object which is faster than the alternative below.


original modelconvex hull of the model


Images are from http://cgtools.net/treatments_convex_hull.html.



Do you want to end up with several convex shapes for a single model? Then convex decomposition is what you want. For example Bullet Physics has an algorithm called HACD built in to perform convex decomposition. There is also a standalone version you could integrate in your own application. Furthermore, the algorithms allows you to specify the amount of detail and number of clusters in the result.


convex decomposition performed by HACD


This screenshot is from the algorithm author's blog linked above.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...