< Zurück | Inhalt | Weiter >

13.6 Summary

The BehaviorTest example allows many behaviors to affect a single texture−mapped Sphere. RotationInterpolator rotates the entire scene, ObjectSizeBehavior prints the size of the Sphere every 20 frames, ExplodeBehavior explodes the Sphere every 10 seconds, StretchBehavior models the vertices of the Sphere as weights attached to springs anchored at the origin, and BoundsBehavior tracks the Bounds of the Sphere.

Tying all these behaviors together into a single application allows complex application logic to be built up from relatively simple building blocks. The interactions between the behaviors can be explored by running the example and switching the behaviors on and off using the AWT buttons at the bottom of the Frame.

I hope the examples presented in this section have demystified Java 3D’s behaviors. You should now start breaking down your application logic into good, reusable, OO chunks and distributing them across your scenegraph. You should aim to empower your scenegraph objects with the abilities to detect, process, and respond to user interactions.

Keep a careful eye on application performance at all times, because excessive behavior processing can slow your frame rate or make your application appear unresponsive. Do not be afraid of writing more complex behaviors that can affect whole classes of objects within your scenegraph. In this way you may be able to limit the number of behaviors in the scenegraph and use a manager design philosophy, where each behavior manages a given class of objects within the scenegraph, instead of attaching single instances of a behavior to a single object.