Graphics Reference
In-Depth Information
primitives are inserted into the primitive list, and the list is set to be the primitive
of
m
_
Body
at label D. The left and right arms are allocated at label E and set to be
the children of
m
_
Body
at label F. In this way, the scene node hierarchy (or simply
the scene) is constructed. The entire scene hierarchy is drawn when we invoke the
SceneNode::Draw()
routine of the
m
_
Body
object. In this case, the primitives of
the
Body
node (e.g.,
R
b
0
) will be transformed by
M
db
:
M
db
=
M
b
M
V
M
P
.
(11.4)
The primitives of the left
Arm
(e.g.,
R
a
0
) will be transformed by
M
dla
:
Right
Arm
/
Palm
.
Correspond-
ingly, primitives of the right
Arm
/
Palm
will be transformed
by
M
dla
=
M
la
M
b
M
V
M
P
,
(11.5)
whereas the primitives of the left
Palm
(e.g.,
R
p
0
) will be transformed by
M
dlp
:
M
ra
M
b
M
V
M
P
and
M
dlp
=
.
M
lp
M
la
M
b
M
V
M
P
(11.6)
M
rp
M
ra
M
b
M
V
M
P
.
The
SceneTreeControl
user interface construct allows the user select one of the
M
b
,
M
rp
,
M
ra
,
M
lp
,or
M
la
transformations for interactive manipulation. In this
way, the user can have independent control of each of the components in the scene
hierarchy.
This tutorial presents a straightforward extension to Tutorial 11.5 in building
a scene tree with the
SceneNode
class. Through working with the
SceneTree
Control
GUI container, the user can select any of the five scene nodes and control
the selected transformation operator. In addition, the user can select any of the
primitives in the selected scene node to interactively adjust the attributes of the
selected primitive.
M
b
C
b0
R
b1
Body
11.3.1
Instancing: Scene Graph
M
la
M
ra
Left
Arm
Right
Arm
Instancing
From Figures 11.13 and 11.14, we can observe that the scene hierarchies under
the left and the right arms are identical. Indeed, in Listing 11.11, the two arms are
implemented based on the same
CArm
class. For efficiency purposes, it is logical
to examine the possibilities of sharing the
CArm
object, that is, implement the two
arms based on sharing the memory of one instance of the
CArm
object.
M
a
R
a2
R
a0
R
a1
Arm
M
p
C
p0
R
p1
Palm
Figure 11.15.
In-
stancing: sharing of scene
nodes.
Sharing of Scene Node Hierarchy
Figure 11.15 shows a straightforward approach to sharing an instance of the
CArm
hierarchy. Notice that in order to retain the independent control over the two sep-
arate arms, the
CArm
object must have two separate parents with two independent
Search WWH ::
Custom Search