In retained mode, Graphics3D
renders a scene graph,
which may range from one node containing a simple mesh to very complex scenes
that include multiple meshes, textures, animations, lights, etc. Using scene
graphs makes it easier to break a scene into logical parts and create groups
for different parts of an application. Having a scene graph built into the
API also eases the integration with models built using 3-D modeling tools.
A complete scene graph must include the World
,
which is the top of the hierarchy, and a Camera
. Normally
it will also include a Background
, Light
s
if necessary, and Mesh
es of the scene. Animations can
also be included in the scene graph associated with different Node
s.
They can be advanced individually or all at once by calling the animate
method
in the top World
object of the scene graph. It is also
possible to build a partial scene graph using Group
and SkinnedMesh
nodes.
The class Object3D
is the parent of all the classes
that can be part of the 3-D world. An important property of Object3D
is
the userID
, which can be used to find individual objects
in a complex graph. Third-party modeling tools can set this userID
so
that the designer and programmer can easily work in the same object. Object3D
also
includes support for animations, with methods to add and remove AnimationTrack
s
and to advance the animations.
The scene graph itself is composed by Node
objects,
which include the classes Camera
, Mesh
(including SkinnedMesh
and MorphingMesh
), Sprite3D
, and Light
. A Node
is
the type of object commonly manipulated in an application. The rendering and
picking of nodes can be enabled or disabled individually. Node
s
can also be manipulated with the usual translation, rotation, and scaling
transformations. Besides the userID
, Node
s
can have a scopeID
, which can be used to group objects
across different parts of a scene graph for lighting and picking purposes.
A Mesh
is a 3-D geometrical object displayed in
a scene. A mesh normally includes the positions of the vertices, colors, and
normals, as well as texture coordinates. It also includes information about
the edges between vertices. The rendering of Mesh
es is
regulated by their Appearance
. This comprises several
properties such as material attributes, textures, compositing mode, etc. A Mesh
is
lit only when its Appearance
contains a Material definition.
Developers can set this to null to enabled and disable lighting for a particular
object.
Node
s are put together in Group
s. Group
s
include the ability to perform a picking
operation among
the nodes in the group. The World
is also a Group
,
with the extra properties as indicated above.
A good way to see a scene graph is by making a diagram of it. The figure in section Implementation of the Scene Graph shows how the scene graph looks in the Maze3D game.