< Zurück | Inhalt | Weiter >

13.5 Using behaviors for debugging

A library of custom Behavior classes can be a very useful debugging aid, as they can be quickly added and removed from the scenegraph as needed. It is a simple step to conditionally add the debugging behaviors for development builds and remove them for production builds. For example, I have used the following two behaviors extensively:


1. BoundsBehavior is attached to a scenegraph Node and creates a wire frame ColorCube or Sphere to graphically represent the Bounds (BoundingBox or BoundingSphere) for the object at runtime.

2. FpsBehavior can be added anywhere in the scenegraph and writes the rendered FPS to the standard output window.


Both behaviors can be found in the org.selman.java3d.book package and are illustrated in the

BehaviorTest example application.


 

13.5.1 Calculating the rendered FPS using a behavior
NOTE
From FpsBehavior