Loaders in Java 3D
Before WrapLoaderInfo3D can traverse or change the external model's scene graph, the model has to be loaded. Java 3D supports external model loading through its Loader interface and the Scene class.Loader takes as input the model's filename and flags for enabling and disabling the loading of certain elements of the model, such as light nodes, sound nodes, and view graphs.
Java 3D's utilities package includes two subclasses of Loader aimed at particular file formats: Lw3dLoader
handles Lightwave 3D scene files, and ObjectFile
processes Wavefront OBJ files. A third subclass, LoaderBase
, implements the Loader interface in a generic way to encourage the building of loaders for other 3D formats through subclassing.
The Scene class uses a Loader object to extract details about a model, the most significant being its BranchGroup, usually for the purpose of adding it to the application scene. Information about other aspects of the model may be available, including the model's light nodes, object names, viewpoints, and behavior nodes. However, not all loaders supply this information, i.e., the relevant methods may return nothing.
There's a wide range of Java 3D loaders for different file formats, written by third-party developers. A good list is maintained at http://www.j3d.org/utilities/loaders.html.
Tip
Loaders specifically aimed at gaming are listed in Chapter 14.
In this and other chapters, I employ the loaders in the NCSA Portfolio package (available from http://www.ncsa.uiuc.edu/~srp/Java3D/portfolio/ ...