SCENE GRAPH
Scene Graphs
- Basic building block used to create three-dimensional scene databases in
Inventor
- Each node is an object that holds a piece of information,
such as a surface material, shape description, geometric transformation,
light,or camera
- All 3D shapes, attributes, cameras, and light sources present
in a scene are represented as nodes
- Each node is composed of a set of data elements, known as fields,
that describe the parameters of the node
Nodes are divided into three basic categories
- Shape nodes, which represent 3D geometric objects
- Property nodes, which represent appearance and other qualitative
characteristics of the scene
- Group nodes, which are containers that collect nodes into graphs
Nodes may contain data elements within fields. Each field
within a node is also a class, rather than a basic data type; for
example, if a node needed to contain a single floating point value, it
would have an SoSFFloat field data member rather than just a float, as
in a C data structure.
There are two main reasons for doing this:
- All field types have consistent set and get functions; the interface
to get the value stored in a field is consistent over all field types.
- Because of these set and get functions, a node can tell when the value
of a field stored within it has changed, and can automatically notify the
application; for example, it could (and usually does) automatically
rerender the scene.
Upon first inspection, the names of Inventor classes seem
strange: they all have either an "So" or "Sb" prefix. The difference
between them is important. "So" stands for scene object, and
data types with this prefix are usually related to the scene graph;
for example, all nodes have an "So" prefix. "Sb" stands for scene
basic, and refers to basic data types such as vectors, matrices,
and colors.
Some of the more important Sb types are as follows:
- SbBool: defines a boolean value. In Scheme this type is an integer
which is 1 when true and 0 when false.
- SbColor: defines a RGB (red, green, blue) color.
- SbMatrix: 4x4 matrix.
- SbVecnx: 2D or 3D vector. n is the number of elements in the
vector (2, 3, or 4); x is the type of element (f for float, s for
short integer).
- A container for collecting child objects
- Collect property, shape, and other group nodes into graphs
- Consists of one or more nodes
- Hierarchical scenes are created by adding nodes as children of grouping
nodes
- Consists of information representing one or more 3D scenes
- Can contain several scene graphs
Scene Graph Showing Nodes Used to Create a Robot
Rendered Image of the Robot
#Inventor V2.0 ascii
Separator {
Separator { # Body
Transform { translation 0 3 0 }
Material { # A bronze color:
ambientColor .33 .22 .27
diffuseColor .78 .57 .11
specularColor .99 .94 .81
shininess .28
}
Cylinder { radius 2.5 height 6 }
}
Separator { # Head
Transform { translation 0 7.5 0 }
Material { # A silver color:
ambientColor .2 .2 .2
diffuseColor .6 .6 .6
specularColor .5 .5 .5
shininess .5
}
Sphere { }
}
}
The Scene Graph in Open Inventor File Format