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 __NESCENENODE_H
00028 #define __NESCENENODE_H
00029
00030
00037 #include "base.h"
00038 #include "hierarchynode.h"
00039 #include "updateentity.h"
00040 #include "renderentity.h"
00041 #include "boundingvolume.h"
00042
00043 #include <vector>
00044 #include <string>
00045
00046
00047 namespace NeoEngine
00048 {
00049
00050
00051
00052 class SceneEntity;
00053 class Room;
00054
00055
00056 #ifdef WIN32
00057
00058 # ifdef _MSC_VER
00059 # pragma warning( disable : 4231 )
00060 # endif
00061
00062 # ifndef __HAVE_VECTOR_NESCENENODE
00063 UDTVectorEXPIMP( class SceneNode* );
00064 # define __HAVE_VECTOR_NESCENENODE
00065 # endif
00066
00067 # ifdef _MSC_VER
00068 # ifndef __HAVE_NEHIERARCHYNODE_NESCENENODE
00069 EXPIMP_TEMPLATE template class NEOENGINE_API HierarchyNode< class SceneNode >;
00070 # define __HAVE_NEHIERARCHYNODE_NESCENENODE
00071 # endif
00072 # endif
00073
00074 #endif
00075
00076
00093 class NEOENGINE_API SceneNode : public virtual UpdateEntity, public virtual RenderEntity, public HierarchyNode<SceneNode>
00094 {
00095 public:
00096
00097 DefineVisitable();
00098
00099
00100 protected:
00101
00103 SceneEntity *m_pkEntity;
00104
00106 BoundingVolume *m_pkBoundingVolume;
00107
00109 bool m_bNeedVolumeUpdate;
00110
00112 bool m_bIgnoreVolumeUpdate;
00113
00114
00119 virtual bool UpdateWorld();
00120
00125 virtual bool UpdateVolume();
00126
00131 inline virtual SceneNode *Get() { return this; }
00132
00133
00134 public:
00135
00137 Room *m_pkRoom;
00138
00140 bool m_bIgnoreVolume;
00141
00142
00150 SceneNode( const HashString &rstrName = "", SceneNode *pkParent = 0, BoundingVolume::BOUNDINGVOLUMETYPE eVolume = BoundingVolume::BV_AABB );
00151
00157 SceneNode( SceneNode &rkNode, bool bDuplicateChildren = true );
00158
00162 virtual ~SceneNode();
00163
00171 inline virtual void NotifyUpdate( bool bRecurse = true ) { HierarchyNode<SceneNode>::NotifyUpdate( bRecurse ); NotifyVolumeUpdate( bRecurse ); }
00172
00179 inline virtual void NotifyVolumeUpdate( bool bRecurse = true ) { m_bNeedVolumeUpdate = true; if( !bRecurse || !m_pkParent || m_bIgnoreVolumeUpdate ) return; m_pkParent->NotifyVolumeUpdate( true ); }
00180
00186 virtual void Update( float fDeltaTime );
00187
00194 virtual bool Render( Frustum *pkFrustum = 0, bool bForce = false );
00195
00200 inline BoundingVolume *GetBoundingVolume() { if( m_bWorldUpdate ) UpdateWorld(); if( m_bNeedVolumeUpdate ) UpdateVolume(); return m_pkBoundingVolume; }
00201
00206 void SetBoundingVolume( BoundingVolume *pkVolume );
00207
00212 inline SceneEntity *GetEntity() { return m_pkEntity; }
00213
00220 void SetEntity( SceneEntity *pkEntity, bool bDeleteOld = true );
00221
00226 void PrintHierarchy( unsigned int uiLevel = 0 );
00227
00232 virtual SceneNode *Duplicate();
00233
00238 virtual void TraverseNode( BaseVisitor &rkVisitor );
00239
00246 virtual bool Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0 );
00247
00254 virtual bool Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 );
00255 };
00256
00257
00258 };
00259
00260
00261 #endif