Java3D Specific Hints

13. Minimise your reliance on collision detection, or do your own

You're walking along quitely minding your own business, head stuck in a paper, oblivious to the world around you when smack! you walk into a lamp post. Collision detection - it can get you in the physical world, why not the virtual world too!

The most common form of physical modelling done in a virtual environment

Java3D provides a mechanism to do it automatically for you

Like all forms of physical modelling, collision detection is expensive to perform and the more objects in your scene the more complex it becomes

Java3D's collision seems not to be the best one and is slow too

Okay for detecting a basic two-object collisions in very simple scenes

If you plan to use it, reduce the number of objects that can collide to the barest minimum

If collision detection is a big part of your application, build your own.

A good source of information is actually the computer games industry

Collision detection is perhaps the most common form of physical modelling done in a virtual environment. Because it is such an important part of physical interaction Java3D provides a mechanism to do it automatically for you. But, like all forms of physical modelling, collision detection is expensive to perform and the more objects in your scene the more complex it becomes. Java3D's collision detection system has some fairly nasty limitations and even the odd outright bug. It's slow too. It may be okay for detecting a basic two-object collisions in very simple scenes but don't rely on it for anything even remotely complex. If you plan to use it, reduce the number of objects that can collide to the barest minimum.

If collision detection is a big part of your application you will probably need to do your own collision detection. This is not a trivial task, but fortunately collision detection is a well studied problem. A good source of information is actually the computer games industry. Modern games have very demanding requirements for physical modelling.Collisions are the basis of all the interaction in games such as Quake, Unreal and Half-life. Grab a good game programming text, or hit any of online resources (http://www.gamasutra.com is a ripper) to learn more. But be warned, writing a general purpose collision detector is not for the faint of heart!