|
The Java 3DTM API Specification Version 0.98
Scene Graphs and Java 3DTM API Objects
This chapter provides an overview of the Java 3DTM API scene graph along with its component objects. For a more detailed discussion of these
objects, along with their methods, the Java 3D API Specification should be consulted.
Scene Graph Overview
As discussed earlier, a Java 3D API scene graph consists of objects, called nodes, arranged in a tree structure. The user creates one or more
scene subgraphs and attaches them to a virtual universe.
The individual connections between Java 3D nodes are always a directed relationship: parent to child. The Java 3D API differs from other scene
graph-based systems in that scene graphs may not contain cycles. Thus, a Java 3D scene graph is a directed acyclic graph (DAG) as
shown in Figure 3-1.

Scene Graph Structure
A scene graph organizes and controls the rendering of its constituent objects. All Java 3D renderers draw a scene graph in a consistent
manner that allows for concurrence. A Java 3D renderer can draw one object independently of other objects. The Java 3D API can allow such
independence because its scene graphs have a particular form and cannot share state among branches of a tree.
Spatial Separation
The hierarchy of the scene-graph imposes a natural spatial grouping on the geometric objects found at the leaves of the graph. Internal
nodes act to group their children together. Group nodes also define a spatial bound that contains all the geometry defined by its
descendants. Spatial grouping allows for efficient implementation of operations such as proximity detection, collision detection, view
frustum culling, and occlusion culling.
State Inheritance
A leaf nodes state is defined by the nodes in a direct path between the scene graphs root and the leaf. Because a leafs graphics context
only relies on a linear path between the root and that node, the Java 3D renderer can decide to traverse the scene graph in whatever
order it wishes. Except for spatially bounded attributes (i.e. lights and fog), the scene graph can be traversed from left to right and top to
bottom, level order from right to left, or even in parallel.
Many older scene graph-based APIs (including PHIGS and SGIs Inventor ä ) feature less flexible rendering traversal. In these systems,
if a node above or to the left of a given node changes the graphic state, the change affects the graphic state of all nodes below it or to its
right.
The most common node object, along the path from the root to the leaf, that changes the graphics state is the TransformGroup object.
The TransformGroup object can change the position, orientation, and/or scale of the objects below it.
Most graphics state is set by a Shape3D node through its constituent Appearance object which allows for parallel rendering. The
Shape3D node also has a constituent geometry object that specifies its geometry, permitting different Shape3D objects to share common
geometry without sharing material attributes (or vice-versa).
Rendering
The Java 3D renderer incorporates all graphics state changes made in a direct path from a scene-graph root to a leaf object in the
drawing of that leaf object. The Java 3D API provides this semantic for both retained and compiled-retained modes.
Scene Graph Objects
A Java 3D scene graph consists of a collection of Java 3D node objects connected in a tree structure. These node objects reference
other scene graph objects called component objects. All scene graph node and component objects are subclasses of a common
SceneGraphObject class (see Figure 3-2). The SceneGraphObject class is an abstract class that defines methods that are common
among nodes and component objects.

