Graphics Reference
In-Depth Information
F. The concatenated top of matrix stack M t 2 is popped off, thus restor-
ing the original M t as the top of the matrix stack. In this way, the
matrix stack is unchanged before and after this drawing routine.
Notice that the nodes and the matrices are concatenated in order, where the current
node is always processed before that of the child nodes. In addition, the above
drawing routine traverses the hierarchy in a depth-first manner. The depth-first in-
order traversal of the Draw() routine is hard-coded; the routine does not support
run-time re-configuration of traversal order. This fixed traversal implies a fixed
drawing sequence where children's primitives are always drawn after those from
the parents. As a result, children's primitives always cover those of parents'. This
is a limitation of the SceneNode class.
In computer graphics, a scene node typically refers to the combination of a
transformation operator with its associated primitives, or simply the functionality
of our SceneNode class. An interconnected hierarchy of scene nodes is typically
referred to as a scene tree. When sharing of scene nodes is allowed, the scene tree
can be generalized to a scene graph.
In the rest of this section, we study scene nodes by examining how to work
with the SceneNode class. We will examine building hierarchical models with
scene nodes and including multiple primitives in each scene node. Scene trees/-
graphs will be examined in more detail in the next section.
Tutorial 11.3. Working with the SceneNode Class
Tutorial 11.3.
Project Name:
D3D _ SceneNode
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib11
Goal. Gain insight and understanding of how to work with the SceneNode
class.
Approach. Implement the arm/palm hierarchy from Tutorial 11.2 based on
the SceneNode class.
m_Scene (arm)
Tutorial 11.3 runs and behaves identically to Tutorial 11.2. The only differences
between these two tutorials are in the implementation of the arm and the palm
graphical objects. The top portion of Listing 11.5 shows that the definition of
the CModel class is mostly similar to that of Tutorial 11.2. The exception here is
that at label A, the m _ scene SceneNode object replaces the rectangle, circle, and
XformInfo objects. During the construction of the CModel object, at labels B, C,
and D, a SceneNode hierarchy that corresponds to the illustration of Figure 11.6
is constructed. At label B, the memory of R a 0 ( pRectangle ) is allocated and
geometric information is initialized and set to be referenced by m _ pPrimitive
XformInfo
Velocity
PrimitiveList
Child SN
M a
R a0
pChildNode
(palm)
XformInfo
Velocity
PrimitiveList
Child SN
M p
C p0
Figure 11.6.
The
SceneNode structure
of
Tutorial 11.3.
Search WWH ::




Custom Search