Java Reference
In-Depth Information
For the RotatingCube example, the geometry and appearance of the cube are defined
using the ColorCube class, while its behavior is that of rotation. The following subsections
give a simple overview of the meaning and implications of the various lines of codes and
the corresponding scene graph structure created.
In the RotatingCube example, the content branch is primarily built using the build-
ContentBranch() function, shown starting from line 12 of Figure 6. The 3D content of this
particular scene can be described in terms of the geometry, appearance and behavior of
the multicolor cube to be realized.
The geometry and appearance of the multicolored 3D cube is specified under a Shape3D
Node S1 in Figure 6. This node is created by the buildShape() function, which is a func-
tion outside the main content branch function. The buildShape() function returns a Node
type shape and is given in lines 34 to 36 of Figure 6. After being invoked in line 50, the
multicolor cube created is then passed as an argument to the buildContentBranch() func-
tion which proceeds to create the remaining attributes, including the rotation behavior B1
of the cube.
As given by lines 14 and 15, buildContentBranch() first creates new BranchGroup
BG_c and TransformGroup TG_c nodes in Figure 6. The next subsection will give further
information on these nodes, which are essential in the creation of the content branch.
From Figure 6, the behavior B1 node is connected to TG_c node by an arrow. This
indicates that the behavior is time varying. Line 17 invokes the setCapability() function,
which allows the real-time writing of transform information into an object. This is neces-
sary for the cube to be rotated continuously. Lines 21 to 26 continue with the creation of the
rotational attribute of the cube. Line 19 attaches TG_c to the newly created BG_c and lines
20 and 26 add the attributes of geometry and appearance, S1 and rotation B1 to TG_c. This
completes the creation of the content branch, BG_c, for the RotatingCube scene graph.
branch Group
In general, BranchGroup objects are for the purpose of organizing a scene graph. As previ-
ously described, the scene graph will have one viewing BranchGroup and another one for
content in the most basic configuration.
A viewing or content BranchGroup can be linked as a child to another BranchGroup or
node. The using and linking of BranchGroup objects or nodes are dependent on how objects
in the virtual world are being organized and behaved as well as programming style.
A properly organized BranchGroup structure facilitates the addition and removal of
visual objects in the virtual universe after the scene graph has become live. Specifically,
by setting the appropriate capability and using the relevant detach method, a BranchGroup
can be removed from its parent, thereby preventing all the underlying nodes from being
Search WWH ::

Custom Search