< Zurück | Inhalt | Weiter >

Implementing collision detection

To implement simple collision detection to prevent the viewer from walking through walls or bookcases, a modified keyboard behavior was used. The KeyCollisionBehavior class is derived from KeyBehavior, written by Gary Moss and Andrew Cain, included with permission in the org.selman.java3d.book package.

The KeyCollisionBehavior takes a reference to a CollisionDetector interface in its constructor. If the CollisionDetector.isCollision method returns true, the modified Transform3D is not applied to the TransformGroup and no movement will occur.


From KeyCollisionBehavior.java
From KeyNavigateTest.java