00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEHIERARCHYNODE_H
00028 #define __NEHIERARCHYNODE_H
00029
00030
00038 #include "base.h"
00039 #include "node.h"
00040 #include "hashstring.h"
00041 #include "visitor.h"
00042
00043 #include <assert.h>
00044
00045 #include <vector>
00046
00047
00048 namespace NeoEngine
00049 {
00050
00051
00061 template <class NodeType> class HierarchyNode : public virtual BaseVisitable, public SRTNode
00062 {
00063 public:
00064
00065 DefineVisitable()
00066
00067
00071 enum NODESEARCHMODE
00072 {
00074 BREADTH_FIRST,
00075
00077 DEPTH_FIRST
00078 };
00079
00080
00081
00082 protected:
00083
00085 bool m_bWorldUpdate;
00086
00088 float m_fWorldScaling;
00089
00091 Quaternion m_kWorldRotation;
00092
00094 Vector3d m_kWorldTranslation;
00095
00097 std::vector< NodeType* > m_vpkChildren;
00098
00100 NodeType *m_pkParent;
00101
00103 HashString m_strName;
00104
00106 Matrix m_kWorldTransform;
00107
00109 Matrix m_kInverseWorldTransform;
00110
00111
00112
00117 inline virtual bool UpdateWorld();
00118
00123 inline virtual NodeType *Get();
00124
00125
00126
00127 public:
00128
00135 inline HierarchyNode( const HashString &rstrName = "", NodeType *pkParent = 0 );
00136
00142 inline HierarchyNode( NodeType &rkNode, bool bDuplicateChildren );
00143
00147 virtual ~HierarchyNode();
00148
00155 inline virtual void SetTranslation( const Vector3d &rkTranslation, bool bNotifyUpdate = true );
00156
00163 inline virtual void SetRotation( const Quaternion &rkRotation, bool bNotifyUpdate = true );
00164
00171 inline virtual void SetScaling( float fScaling, bool bNotifyUpdate = true );
00172
00177 inline void SetName( const HashString &rstrName );
00178
00182 inline const HashString &GetName() const;
00183
00187 inline NodeType *GetParent();
00188
00200 virtual int AttachNode( NodeType *pkNode, bool bKeepWorldSRT = false );
00201
00207 virtual int DetachNode( NodeType *pkNode );
00208
00214 void DetachFromParent();
00215
00223 inline virtual void NotifyUpdate( bool bRecurse = true );
00224
00230 inline const Vector3d &GetWorldTranslation();
00231
00237 inline const Quaternion &GetWorldRotation();
00238
00244 inline float GetWorldScaling();
00245
00251 inline const Matrix &GetWorldTransform();
00252
00258 inline const Matrix &GetInverseWorldTransform();
00259
00264 inline const std::vector< NodeType* > &GetChildren();
00265
00274 NodeType *GetByName( const HashString &rstrName, NODESEARCHMODE eMode = BREADTH_FIRST, bool bInitSearch = true );
00275
00283 virtual void Traverse( BaseVisitor &rkVisitor, NODESEARCHMODE eMode = DEPTH_FIRST, int iDirection = 1, bool bInitSearch = true );
00284
00289 inline virtual void TraverseNode( BaseVisitor &rkVisitor );
00290 };
00291
00292
00293
00294 #include "hierarchynode_inl.h"
00295
00296
00297 };
00298
00299
00300 #endif