2
\$\begingroup\$

Currently I'm working on an Android OpenGL 3D game and now I want to implement a collision detection. For this I want to use oriented bounding boxes but here is my problem. For a normal oriented bounding box I have to store the middle and then the length into every dimension. Now let's say I have a tree and of course my character can walk under the treetop but not into the tree trunk. I tried to sketch up the different bounding boxes here:

Tree as two rectangels                         Normal bounding box

-----------------------                   ------------------------------
|                     |                   |                            |
-----------------------                   |                            |
        |     |                           |                            |
        |     |                           |                            |
        |     |                           |                            |
        |     |                           |             x              |
        |     |                           |                            |
        |     |                           |                            |
        |     |                           |                            |
        |     |                           |                            |
        |     |                           |                            |
        -------                           ------------------------------

If you think about the collision detection in the first sketch you can walk under the treetop because the border of the tree is subdivided into different shapes and the outline of a tree is still visible. In the second picture you can't tell something about the outline of the object because you only have one big box around the whole object so you can't walk under the treetop. You see the first method is much better then the second method for my plan.

Now my question: Do you have any ideas how I can subdivide my objects into different shapes? Maybe even in triangles, circles and so on. Is there an algorithm for this or do I have to do it by myself?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ you might find this paper interesting. \$\endgroup\$
    – mklingen
    Mar 19, 2015 at 13:46
  • \$\begingroup\$ Thank you for this really great paper. That was perfectly what I was looking for. But I can't find a date when it was published. 2 seconds for 300 points looks really expansive for me. Of course most of my objects only have around 50 points or something like that and the algorithm has to calculate many different cases but is 2 seconds not a bit long? \$\endgroup\$
    – Cilenco
    Mar 20, 2015 at 14:08

2 Answers 2

1
\$\begingroup\$

From my experience, the subdivision is made manually: you produce a 3d model for the graphics, and you compose another one made out of boxes, spheres, capsules and cylinders for your physics engine because it is generally what it understands well.

So yeah, basically, you have to make these yourself.

Unless you need very basic physics simulation, I would strongly advise you to try and use a readily available physics engine for your target language and platform. Physics simulation is one of the most complex things to manage in a game, and you'd probably like to spend your time on not recoding such a thing.

\$\endgroup\$
0
\$\begingroup\$

I agree with Alex, but more to the point, I don't think you'll find a silver bullet approach to make collision approximation models.

You will need to let your editor pick from a list of optional methods or generate one from scratch. After a tree model and material have been made, creating another cylinder and sphere mesh for collisions should be negligible effort.

\$\endgroup\$

You must log in to answer this question.

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