Graphics Reference
In-Depth Information
transformation operators. To satisfy this requirement, two new scene nodes are
introduced in Figure 11.15 (
LeftArm
and
RightArm
) parenting the shared
CArm
instance. Recall from Listing 11.4 that the
SceneNode::Draw()
routine performs
in-roder depth-first matrix concatenation. In this case, for the
LeftArm
,
M
b
M
la
M
ra
M
a
M
p
.
Trans-
formation operators of the
Base
,
LeftArm
,
RightArm
,
Arm
,and
Palm
nodes, respec-
tively.
M
l
1
=
M
a
M
la
M
b
,
M
l
2
=
M
p
M
a
M
la
M
b
,
where
M
l
1
is the transformation matrix for drawing of primitives in the
Arm
node
(e.g.,
R
a
0
)and
M
l
2
is for the primitives of the
Palm
node (e.g.,
C
p
0
).
For the
RightArm
,
M
r
1
=
M
a
M
ra
M
b
,
M
p
M
a
M
ra
M
b
.
Notice that although there is only one instance of the
CArm
node, the primitives of
this node will be drawn twice, once for each of the
LeftArm
and
RightArm
parent.
Because each time the primitives will be drawn with different matrices,
M
l
1
and
M
l
2
versus
M
r
1
and
M
r
2
, the primitives will appear in different locations with
distinct orientations. In this way, by drawing the scene node twice, we can create
the illusion of two distinct objects (the two arms) in the application window.
When a user manipulates the
LeftArm
transformation operator (
M
la
), only
M
l
1
and
M
l
2
are affected, and thus only the primitives drawn associated with the
left arm will be affected. In this way, by manipulating the
LeftArm
(
M
la
)and
RightArm
(
M
ra
) transformation operators, the user can control the left and right
arms independently.
When implementing instancing by sharing of scene node hierarchy, there is
no
straightforward way of supporting independent control over components in-
side the hierarchy. For example, in our case, the
CArm
hierarchy is shared, and
an example of an “independently controllable component” in the hierarchy is the
Palm
object. Notice that the transformation operator for controlling the
Palm
,
M
p
, is shared between the left and the right arms. This is verified from the fact
that the transformation operators for the left palm (
M
l
2
) and the right palm (
M
r
2
)
do not include dedicated transformation operators for controlling the primitives
associated with the left and right palms. Without separate transformation opera-
tors, the user will not be able to control the two palms independently. In this case,
if the user manipulates the
M
p
operator, in the application window the palms on
both arms will change in an identical manner!
Supporting instancing by sharing scene node hierarchy is only viable when the
instances do not change, or when all instances behave in exactly the same manner.
Examples of instances that do not change would include stationary objects, e.g.,
identical tables/chairs. These objects can be highly complex with definitions that
M
r
2
=
Search WWH ::
Custom Search