Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

HierarchyNode Class Template Reference

#include <hierarchynode.h>

Inheritance diagram for HierarchyNode:

Inheritance graph
[legend]
Collaboration diagram for HierarchyNode:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class NodeType>
class NeoEngine::HierarchyNode< NodeType >

Base class for node hierarchies A hierarchy node is the building block of a node tree. Derived from the SRT node for basic capabilities, extended with hierarchy data (one parent, mutliple children). World data is cached and updated when needed by overloading SRT node methods and flagging for invalid caches.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  NODESEARCHMODE { BREADTH_FIRST, DEPTH_FIRST }
 Search mode identifiers. More...


Public Member Functions

 HierarchyNode (const HashString &rstrName="", NodeType *pkParent=0)
 HierarchyNode (NodeType &rkNode, bool bDuplicateChildren)
virtual ~HierarchyNode ()
virtual void SetTranslation (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
virtual void SetRotation (const Quaternion &rkRotation, bool bNotifyUpdate=true)
virtual void SetScaling (float fScaling, bool bNotifyUpdate=true)
void SetName (const HashString &rstrName)
const HashStringGetName () const
NodeType * GetParent ()
virtual int AttachNode (NodeType *pkNode, bool bKeepWorldSRT=false)
virtual int DetachNode (NodeType *pkNode)
void DetachFromParent ()
virtual void NotifyUpdate (bool bRecurse=true)
const Vector3dGetWorldTranslation ()
const QuaternionGetWorldRotation ()
float GetWorldScaling ()
const MatrixGetWorldTransform ()
const MatrixGetInverseWorldTransform ()
const std::vector< NodeType * > & GetChildren ()
NodeType * GetByName (const HashString &rstrName, NODESEARCHMODE eMode=BREADTH_FIRST, bool bInitSearch=true)
virtual void Traverse (BaseVisitor &rkVisitor, NODESEARCHMODE eMode=DEPTH_FIRST, int iDirection=1, bool bInitSearch=true)
virtual void TraverseNode (BaseVisitor &rkVisitor)
virtual void Accept (BaseVisitor &rkVisitor)=0
const Vector3dGetTranslation () const
const QuaternionGetRotation () const
float GetScaling () const
void Translate (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
void TranslateWorld (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
void Rotate (const Quaternion &rkRotation, bool bNotifyUpdate=true)
void RotateWorld (const Quaternion &rkRotation, bool bNotifyUpdate=true)
void Scale (float fScaling, bool bNotifyUpdate=true)

Protected Member Functions

virtual bool UpdateWorld ()
virtual NodeType * Get ()

Static Protected Member Functions

template<class NodeType> void AcceptImpl (NodeType &rkVisited, BaseVisitor &rkVisitor)

Protected Attributes

bool m_bWorldUpdate
float m_fWorldScaling
Quaternion m_kWorldRotation
Vector3d m_kWorldTranslation
std::vector< NodeType * > m_vpkChildren
NodeType * m_pkParent
HashString m_strName
Matrix m_kWorldTransform
Matrix m_kInverseWorldTransform
float m_fScaling
Quaternion m_kRotation
Vector3d m_kTranslation


Member Enumeration Documentation

enum NODESEARCHMODE
 

Search mode identifiers.

Enumeration values:
BREADTH_FIRST  Search breadth first, i.e all child nodes first before recursing on grandchildren
DEPTH_FIRST  Search depth first, i.e recurse on grandchildren before searching next child node


Constructor & Destructor Documentation

HierarchyNode const HashString rstrName = "",
NodeType *  pkParent = 0
[inline]
 

Create named, attached node. Will initially have same world position as parent (i.e zero relative rotation and translation, no scaling)

Parameters:
rstrName Node name
pkParent Parent node

HierarchyNode NodeType &  rkNode,
bool  bDuplicateChildren
[inline]
 

Create node from reference object (including duplicating child nodes if flag set)

Parameters:
rkNode Reference node object to copy
bDuplicateChildren Duplicate child nodes if true

~HierarchyNode  )  [inline, virtual]
 

Deallocates child nodes and detaches from parent


Member Function Documentation

bool UpdateWorld  )  [inline, protected, virtual]
 

Updates cached world-relative SRT data if needed

Returns:
true if any world cache data was updated, false if not

Reimplemented in SceneNode.

NodeType * Get  )  [inline, protected, virtual]
 

Used to get this as correct type

Returns:
This node

Reimplemented in SceneNode.

void SetTranslation const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, virtual]
 

Set position relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
rkTranslation New translation relative parent node
bNotifyUpdate Set update flag to child tree for world SRT data and parent tree for bounding volume (true default, use false with caution)

Reimplemented from SRTNode.

void SetRotation const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, virtual]
 

Set rotation relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
rkRotation New rotation relative parent node
bNotifyUpdate Set update flag to child tree for world SRT data (true default, use false with caution)

Reimplemented from SRTNode.

void SetScaling float  fScaling,
bool  bNotifyUpdate = true
[inline, virtual]
 

Set uniform scaling relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
fScaling Uniform scaling factor
bNotifyUpdate Set update flag to child tree for world SRT data (true default, use false with caution)

Reimplemented from SRTNode.

void SetName const HashString rstrName  )  [inline]
 

Set name

Parameters:
rstrName New node name

const HashString & GetName  )  const [inline]
 

Returns:
Node name

NodeType * GetParent  )  [inline]
 

Returns:
Parent node

int AttachNode NodeType *  pkNode,
bool  bKeepWorldSRT = false
[inline, virtual]
 

