#ifndef _PlatformHierarchyInterface_H__ #define _PlatformHierarchyInterface_H__ #include #include #include #include #include "OgreSolidHalfBoundingBox.h" #include "HierarchyInterface.h" #include "OgrePlatformOcclusionQuery.h" namespace Ogre { /** Class which implements a hierarchy interface for a specific type of hierarchy. @remark also provides methods for using occlusion queries on the hierarchy nodes */ class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface { public: /** Construction taking the current scene manager and the current rendersystem as argument @param sm current scene manager @param rsys current render system */ PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys); ~PlatformHierarchyInterface(); /** Returns next available occlusion query or creates new one. @return the next occlusion query */ GtpVisibility::OcclusionQuery *GetNextOcclusionQuery(); /** Sets the current camera. @param cam the current camera */ void SetCamera(Camera *cam); /** Initialises this scene traverser for the current frame. @param root root of the hierarchy @param cam current camera @remark convenience method wich calls VisibilitySceneTraverser::initFrame, sets the current camera, and initialises the distance queue. */ void InitFrame(GtpVisibility::HierarchyNode *root, Ogre::Camera *cam); /** Checks if the node is visible from the current view frustum. @param node the current node @param intersects returns true if the current node intersects the near plane */ bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects); /** Sets pointer to the current scene manager. @param sm the scene manager */ void SetSceneManager(SceneManager *sm); /** Sets pointer to the current render system @param rsys the rendersystem */ void SetRenderSystem(RenderSystem *rsys); /** Returns pointer to bounding box of node. @param node current hierarchy node @returns bounding box of current node */ virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0; /** Issue a occlusion query for this node. @param node the current hierarchy node @returns occlusion query for this node */ GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::HierarchyNode *node); protected: /** Deletes all occlusion queries. */ void DeleteQueries(); /** Renders bounding box of specified node. @param box the bounding box of the scene node to be rendered */ void RenderBoundingBox(AxisAlignedBox *box); /** Returns one half of the bounding box. @param half the half index of the bouding box (0 or 1) */ SolidHalfBoundingBox *GetSolidHalfBoundingBox(int half); /** two halfes of an aabb. */ SolidHalfBoundingBox *mHalfBoundingBox[2]; SceneManager *mSceneManager; RenderSystem *mRenderSystem; Camera *mCamera; AxisAlignedBox mBox; std::vector mOcclusionQueries; }; } // namespace Ogre #endif // PlatformHierarchyInterface_H