Scene graph objects are constructed by creating a new instance of the desired class and are accessed and manipulated using the objects
set and get methods. Once a scene graph object is created and connected to other scene graph objects to form a subgraph, the entire
subgraph can be attached to a virtual universe via a high-resolution Locale objectmaking the object live. Prior to attaching a
subgraph to a virtual universe, the entire subgraph can be compiled into an optimized, internal format.
An important characteristic of scene graph objects is that they can only be accessed or modified during the creation of a scene graph,
except where explicitly allowed. Access to most set and get methods of objects that are part of a live or compiled scene graph is
restricted. Such restrictions provide the scene-graph compiler with usage information it can use in optimally compiling or rendering a
scene graph.
Each object has a set of capability bits that enable certain functionality when the object is live or compiled. By default, all capabilities are
disabled. Only those set and get methods corresponding to capability flags that are explicitly enabledprior to the object being compiled
or made liveare legal. The methods for setting and getting capability flags are described in the Java 3D API Specification.
Scene Graph Superstructure Objects
The Java 3D API defines two Scene graph superstructure objects, the VirtualUniverse and Locale, which are used to contain collections of
subgraphs that comprise the scene graph.
VirtualUniverse Object
A VirtualUniverse object consists of a name and a list of Locale objects that contain a collection of scene graph nodes that exist in the
named universe. Typically, an application will need only one VirtualUniverse, even for very large virtual databases. Operations on a
VirtualUniverse include retrieving its name and enumerating the Locale objects contained within the universe.
Locale Object
The Locale object acts as a container for a collection of subgraphs of the scene graph that are rooted by a BranchGroup node. A Locale
also defines a location within the virtual universe using high resolution coordinates (HiResCoord) to specify its position. This HiResCoord
serves as the origin for all scene graph objects contained within the Locale.
A Locale has no parent in the scene graph, but is implicitly attached to a named virtual universe when it is constructed. A Locale may
reference an arbitrary number of BranchGroup nodes, but has no explicit children.
The coordinates of all scene graph objects are relative to the HiResCoord of the Locale in which they are contained. Operations on a
Locale include setting or getting the HiResCoord of the Locale, adding a subgraph, and removing a subgraph.
Node Objects
The Java 3D API refines the Node object class into two subclasses: Group and Leaf node objects. Group node objects group together one or
more child nodes. A group node can point to zero or more children but can have only one parent (some group nodes have no parents).
Leaf node objects contain the actual definitions of shapes in the form of geometry objects, lights, fog, sounds, etc. The semantics of both
group and leaf nodes are described later in this chapter.
Scene Graph Component Objects
Scene graph component objects include the actual geometry and appearance attributes used to render the geometry. These component
objects are described later in this chapter.
Scene Graph Viewing Objects
The Java 3D API defines six scene graph viewing objects that are not part of the scene graph per se, but serve to define the viewing parameters
and to connect with the physical world. Scene graph viewing objects are illustrated in Figure 3-3.
- ViewPlatform
The ViewPlatform object is a Leaf node that locates a view within a scene graph. The ViewPlatforms parents specify its location,
orientation, and scale within the Virtual Universe.
- View Object
The View object specifies information needed to render the scene graph. The View object is the central Java 3D object for
coordinating all aspects of viewing. All viewing parameters in the Java 3D API are either directly contained within the View object or within
objects pointed to by a View object. The Java 3D API supports multiple simultaneously active View objects, each of which can render to
one or more canvases.
- Canvas3D Object
The Canvas3D object encapsulates all of the parameters associated with the window being rendered into. When a Canvas3D
object is attached to a View object, the Java 3D traverser renders the specified view onto the canvas. Multiple Canvas3D objects
can point to the same View object.
- Screen3D Object
The Screen3D object encapsulates all of the parameters associated with the physical screen containing the canvas, such as the
width and height of the screen in pixels, the physical dimensions of the screen, and whether the screen is head-mounted or is fixed
in position.

- Physical Body Object
The Physical Body Object contains calibration information describing the users physical body.
- Physical Environment Object
The Physical Environment Object contains calibration information describing the physical world, mainly information that describes
the environments six-degree-of-freedom tracking hardware, if present.
Group Node Objects
The Group node is an abstract class for the general purpose of grouping objects used in constructing a scene graph. The group node
object hierarchy is listed in Figure 3-4.

Group Node
All group nodes can have a variable number of child node objectsincluding other group nodes as well as leaf nodes. Group nodes have
exactly one parent.
The children of a group node have associated with them an index that allows operations to specify a particular child. However, unless one
of the special ordered group nodes is used, the Java 3D renderer can choose to render a group nodes children in whatever order it
chooses (including rendering the children in parallel).
Operations on Group node objects include: adding, removing, and enumerating the children of the Group node. The subclasses of Group
add additional semantics. Subclasses of the Group Node are listed in Table 3-1 below along with their descriptions.
| |
| Node Name | Description |
| |
| BranchGroup Node | The root of a subgraph of a scene that may be compiled as a unit, attached to a virtual universe, or included as a child of a group node in another subgraph |
| OrderedGroup Node | Guarantees that the Java 3D API will render its children in their index order |
| DecalGroup Node | Specifies that its children generate coplanar objects |
| SharedGroup Node | Provides a mechanism for sharing the same subgraph in different parts of the tree via a Link node |
| Switch Node | Allows a Java 3D API-based application to choose dynamically among a number of subgraphs |
Transform Group
Node | Specifies a single spatial transformation that can position, orient, and scale all of its children |
| |
| |
| Table 3-1 Group node objects | |
Leaf Node Objects
The leaf node is an abstract class for all scene graph nodes which have no children. Figure 3-5 depicts the Leaf node object hierarchy.

