Using the SimpleUniverse class in Java 3D programming significantly reduces the time and effort needed to create the view branch graph. Consequently, the programmer has more time to concentrate on the content.

This is what writing a Java 3D program is really about.

  1. Create a Canvas3D Object
  2. Create a SimpleUniverse object which references the earlier Canvas3D object
    • Customize the SimpleUniverse object
  3. Construct content branch
  4. Compile content branch graph
  5. Insert content branch graph into the Locale of the SimpleUniverse

To illustrate the simple recipe a "Hello Java3D" application is written here. The application will display a color cube in a frame. You can run this application by typing 'java HelloJava3D' in command line.

 import java.awt.*;
import javax.swing.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;

 * This is the main class of the hello Java3D demo.
public class HelloJava3D extends JFrame {
  public HelloJava3D() {
    GraphicsConfiguration config = SimpleUniverse
    Canvas3D canvas3D = new Canvas3D(config);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

    // This moves the ViewPlatform back a bit so the
    // objects in the scene can be viewed.

  } // end of HelloJava3D (constructor)

  public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create a simple shape leaf node, add it to the scene graph.
    // ColorCube is a Convenience Utility class
    objRoot.addChild(new ColorCube(0.4));

    return objRoot;
  } // end of createSceneGraph method of HelloJava3D
  public static void main(String[] args){
    JFrame frame=new HelloJava3D();
    frame.setTitle("Hello Java3D");
} // end of class HelloJava3D