Java 3DTM API Collateral

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 node’s state is defined by the nodes in a direct path between the scene graph’s root and the leaf. Because a leaf’s 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 SGI’s 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 object’s 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 object—making 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 enabled—prior to the object being compiled or made live—are 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 ViewPlatform’s 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 user’s physical body.
  • Physical Environment Object
    The Physical Environment Object contains calibration information describing the physical world, mainly information that describes the environment’s 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 objects—including 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 node’s 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 NameDescription

BranchGroup NodeThe 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 NodeGuarantees that the Java 3D API will render its children in their index order
DecalGroup NodeSpecifies that its children generate coplanar objects
SharedGroup NodeProvides a mechanism for sharing the same subgraph in different parts of the tree via a Link node
Switch NodeAllows 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 NodeDefines either a solid background color or a background image that is used to fill the window at the beginning of each new frame.
Behavior NodeAllows 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 NodeDefines a bounding region object that can be referenced by other leaf nodes to define a region of influence, activation region, or scheduling region
Clip NodeDefines 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 NodeSpecifies the attributes that control fog, or depth cueing, in the scene
ExponentialFog NodeExtends the Fog leaf node by adding a fog density that is used as the exponent of the fog equation
LinearFog NodeExtends 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 NodeAbstract 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 NodeDefines 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 NodeDefines a point light source located at some point in space and radiating in a specific direction
Link NodeAllows an application to reference a shared subgroup, rooted by a SharedGroup node, from within a branch of the scene graph
Morph NodePermits an application to morph between multiple GeometryArrays (geometries)
Shape3D NodeSpecifies all geometric objects and contains two components: a reference to the shape’s geometry, and its appearance
Sound NodeDefines the properties common to all sound nodes; a scene graph can contain multiple sounds
BackgroundSound NodeDefines an unattenuated sound source that has no position or direction
PointSound NodeDefines a spatially-located sound whose waves radiate uniformly in all directions from some point in space
ConeSound NodeDefines 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 NodeSoundscape Node Defines the attributes that characterize the listener's environment as it pertains to sound
ViewPlatform NodeDefines 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
ColoringAttributesDefines attributes that apply to color mapping
LineAttributesDefines all rendering state that can be set as a component object of a Shape3D node (solid, dash, dot, dash-dot, width, pattern, antialiasing)
PointAttributesDefines all rendering state that can be set as a component object of a Shape3D node (point size, antialiasing)
PolygonAttributesDefines all rendering state that can be set as a component object of a Shape3D node (face culling, rasterization mode, offset)
RenderingAttributesDefines all rendering state that can be set as a component object of a Shape3D node (alpha, depth buffering)
TextureAttributesDefines attributes that apply to texture mapping
TransparencyAttributes Defines all attributes affecting transparency of the object
Material ObjectComponent object of an Appearance object that defines the material properties used when lighting is enabled
MediaContainerComponent object of a Sound node that defines the sound data associated with a Sound node.
TexCoordGenerationComponent object of an Appearance object that defines the parameters used when texture coordinate generation is enabled
Texture ObjectComponent object of an Appearance object that defines the texture properties used when texture mapping is enabled
Texture2D ObjectExtends the Texture class by adding a constructor and a mutator method for setting a 2D texture image
Texture3D ObjectExtends 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 ObjectAn abstract class that is used to define 2D and 3D PixelArray classes used for texture images and background images
PixelArray2DObject Defines a 2D array of pixels, used for texture and background images
PixelArray3DObject Defines a 3D array of pixels, used for texture and background images
DepthImageAn abstract class that defines a 2D array of depth (Z) values
DepthImageFloatExtends the DepthImage Object to define a 2D array of depth (Z) values in floating point format
DepthImageIntExtends the DepthImage object and defines a 2D array of depth (Z) values in integer format
DepthImageNativeExtends the DepthImage object and defines a 2D array of depth (Z) values stored in the most efficient format for a particular device
Bounds ObjectDefine three varieties of containing volumes (BoundingBox, Bounding Polytope, and BoundingSphere) which the Java 3D API uses to support various culling operations
BoundingBox ObjectAxis-aligned bounding box volumes
BoundingPolytope ObjectDefines a set of planes that prescribe a convex polygonal bounding region
BoundingSphere ObjectSpherical bounding volume with two associated values, a center point and a radius of the sphere
Transform3DTransformations 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 NameDescription

CompressedGeometry ObjectEmploys a special format for representing geometric information in one order of magnitude less space
Raster Geometry ObjectExtends geometry to allow drawing a raster image that is attached to a 3D location in the virtual world.
Text3D Geometry ObjectConsists 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 ObjectsAn abstract class from which several classes are derived to specify a set of geometric primitives
GeometryStripArrayAn abstract class from which all strip primitives (line strip, triangle strip and triangle fan) are derived
LineStripArrayDraws an array of vertices as a set of connected line strips
TriangleStripArrayDraws an array of vertices as a set of connected triangle strips
TrangleFanArrayDraws an array of vertices as a set of connected triangle fans
LineArrayDraws the array of vertices as individual line segments using each pair of vertices to define a line segment to be drawn
PointArrayDraws the array of vertices as individual points
QuadArrayDraws the array of vertices as individual quadrilaterals using each group of four vertices to defines a quadrilateral to be drawn
TriangleArrayDraws the array of vertices as individual triangles using each group of three vertices to define a triangle to be drawn
IndexedGeometryArrayObjects 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 ArrayAn 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
IndexedLineStripArrayDraws 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 ArrayDraws 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 ArrayDraws 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
IndexedPointArrayDraws the array of vertices as individual points
IndexedQuadArrayDraws the array of vertices as individual quadrilaterals with each group of four vertices defining a quadrilateral to be drawn
IndexedTriangleArrayDraws 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