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

hierarchynode.h

Go to the documentation of this file.
00001 /***************************************************************************
00002            hierarchynode.h  -  Base classes for hierarchy objects
00003                              -------------------
00004     begin                : Sun Jan 26 2003
00005     copyright            : (C) 2003 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, hierarchynode.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2003
00023  Reality Rift Studios. All Rights Reserved.
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

Generated on Wed Jan 21 14:21:06 2004 for NeoEngine by doxygen 1.3.5