Attach node. If the node is attached to a parent, detach it first. This will cause the node to get it's world SRT data as local SRT data. If bKeepWorldSRT is set, node will be updated with inverse of this (new parent) node's SRT data, effectively keeping it intact in world space. If flag not set, node will effectivaly get new parent world SRT data added to own (used in initialization phase, for example).

Parameters:
pkNode Node to attach
bKeepWorldSRT If true, recalculate node relative position to maintain world SRT
Returns:
undefined (reserved for future use or derived classes)

Reimplemented in Room.

int DetachNode NodeType *  pkNode  )  [inline, virtual]
 

Detach node. The node will store world SRT data in local SRT data.

Parameters:
pkNode Node to detach
Returns:
undefined (reserved for future use or derived classes)

Reimplemented in Room.

void DetachFromParent  )  [inline]
 

Detach this node from parent, if any. Will store world SRT data (and update first if needed) in local SRT data to remain in same world position and orientation.

void NotifyUpdate bool  bRecurse = true  )  [inline, virtual]
 

Set world update flag. If flag is set, a call to any of the GetWorldScaling, GetWorldRotation, GetWorldTranslation will cause world cache data to be updated. Optionally recurses on all child nodes (default).

Parameters:
bRecurse Recurse on children

Reimplemented in BoneAdaptor, and SceneNode.

const Vector3d & GetWorldTranslation  )  [inline]
 

Get position relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World position

const Quaternion & GetWorldRotation  )  [inline]
 

Get rotation relative world unrotated coordinate system. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World-relative quaternion

float GetWorldScaling  )  [inline]
 

Get total unform scaling factor relative world scale. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World scaling factor

const Matrix & GetWorldTransform  )  [inline]
 

Get total transform matrix relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World transform matrix

const Matrix & GetInverseWorldTransform  )  [inline]
 

Get inverse total transform matrix relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
Inverse world transform matrix

const std::vector< NodeType * > & GetChildren  )  [inline]
 

Get all child nodes

Returns:
Children node vector

NodeType * GetByName const HashString rstrName,
NODESEARCHMODE  eMode = BREADTH_FIRST,
bool  bInitSearch = true
[inline]
 

Search hierarchy for named node, including this node. Will return first node found along selected search mode.

Parameters:
rstrName Node name to search for
eMode Search mode (see enum descriptions for details)
bInitSearch Internal flag
Returns:
Ptr to node or null if not found

void Traverse BaseVisitor rkVisitor,
NODESEARCHMODE  eMode = DEPTH_FIRST,
int  iDirection = 1,
bool  bInitSearch = true
[inline, virtual]
 

Traverse the hierarchy applying the visitor to the nodes.

Parameters:
rkVisitor Visitor to apply to each node.
eMode Search mode (see enum descriptions for details)
iDirection Direction of traversal (for DEPTH_FIRST, > 0 means top-down, < 0 means bottom up)
bInitSearch Internal flag

void TraverseNode BaseVisitor rkVisitor  )  [inline, virtual]
 

Traverse this nodes

Parameters:
rkVisitor Visitor

Reimplemented in SceneNode.

void AcceptImpl NodeType &  rkVisited,
BaseVisitor rkVisitor
[inline, static, protected, inherited]
 

Accept visitors if implementation available

Parameters:
rkVisited Node being visited
rkVisitor Visitor

virtual void Accept BaseVisitor rkVisitor  )  [pure virtual, inherited]
 

Accept a visitor

Parameters:
rkVisitor Visitor

const Vector3d& GetTranslation  )  const [inline, inherited]
 

Returns:
Translation of this node

const Quaternion& GetRotation  )  const [inline, inherited]
 

Returns:
Rotation of this node

float GetScaling  )  const [inline, inherited]
 

Returns:
Uniform scaling factor

void Translate const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Translate node from current position, in local (along current rotated axes) coordinate system. Will call SetTranslation() for setting new translation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkTranslation Translation offset vector
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void TranslateWorld const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Translate node from current position, in world (along unrotated axes) coordinate system. Will call SetTranslation() for setting new translation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkTranslation Translation offset vector
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void Rotate const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Rotate node in local (current rotation) coordinate system. Will call SetRotation() for setting new rotation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkRotation Rotation quaternion
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void RotateWorld const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Rotate node in world (unrotated) coordinate system. Will call SetRotation() for setting new rotation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkRotation Rotation quaternion
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void Scale float  fScaling,
bool  bNotifyUpdate = true
[inline, inherited]
 

Scale node by uniform factor. Will use SetScaling for setting new scaling of node, derived classes do not need to overload this method directly. Must be >0, where a value of 1.0f indicates no scaling

Parameters:
fScaling Uniform scaling factor
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)


Member Data Documentation

bool m_bWorldUpdate [protected]
 

Flag indicating we need to update world relative SRT information

float m_fWorldScaling [protected]
 

Total scaling relative world (cached)

Quaternion m_kWorldRotation [protected]
 

Total rotation relative world (cached)

Vector3d m_kWorldTranslation [protected]
 

Total translation relative world (cached)

std::vector< NodeType* > m_vpkChildren [protected]
 

Child nodes

NodeType* m_pkParent [protected]
 

Parent node

HashString m_strName [protected]
 

Name

Matrix m_kWorldTransform [protected]
 

Total transformation matrix relative world (cached)

Matrix m_kInverseWorldTransform [protected]
 

Total inverse transformation matrix relative world (cached)

float m_fScaling [protected, inherited]
 

Uniform scaling factor (must be >0, default 1)

Quaternion m_kRotation [protected, inherited]
 

Rotation

Vector3d m_kTranslation [protected, inherited]
 

Translation


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:11 2004 for NeoEngine by doxygen 1.3.5