6
\$\begingroup\$

I lately integrated Bullet Physics into my little game engine, but for now I only use basic shapes as spheres or boxes for collision checks. For more realistic physics I need collision meshes for all models in the scene. They should be much simpler and in lower detail than the actual model for drawing to speed up computations.

Since I want adding new asserts to the engine as easy as possible, I am looking for a way to automatically generate collision meshes. I could just use the actual mesh loaded from file and that would result in very realistic physics calculations but that won't be fast enough. Therefore, how can I generate low detail collision meshes from a given set of vertices?

This task doesn't seem trivial since there many different cases to handle. For example a model of a house with furniture must retain details of floor and door frames while ornaments should be removed. I believe there already was research on this topic, but I couldn't find anything useful yet.

\$\endgroup\$
3
  • \$\begingroup\$ Convex hulls are a nice medium between boxes/spheres and the full mesh. \$\endgroup\$
    – ccxvii
    Apr 15, 2013 at 11:07
  • \$\begingroup\$ I cannot walk into a convex room. \$\endgroup\$
    – danijar
    Apr 15, 2013 at 12:17
  • \$\begingroup\$ @danijar but you can create it from convex hulls. Each wall would be a convex hull for example. \$\endgroup\$
    – Tara
    Apr 15, 2016 at 22:17

1 Answer 1

6
\$\begingroup\$

You can first decimate the mesh. Then use the decimated mesh to create a triangle mesh shape to create a collision mesh for that model.

You will probably run into issues with automatically generating meshes in this way. Since your physics object will not exactly match your world object. The decimating can have unexpected results for changing the shapes of meshes, particularly cutting off corners.

In my game, I define simple shapes in my modeling software (Blender), I name them something special like "PHYSICS_SHAPE_1", then my model importer looks for meshes with the name "PHYSICS_SHAPE*" and reads those to create physics objects. This is a little more work, but it ensures that my collision meshes are accurate and fits well with a data driven approach.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, especially your other answer you linked is very helpful. These algorithms are exactly what I was looking for. If someone minds, I will use the HACD algorithm that fits good into Bullet Physics. \$\endgroup\$
    – danijar
    Apr 15, 2013 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .