AI_SDB_GenArrayVisitors.h

Go to the documentation of this file.
00001 #ifndef AI_SDB_GENARRAYVISITORS_H
00002 #define AI_SDB_GENARRAYVISITORS_H
00003 
00004 // this file contains subclasses of the various visitors that take the found
00005 // nSpatialElements and put them into an array container that is specified
00006 // by the user.  Note that all of these "GenArray" classes are designed such
00007 // that you use them by performing a Reset(), then an Accept() on the target
00008 // sector/hierarchy to get a new set of found objects in
00009 // the array.  Without the Reset(), doing multiple visits will just append found
00010 // objects. This appending behavior can be used in some situations where, for example, you want to get 
00011 // all the objects found in two AI_Sphere regions.
00012 
00013 
00014 #include "AI_SDB_VisibleFrustumVisitor.h"
00015 #include "AI_SDB_OccludedFrustumVisitor.h"
00016 #include "AI_SDB_VisibleSphereVisitor.h"
00017 
00033 class AI_SDB_VisibleFrustumGenArray : public AI_SDB_VisibleFrustumVisitor {
00034 public:
00035     AI_SDB_VisibleFrustumGenArray(const AI_SDB_Camera &cam, const AI_Matrix44 &camxform, VisibleElements &foundarray)
00036         : AI_SDB_VisibleFrustumVisitor(cam, camxform), m_visarray(foundarray)   { }
00037 
00038     ~AI_SDB_VisibleFrustumGenArray() { }
00039 
00040     void Reset() { ClearArray(); AI_SDB_VisibleFrustumVisitor::Reset(); }
00041 
00042     void Visit(AI_SDB_SpatialElement *visitee) { m_visarray.Append(visitee); }
00043 
00044 
00045 protected:
00046     void ClearArray() { m_visarray.Clear(); }
00047 
00048     VisibleElements &m_visarray;
00049 };
00050 
00051 class AI_SDB_OccludedFrustumGenArray : public AI_SDB_OccludedFrustumVisitor {
00052 public:
00053     AI_SDB_OccludedFrustumGenArray(const AI_SDB_Camera &cam, 
00054         const AI_Matrix44 &camxform, 
00055         AI_SDB_OcclusionVisitor &occlusion,
00056         VisibleElements &foundarray)
00057         : AI_SDB_OccludedFrustumVisitor(cam, camxform, occlusion), m_visarray(foundarray) { }
00058 
00059     ~AI_SDB_OccludedFrustumGenArray() {}
00060 
00061     void Reset() { ClearArray(); AI_SDB_OccludedFrustumVisitor::Reset(); }
00062     void Reset(const AI_SDB_Camera &newcamera, const AI_Matrix44 &newxform)
00063     { ClearArray(); AI_SDB_OccludedFrustumVisitor::Reset(newcamera, newxform); }
00064 
00065 
00066     void Visit(AI_SDB_SpatialElement *visitee) { m_visarray.Append(visitee); }
00067 
00068 protected:
00069     void ClearArray() { m_visarray.Clear(); }
00070 
00071     VisibleElements &m_visarray;
00072 };
00073 
00074 class AI_SDB_VisibleSphereGenArray : public AI_SDB_VisibleSphereVisitor {
00075 public:
00076     AI_SDB_VisibleSphereGenArray(const AI_Sphere &viewsphere, VisibleElements &foundarray)
00077         : AI_SDB_VisibleSphereVisitor(viewsphere), m_visarray(foundarray) {}
00078     ~AI_SDB_VisibleSphereGenArray() { }
00079 
00080     void Reset() { ClearArray(); AI_SDB_VisibleSphereVisitor::Reset(); }
00081     void Reset(const AI_Sphere &s) { ClearArray(); AI_SDB_VisibleSphereVisitor::Reset(s); }
00082 
00083     void Visit(AI_SDB_SpatialElement *visitee) { m_visarray.Append(visitee); }
00084 
00085 protected:
00086     void ClearArray() { m_visarray.Clear(); }
00087 
00088     VisibleElements &m_visarray;
00089 };
00090 
00091 #endif
00092