Leaf Node
Leaf nodes specify lights, geometry and sounds and provide special linking and instancing capabilities for sharing scene graphs, as well as
a view platform for positioning and orienting a view in the virtual world. Subclasses of the Leaf Node are listed in Table 3-2 along with
their descriptions.
| |
| Node Name | Description |
| |
| Background Node | Defines either a solid background color or a background image that is used to fill the window at the beginning of each new frame. |
| Behavior Node | Allows an application to manipulate a scene graph at runtime; behavior is an abstract class that defines properties common to all behavior objects in the Java 3D API |
| BoundingLeaf Node | Defines a bounding region object that can be referenced by other leaf nodes to define a region of influence, activation region, or scheduling region |
| Clip Node | Defines the far clipping plane used to clip objects in the virtual world; also specifies an application region in which this Clip node is active |
| Fog Node | Specifies the attributes that control fog, or depth cueing, in the scene |
| ExponentialFog Node | Extends the Fog leaf node by adding a fog density that is used as the exponent of the fog equation |
| LinearFog Node | Extends the Fog leaf node by adding a pair of distance values, in Z, at which fog should start obscuring the scene and should maximally obscure the scene |
| Light Node | Abstract class that defines the properties common to all light nodes. A Light node has associated with it a color, state (on/off), and a Bounds object. |
| AmbientLight | Defines an ambient light source |
| DirectLight Node | Defines an oriented light with an origin at infinity |
| PointLight Node | Defines a point light source located at some point in space and radiating light in all directions (also known as a positional light) |
| SpotLight Node | Defines a point light source located at some point in space and radiating in a specific direction |
| Link Node | Allows an application to reference a shared subgroup, rooted by a SharedGroup node, from within a branch of the scene graph |
| Morph Node | Permits an application to morph between multiple GeometryArrays (geometries) |
| Shape3D Node | Specifies all geometric objects and contains two components: a reference to the shapes geometry, and its appearance |
| Sound Node | Defines the properties common to all sound nodes; a scene graph can contain multiple sounds |
| BackgroundSound Node | Defines an unattenuated sound source that has no position or direction |
| PointSound Node | Defines a spatially-located sound whose waves radiate uniformly in all directions from some point in space |
| ConeSound Node | Defines a point sound source located at some location in space whose amplitude is constrained not only by maximum and zero amplitude spheres but by two concentric cone volumes directed down a vector radiating from the sound's location |
| Soundscape Node | Soundscape Node Defines the attributes that characterize the listener's environment as it pertains to sound |
| ViewPlatform Node | Defines a viewing platform that is referenced by a View object |
| |
| Table 3-2 Leaf node objects | |
Scene Graph Component Objects
The node objects described above do not fully specify their exact semantics by themselves. Some information is specified as an attribute
and an associated floating-point or integer value.
In many cases, however, node objects utilize references to more complex entities called component objects in order to specify
appearances or other properties. Node component objects encapsulate related state information in a single entity.
Within the Java 3D API two main groupings of objects are provided. One grouping provides attribute information, the other provides geometry
information required to describe the geometry of a Shape3D Node.
Node Component Objects - Attribute
Attribute node component objects provide information relating to the appearance (materials, textures, images), or implement other
properties (bounding boxes, etc.) to the nodes that reference them.
The attribute component object hierarchy is shown in Figure 3-6.

| |
| Node Name | Description |
| |
Appearance
Component Object | Component object of a Shape3D node that defines all rendering state for that Shape3D node |
Aural Attributes
Component Object | Component object of a Soundscape node that defines environmental audio parameters that affect sound rendering |
| ColoringAttributes | Defines attributes that apply to color mapping |
| LineAttributes | Defines all rendering state that can be set as a component object of a Shape3D node (solid, dash, dot, dash-dot, width, pattern, antialiasing) |
| PointAttributes | Defines all rendering state that can be set as a component object of a Shape3D node (point size, antialiasing) |
| PolygonAttributes | Defines all rendering state that can be set as a component object of a Shape3D node (face culling, rasterization mode, offset) |
| RenderingAttributes | Defines all rendering state that can be set as a component object of a Shape3D node (alpha, depth buffering) |
| TextureAttributes | Defines attributes that apply to texture mapping |
| TransparencyAttributes | Defines all attributes affecting transparency of the object |
| Material Object | Component object of an Appearance object that defines the material properties used when lighting is enabled |
| MediaContainer | Component object of a Sound node that defines the sound data associated with a Sound node. |
| TexCoordGeneration | Component object of an Appearance object that defines the parameters used when texture coordinate generation is enabled |
| Texture Object | Component object of an Appearance object that defines the texture properties used when texture mapping is enabled |
| Texture2D Object | Extends the Texture class by adding a constructor and a mutator method for setting a 2D texture image |
| Texture3D Object | Extends the Texture class by adding a third texture coordinate and by adding a constructor and a mutator method for setting a 3D texture image |
| PixelArray Object | An abstract class that is used to define 2D and 3D PixelArray classes used for texture images and background images |
| PixelArray2D | Object Defines a 2D array of pixels, used for texture and background images |
| PixelArray3D | Object Defines a 3D array of pixels, used for texture and background images |
| DepthImage | An abstract class that defines a 2D array of depth (Z) values |
| DepthImageFloat | Extends the DepthImage Object to define a 2D array of depth (Z) values in floating point format |
| DepthImageInt | Extends the DepthImage object and defines a 2D array of depth (Z) values in integer format |
| DepthImageNative | Extends the DepthImage object and defines a 2D array of depth (Z) values stored in the most efficient format for a particular device |
| Bounds Object | Define three varieties of containing volumes (BoundingBox, Bounding Polytope, and BoundingSphere) which the Java 3D API uses to support various culling operations |
| BoundingBox Object | Axis-aligned bounding box volumes |
| BoundingPolytope Object | Defines a set of planes that prescribe a convex polygonal bounding region |
| BoundingSphere Object | Spherical bounding volume with two associated values, a center point and a radius of the sphere |
| Transform3D | Transformations are represented by matrix multiplication and include such operations as rotation, scaling, and translation. The Transform3D object is represented internally as a 4x4 floating point matrix |
|
| Table 3-3 Attribute component objects | |
Node Component Objects - Geometry
A Geometry object is an abstract class which specifies the geometry component information required by a Shape3D node. Geometry
objects describe both the geometry and topology of the Shape3D nodes which reference them.
The geometry component object hierarchy is shown in Figure 3-7

