Graphics Reference
In-Depth Information
Label E in Listing 11.5 shows that in this case, drawing of the entire arm can
be accomplished by simply calling the
m
_
scene.Draw()
function. From List-
ing 11.4, we know that the
SceneNode::Draw()
routine does the following.
•
C.
Concatenates
M
a
with the top of matrix stack and loads the top of matrix
stack to the
WORLD
matrix.
•
D.
Draws
R
a
0
; with
M
a
loaded in the
WORLD
matrix, the triangles of
R
a
0
are
transformed according to Equation (11.2).
•
E.
Invokes the child node
Draw()
function with
M
a
on the top of the matrix
stack. In this case, the child node concatenates
M
p
with
M
a
, loads the
result to the
WORLD
matrix processor, and draws
C
p
0
. With the concatenated
results of
M
p
and
M
a
on the top of the matrix stack, the triangles of
C
p
0
are
transformed according to Equation (11.3).
In this way, although with very different implementations, Tutorials 11.2 and 11.3
behave in identical manners. This tutorial demonstrates that the
SceneNode
class
is convenient for building and controlling graphical objects with independently
transformable components.
Notice that the identifiable and controllable “graphical objects” (e.g., the arm,
or the palm) are usually associated with
SceneNode
objects. Recall that at label
E of Listing 11.3, the
SceneNode
class has a
m
_
Name
instance variable reserved
for naming of individual components in an object.
Tutorial 11.4. Subclassing from the
SceneNode
Class
Tutorial 11.4.
Project Name:
D3D
_
SceneNodeArm
Library Support:
UWB
_
MFC
_
Lib1
UWB
_
D3D
_
Lib11
•
Goal.
Demonstrate different ways of working with the
SceneNode
class,
including design reuse.
•
Approach.
Show a different approach to implementing the arm/palm hier-
archy from Tutorial 11.3 with the same
SceneNode
class.
Tutorial 11.4 runs and behaves identically to Tutorial 11.3. In this case, we sub-
class from
SceneNode
to create individual classes for the arm and the palm ob-
jects. Listing 11.6 shows the
CPalm
class, a general palm object designed to be
attached to the arm object of Figure 11.3. Taking advantage of the functionality
defined by the
SceneNode
class, the
CPalm
class only needs to define the con-
structor (at label A). The first parameter of the constructor, the
vec3 at
position,
defines the location of the palm object. This is to ensure that it is possible to define
and attach a
CPalm
object to an arm object at any location. In the implementation
Search WWH ::
Custom Search