Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

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).

Java3dTree representation of the Checkers3D scene graph

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page