Viewing the Scene Graph
This chapter has used scene graphs to illustrate the discussed coding techniques, and scene graphs are a useful way of understanding (and checking) code.
I received help with my drawings by using Daniel Selman's Java3dTree package. It creates a JFrame holding a textual tree representation of the scene graph (Figure 15-9).

Figure 15-9. Java3dTree representation of the Checkers3D scene graph
The tree (a JTree object) is initially minimized, and branches can be examined by clicking on the subfolder icons. Information about the currently selected node appears in the bottom window. The package is available in j3dtree.jar as part of the source code downloadable from http://www.manning.com/selman/ for Selman's Java 3D Programming text.
Augmenting code to generate the JTree is simple. WrapCheckers3D must import the j3dtree package and declare a global variable for the JFrame tree display:
import com.sun.j3d.utils.behaviors.vp.*;
private Java3dTree j3dTree;The WrapCheckers3D() constructor creates the j3dTree object:
public WrapCheckers3D()
{
// other code
su = new SimpleUniverse(canvas3D);
j3dTree = new Java3dTree(); // create a display tree for the SG
createSceneGraph();
initUserPosition();
orbitControls(canvas3D);
su.addBranchGraph( sceneBG );
j3dTree.updateNodes( su ); // build the tree display window
}After the scene graph has been completed, (i.e., at the end of the ...