Geometry objects consist of four generic geometric types: CompressedGeometry, Raster, Text3D, and GeometryArray (of which there
are many subclasses). Each of these geometric types define a visible object or set of objects. Non GeometryArray objects are listed and
described in Table 3-4.
| |
|
Node
Name | Description |
| |
| CompressedGeometry
Object | Employs a special format for representing geometric information in one order of magnitude
less space |
| Raster
Geometry
Object | Extends geometry to allow drawing a raster image that is attached to a 3D location in the
virtual world. |
| Text3D
Geometry
Object | Consists of a set of 3D glyphs, created from an extruded font, that represents a text string |
| |
| Table
3-4
Non
GeometryArray
geometry
component
objects | |
GeometryArray Objects
A GeometryArray object is an abstract class from which several classes are derived to specify a set of geometric primitives. A
GeometryArray contains separate arrays of the following vertex components: coordinates, colors, normals and texture coordinates, and a
bitmask indicating which of these components are present.
A single GeometryArray contains a predefined collection of per-vertex information and all of the vertices in a GeometryArray object have
the same format and primitive type. Different GeometryArrays can contain different per-vertex information. One GeometryArray might
contain only three-space coordinates while another might contain per-vertex coordinates, normals, colors, and texture coordinates. Yet a
third GeometryArray might contain any subset of the previous examples.
The Geometry Component Objects which are derived from the GeometryArray object are listed and described in Table 3-5.
| |
| Node Name | Description |
| |
| GeometryArray Objects | An abstract class from which several classes are derived to specify a set of geometric primitives |
| GeometryStripArray | An abstract class from which all strip primitives (line strip, triangle strip and triangle fan) are derived |
| LineStripArray | Draws an array of vertices as a set of connected line strips |
| TriangleStripArray | Draws an array of vertices as a set of connected triangle strips |
| TrangleFanArray | Draws an array of vertices as a set of connected triangle fans |
| LineArray | Draws the array of vertices as individual line segments using each pair of vertices to define a line segment to be drawn |
| PointArray | Draws the array of vertices as individual points |
| QuadArray | Draws the array of vertices as individual quadrilaterals using each group of four vertices to defines a quadrilateral to be drawn |
| TriangleArray | Draws the array of vertices as individual triangles using each group of three vertices to define a triangle to be drawn |
| IndexedGeometryArray | Objects An abstract class that extends GeometryArray to allow vertex data to be accessed via a level of indirection by adding corresponding arrays of coordinate indices, color indices, normal indices, and texture coordinate indices |
| IndexedGeometryStrip Array | An abstract class from which all indexed strip primitives (line strip, triangle strip and triangle fan) are derived; additionally specifies a number of strips and an array of per-strip vertex counts that indicates where the separate strips appear in the vertex array |
| IndexedLineStripArray | Draws an array of vertices as a set of connected line strips while an array of per-strip vertex counts specifies where the separate strips appear in the vertex array |
| IndexedTriangleStrip Array | Draws an array of vertices as a set of connected triangle strips while an array of per-strip vertex counts specifies where the separate strips appear in the vertex array |
| IndexedTrinagleFan Array | Draws an array of vertices as a set of connected triangle fans while an array of per-strip vertex counts specifies where the separate strips (fans) appear in the vertex array |
| IndexedLineArray | Draws the array of vertices as individual line segments with each pair of vertices defining a line segment to be drawn |
| IndexedPointArray | Draws the array of vertices as individual points |
| IndexedQuadArray | Draws the array of vertices as individual quadrilaterals with each group of four vertices defining a quadrilateral to be drawn |
| IndexedTriangleArray | Draws the array of vertices as individual triangles with each group of three vertices defining a triangle to be drawn |
| |
| Table 3-5 GeometryArray geometry component objects | |
Continue to next chapter
Download the complete document in .pdf format for offline reading and printing
|