AI_SDB_SpatialElements.h
Go to the documentation of this file.00001 #ifndef AI_SDB_SPATIALELEMENT_H
00002 #define AI_SDB_SPATIALELEMENT_H
00003
00004
00005 #include "AI_SDB_VisitorBase.h"
00006 #include "../utils/AI_Ref.h"
00007
00008
00009 class AI_SDB_SpatialSector;
00010
00011
00032 class AI_SDB_SpatialElement
00033 {
00034 public:
00035 enum {
00036
00037 N_SPATIAL_PORTAL = (1<<0),
00038 N_SPATIAL_HIERARCHY = (1<<1),
00039 N_SPATIAL_OCCLUDER = (1<<2),
00040 N_SPATIAL_AABB = (1<<3),
00041 };
00042 typedef int AI_SDB_SpatialElementType;
00043
00044 AI_SDB_SpatialElement(AI_SDB_SpatialElementType starttype=0) : m_spatialtype(starttype), m_AABB(), m_ptr(NULL) {};
00045 AI_SDB_SpatialElement(AI_SDB_SpatialElementType starttype, const AI_BBox &initbbox)
00046 : m_spatialtype(starttype | N_SPATIAL_AABB), m_AABB(initbbox), m_ptr(NULL) { };
00047 virtual ~AI_SDB_SpatialElement() { }
00048
00049 AI_SDB_SpatialElementType GetSpatialType() const { return m_spatialtype; }
00050
00052 bool HasOccluder() const { return (m_spatialtype & N_SPATIAL_OCCLUDER) != 0; }
00053
00055 bool HasAABB() const { return (m_spatialtype & N_SPATIAL_AABB) != 0; }
00056 AI_BBox GetAABB() const { return m_AABB; }
00057 void SetAABB(const AI_BBox &newbbox) { m_AABB=newbbox; }
00058
00059 void *GetPtr() const { return m_ptr; }
00060 void SetPtr(void *ptr) { m_ptr = ptr; }
00061
00067 virtual void Accept(AI_SDB_VisibilityVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00068 virtual void Accept(AI_SDB_SpatialVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00069 virtual void Accept(AI_SDB_OcclusionVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00070
00071 protected:
00072 int m_spatialtype;
00073 AI_BBox m_AABB;
00074 void *m_ptr;
00075 };
00076
00103 class AI_SDB_BBoxSpatialElement : public AI_SDB_SpatialElement
00104 {
00105 public:
00106 AI_SDB_BBoxSpatialElement(AI_SDB_SpatialElementType t, const AI_BBox &initialspace) : AI_SDB_SpatialElement(t | N_SPATIAL_AABB, initialspace) { }
00107 AI_SDB_BBoxSpatialElement(const AI_BBox &initialspace) : AI_SDB_SpatialElement(N_SPATIAL_AABB, initialspace) { }
00108 ~AI_SDB_BBoxSpatialElement();
00109
00110 void UpdateBBox(const AI_BBox &newbox) { m_AABB = newbox; }
00111
00112 virtual void Accept(AI_SDB_VisibilityVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00113 virtual void Accept(AI_SDB_SpatialVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00114 virtual void Accept(AI_SDB_OcclusionVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00115
00116 protected:
00117 };
00118
00119
00137 class AI_SDB_SpatialPortalElement : public AI_SDB_BBoxSpatialElement {
00138 public:
00139 AI_SDB_SpatialPortalElement(const AI_BBox &initbbox, AI_SDB_SpatialSector *parentsector, AI_SDB_SpatialSector *connecttosector) :
00140 AI_SDB_BBoxSpatialElement(N_SPATIAL_PORTAL, initbbox), m_parentsector(parentsector), m_otherside(connecttosector)
00141 {
00142 }
00143
00144 ~AI_SDB_SpatialPortalElement() {
00145 }
00146
00147 virtual void Accept(AI_SDB_VisibilityVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00148 virtual void Accept(AI_SDB_SpatialVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00149 protected:
00150 AI_Ref<AI_SDB_SpatialSector> m_parentsector, m_otherside;
00151 };
00152
00153
00154
00177 class AI_SDB_SpatialHierarchyElement : public AI_SDB_SpatialElement {
00178 public:
00179
00180 AI_SDB_SpatialHierarchyElement() : AI_SDB_SpatialElement(AI_SDB_SpatialElement::N_SPATIAL_HIERARCHY)
00181 {
00182 }
00183 ~AI_SDB_SpatialHierarchyElement() {
00184 }
00185
00186
00187
00188 protected:
00189 };
00190
00191
00206 class AI_SDB_SpatialOccluderElement : public AI_SDB_BBoxSpatialElement
00207 {
00208
00209 public:
00210 AI_SDB_SpatialOccluderElement(const AI_BBox &box)
00211 : AI_SDB_BBoxSpatialElement(AI_SDB_SpatialElement::N_SPATIAL_OCCLUDER, box) { }
00212
00213 virtual ~AI_SDB_SpatialOccluderElement() {
00214 }
00215
00216 void Accept(AI_SDB_OcclusionVisitor &visitor, int recursiondepth, AI_SDB_VisitorFlags flags);
00217
00218 protected:
00219 };
00220
00221 #endif