Graphics Reference
In-Depth Information
class UWB _ SceneNode {
Source file.
uwbgl _ SceneNode1.h file
in the Common Files/ Sce-
neNode
public :
// constructor/destructor and the set/access methods for:
// Primitives/XformInfo/Children/Velocity/Name ... etc.
subfolder
of
the
UWBGL _ D3D _ Lib11 project.
// draws all primitives and children nodes
void Draw(eLevelOfDetail, UWB _ DrawHelper&) const ;
.
protected :
// Geometric primitives of the graphics object
A : UWB _ Primitive * m _ pPrimitive;
// Children nodes (components)
B : UWB _ PointerArray<UWB _ SceneNode * >m _ child _ nodes;
// This operator computes: M cn
C : UWB _ XformInfo m _ xform;
// Velocity of the node (updates m _ xform->m _ translation)
D : vec3 m _ velocity;
// Optional name of this node: for GUI support
E : std::string m _ Name;
};
Listing 11.3. The UWB _ SceneNode class definition.
Listing 11.4 shows the two important aspects of the implementation of the SceneNode
class:
1. Memory management. The destructor at label A shows that the SceneNode
class expects that the memory associated with the m _ pPrimitive refer-
ence is allocated from the heap (via the new() operation). Notice that the
SceneNode class does not make assumptions with respect to the references
in the m _ child _ node array. It is the responsibility of the programmer to
delete() child nodes that are allocated on the heap.
2. Transformation operator concatenation. The Draw() function shows
how the transformation operator is concatenated with the top of the matrix
stack ( M t ) to control the geometric primitives, where at label:
B. The top of the matrix stack, M t , is pushed and duplicated. At this
point, we know that the top two entries on the matrix stack are M t 1
and M t , and we know that these two matrices are the same.
Search WWH ::




Custom Search