![]() | ![]() | ![]() |
|
Collisions© Justin Couch 2000In the previous section it was mentioned that one of potential the uses of picking is to build a collision detection system. It was also noted that Java3D has its own in-built system for this. Collision detection is built in so that it acts like any other behaviour. It has wakeup criteria available for notification and also methods of specifying exactly what should be collided with. Per ObjectThe most simple collision system is based on object to object collision. The default implementation of theNode object sets the
collision system on by default (just like picking). Based on this, whenever
one piece of geometry collides with another, a behaviour could be executed
to deal with the results. Simple or complex interactions can then take place.
Note that this could be any arbitrary object, not just the user’s avatar
with an object.
Because collisions notifications are delivered by the behaviour mechanism, unless you register a behaviour you will never know if two objects collide. That is, the default implementation is just to issue a message to say that two objects have collided, but do nothing about it. It is possible for two objects to pass straight through each other and the rendering engine will not do anything about it. There are three types of notification that the system will deliver for collisions:
Overriding Default BoundsOne potential problem with per object collisions is that complex, non-primitive objects can be extremely compute intensive to deal with collision detection. If you are finding that this is slowing you application down, you might want to try optimising the calculation routines by providing alternative bounds to work against. One typical example of this is to provide a box collision volume around a complex object (eg a car).
If you wish to override the default object shape, then you can use the
Once this is set, your collision behaviours are now based on this region rather than the raw geometry objects themselves and should (providing you actually do make the bounding area simpler) provide a great speed improvement. |
|