Viewer package

The plotter and animator packages produce fully valid 3D scenes. The viewer package renders these scenes and provides tools for manipulating the view. This package is very dependent on the underlying Java3D environment, so persons interested in the details are advised to first learn about Java3D itself via their very useful tutorial.

In Java3D, a BranchGroup object can be directly added to an active scene graph, and all of its children will be properly rendered. The ObjectGroup object already wraps it's contents within a BranchGroup, so the viewer can simply extract it from the ObjectGroup and add it to its private scene graph.

The key class is the PlotEnvironment. This class maintains the Java3D scene graph and it's window, and handles all the manipulation of the view and its contents. This is actually a disorganized way to manage these functions; future versions of this package will likely break this class into components that manage different tasks.

A critical method in this class in the initUniverse() method. This method is not called on instantiation of the PlotEnvironment, and must be called by the user prior to utilizing other methods. The main reason for this design is that initializing the window and the renderer is computationally expensive, but one might want to have a reference to the PlotEnvironment available. This allows the user to control when the viewer is initialized. This method creates the 3-D universe (currently a SimpleUniverse, from the com.sun utilities) and initializes several behaviors for manipulating the view.

A PlotEnvironment maintains a private registry of ObjectGroups, each with a unique tag of type int. In the event of multiple components of the data represented by different objects, this allows manipulations of a particular component, for example toggling whether a particular component is attached to the renderer and thus visible.

One difficulty with viewing is setting the appropriate scale. The data could have any values whatsoever, but these must be scaled to fit the field of view. Alternatively, the field of view can be scaled to match the range of data values. A related issue is the speed of zooming or translating, which is dependent on the physical scale of the 3-D model. These complex issues are simply addressed through a few functions that allow the user to set a scale factor and define the parameters of the view.

View manipulation is provided through the MouseBehavior classes of the com.sun.j3d.utils.mouse package. Click-and-drag is used to produce a behavior: rotate with button 1, zoom with button 2, translate with button 3. In addition, a control panel with some buttons is provided that will rotate the scene by discrete amounts (currently 22.5 degrees). The layout of this panel is described in the RotationControlPanel documentation.

Obviously, many additional features can be added to this package. One example in particular are tools for selecting subsets of the currently visible objects. Many more will be added as the framework is presented to users, who will provide feedback regarding their needs.


Home   NVisF   Design
This page last updated Jan 2 2001.