Graphics Reference
In-Depth Information
UWB _ SceneNode::~UWB _ SceneNode
// Destructor
if (m _ pPrimitive)
// Releasing memory => m _ pPrimitive must be allocated on the Heap!
delete m _ pPrimitive;
m _ pPrimitive = NULL;
A:
void UWB _ SceneNode::Draw(eLevelOfDetail lod, UWB _ DrawHelper& draw _ helper) const
// duplicate the top of the matrix stack ( M t 1 = M t )
draw _ helper.PushModelTransform();
// M t 2 =
B:
M t 2
C: m _ xform.SetUpModelStack(draw _ helper);
D: if (m _ pPrimitive)
// Draw the primitives of this node
m _ pPrimitive->Draw( lod, draw _ helper );
// Draw all the children nodes
E: for ( int i=0; i<m _ child _ nodes.Count(); i++)
m _ child _ nodes[i]->Draw(lod, draw _ helper);
// Pop off the current top of stack (pop off M t 2 )
M sn M t 1 and M W =
draw _ helper.PopModelTransform();
.
F:
Source file.
uwbgl _ SceneNode1.cpp
file in the Common Files/
SceneNode subfolder
Listing 11.4. The UWB _ SceneNode class implementation.
of
the
UWBGL _ D3D _ Lib11 project.
C. The transformation operator m _ xform ( M cn ) is concatenated with
the current top of the matrix stack, such that the new top of the matrix
stack becomes
M t 2 =
M sn M t 1 .
In addition, this new top of the matrix stack M t 2 is loaded into the
WORLD matrix processor ( M W ).
D. The geometric primitives referenced by m _ pPrimitive are drawn
where all these primitives will be transformed by the M t 2 matrix that
was loaded in the WORLD matrix processor.
E. The child nodes are invoked to draw themselves. Because the cur-
rent top of the matrix stack M t 2 is concatenated with the M cn matrix
of this node, all geometric primitives of child nodes will be affected by
this transformation operator. In this way, this invoking node becomes
the parent node. We will examine this hierarchical transformation
concatenation in more detail in Tutorial 11.3.
Search WWH ::




Custom Search