AI_SDB_VisibleFrustumVisitor.h

Go to the documentation of this file.
00001 #ifndef AI_SDB_VISIBLEFRUSTUMVISITOR_H
00002 #define AI_SDB_VISIBLEFRUSTUMVISITOR_H
00003 
00019 #include "AI_SDB_VisitorBase.h"
00020 #include "AI_SDB_FrustumClipper.h"
00021 #include "AI_SDB_SpatialElements.h"
00022 
00023 class AI_SDB_Camera;
00024 
00025 class AI_SDB_VisibleFrustumVisitor : public AI_SDB_VisibilityVisitor {
00026 public:
00027     AI_SDB_VisibleFrustumVisitor(const AI_SDB_Camera &cameraprojection, const AI_Matrix44 &cameratransform); 
00028     ~AI_SDB_VisibleFrustumVisitor();
00029 
00031     void Reset();
00032 
00034     void Reset(const AI_SDB_Camera &newcamera, const AI_Matrix44 &newxform);
00035 
00036     void Visit(AI_SDB_SpatialElement *visitee);
00037 
00041     virtual AI_SDB_VisitorFlags VisibilityTest(const AI_BBox &testbox, AI_SDB_VisitorFlags flags);
00042 
00046     virtual AI_SDB_VisitorFlags VisibilityTest(const AI_Sphere &testsphere, AI_SDB_VisitorFlags flags);
00047 
00048     // entering a new local space; the matrix given will transform from the current local system into
00049     // the new space local coordinate system.  This is used to possibly update a transform matrix
00050     // or to transform the spatial region to a new coordinate system.
00051     virtual void EnterLocalSpace(AI_Matrix44 &warp);
00052 
00053     // leave a local space
00054     virtual void LeaveLocalSpace();
00055 
00056 protected:
00057     // represents the camera position/rotation in the current space.
00058     // changes if we enter a sector with different local coordinate system
00059     AI_Array<AI_Matrix44> m_viewertransformstack;
00060 
00061     // represents the clipping planes of the view frustum
00062     // changes if we enter a sector with different local coordinate system
00063     AI_Array<AI_SDB_FrustumClipper> m_viewfrustumstack;
00064 
00065     // represents the camera projection
00066     // this typically does not change as we wander through coordinate spaces, so we have a member, not a stack
00067     AI_SDB_Camera m_cameraprojection;
00068 
00069     AI_Matrix44 &GetCameraTransform() const;
00070     AI_SDB_FrustumClipper &GetFrustumClipper() const;
00071 };
00072 
00073 inline
00074 AI_Matrix44 &AI_SDB_VisibleFrustumVisitor::GetCameraTransform() const
00075 {
00076     return m_viewertransformstack.Back();
00077 }
00078 
00079 inline
00080 AI_SDB_FrustumClipper &AI_SDB_VisibleFrustumVisitor::GetFrustumClipper() const
00081 {
00082     return m_viewfrustumstack.Back();
00083 }
00084 
00085 #endif