3D collision detection with irregular objects.

So I thought I’d make a few lozenge shaped objects, kind of like long rocks, to do some collision testing.

Quickly I realised the BoundingSphere is no use here, because at least 50% of the produced sphere is empty.space.

How would you get around this scenario? I’ve thought of 2 possible solutions, but have no idea which would be the most expensive or what drawbacks there would be.

  1. Create the object as 2 meshes, each being roughly spherical, then loop the meshes in the collision testing. The downside being texturing could be difficult.
  2. Use one mesh and do two checks, one at each end of the object. Downside being there’s a load more math finding the ‘centre’ of each end of the object.

This problem is obviously going to rear its head with any number of irregular objects.

Then I thought, what about a disk shape, something like a tablet, or a jar lid. It has a circular or rectangular area but little height. How would you go about collision testing that object? It would be very difficult to create out of small meshes.

Then, what if you have multiple objects of different shapes in the same scene and want to collision test everything?

I know I’m getting into the realms of physics engines rather than games, but I want to test the limits of what I can get before starting something, getting half way though, and realising I’ve gone in a dumb direction.

Any input would be gratefully received.

Thank you.

It depends on if you are detecting against a ray or a point.

Basically you handle either with plane intersection tests the forumla and algorithms used depend on the type of impactor to say if it will be a ray test or point test.

The thing you collide against in most games is typically a bounding box or simply a bounding sphere or a set of planes formed from a collision polyhedron or a mix or combination of these for different objects.

What you want to look up though is simply “3d Collision detection”
for example:
http://www.miguelcasillas.com/?mcportfolio=collision-detection-c

http://geomalgorithms.com/a06-_intersect-2.html

see spacial index here

http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/www/notes/bsp_tutorial.pdf

I favor simple approximated collision polyhedrons and ray or point tests.

Real Time Collision Detection page 75. You’ll be intersted in sphere-swept or k-DOP bounding volumes. But you have to ask, is it worth it? You can find a copy of the book on the internet if you are resourceful… Or you can buy it.