< Zurück | Inhalt | Weiter >


The behavior model provides a powerful mechanism to enable application code to be called in a demand−driven manner. Events that occur within the scenegraph can trigger code to be executed, analogous to event processing for GUI elements.

Behaviors can be very useful, but they hinge upon Java 3D’s behavior processor to call them when their WakeUp criteria has been met. Your Behaviors can only be as functionally rich as combinations of WakeUp criteria will allow—there is no point writing a Behavior that should be invoked when the user scratches his head, because Java 3D will never invoke it.

Java 3D provides a relatively complete set of WakeupCondition−derived classes; however, not all eventualities have been covered, and there may be occasions where there is not a suitable WakeupCondition−derived class. For example, there is currently no equivalent to VRML’s VisibilitySensor Node. Chapter 13 builds upon these concepts and illustrates how to write your own custom Behaviors.

The next sections will describe some of the most useful built−in behaviors: keyboard and mouse navigation, aligning objects relative to the viewer, and choosing different object models based on the distance from the viewer.