The Java 3D API
Every Java 3D program is at least partially assembled from objects from the Java 3D class hierarchy.
This collection of objects describes a virtual universe, which is to be rendered. The API defines over
100 classes presented in the javax.media.j3d package. These classes are commonly referred to as
the Java 3D core classes.
There are hundreds of fields and methods in the classes of the Java 3D API. However, a simple virtual
universe that includes animation can be built with only a few classes. This chapter describes a minimal
set of objects and their interactions to render a simple virtual universe.
This chapter includes the development of one simple but complete Java 3D program called HelloJava3D,
which displays a rotating cube. The example program is developed incrementally, and presented in
multiple versions, to demonstrate each part of the Java 3D programming process. All of the programs
used in this tutorial are available electronically. See the "Getting This Tutorial" section in the Preface for
more information.
In addition to the Java 3D core package, other packages are used in writing Java 3D programs. One such
package is the com.sun.j3d.utils package that is commonly referred to as the Java 3D utility
classes. The core class package includes only the lowest-level classes necessary in Java 3D
programming. The utility classes are convenient and powerful additions to the core.
The utility classes fall into four major categories: content loaders, scene graph construction aids,
geometry classes, and convenience utilities. Future functionality, such as nurbs, likely would be added as
utility classes, not in the Java 3D core package. Some utility classes may be moved to the core package
in future versions of the Java 3D API.
Using utility classes significantly reduces the number of lines of code in a Java 3D program. In addition
to the Java 3D core and utility class packages, every Java 3D program uses classes from the java.awt
package and javax.vecmath package. The java.awt package defines the Abstract Windowing
Toolkit (AWT). AWT classes create a window to display the rendering. The javax.vecmath
package defines vector math classes for points, vectors, matrices, and other mathematical objects.
In the rest of the text, the term visual object is used to refer to an ‘object in the scene graph’ (e.g., a cube
or a sphere). The term object is used only to refer to an instance of a class. The term content is used to
refer to visual objects in a scene graph as a whole.