#ifndef _PlatformHierarchyInterface_H__ #define _PlatformHierarchyInterface_H__ #include #include #include #include //#include "OgreSolidHalfBoundingBox.h" #include "OgreSolidBoundingBox.h" #include "HierarchyInterface.h" #include "VisibilityInfo.h" #include "OgrePlatformOcclusionQuery.h" /** This namespace contains the Ogre dependent classes. */ 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 used for the rendering. @param cam the current camera */ void SetCamera(Camera *cam); /** Sets the current camera used for culling. @param cam the current camera @remark the default is the camera used for rendering */ void SetCullCamera(Camera *cullCam); /** Initialises this scene traverser for the current frame. @remark This is a convenience method which resets the stats, sets the current camera, and initialises the distance queue. @param cam the actual camera definding the view frustum @param cullCam the camera used for culling. @remark If cullCam is null, the actual camera is used for both viewing and culling */ void InitTraversal(Camera *cam, Camera *cullCam = NULL, int leavePassesInQueue = 0); /** 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 @param wasVisible if the node was visible in the last frame @returns occlusion query for this node */ GtpVisibility::OcclusionQuery *IssueOcclusionQuery( GtpVisibility::HierarchyNode *node, const bool wasVisible); /** Issue a occlusion query for this mesh. @param node the current mesh @returns occlusion query for this node */ GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh); /** If true, the interface finds and renders only objects which are marked as shadow casters. @remark This is important for the shadow texture pass */ void SetOnlyShadowCasters(bool onlyShadowCasters); /** see set */ bool GetOnlyShadowCasters(); /** see set */ bool GetTestGeometryForVisibleLeaves(); /** see set */ SceneManager *GetSceneManager(); /** see set */ RenderSystem *GetRenderSystem(); /** true if bounding box query is currently active. */ bool IsBoundingBoxQuery(); /** Finds visible objects of hierarchy node using occlusion queries @param node the current scene node @param objs the visible objects @param includeChildren if the children of current scene nodes should also be traversed */ /*virtual bool FindVisibleObjects(GtpVisibility::HierarchyNode *node, InfoContainer *visibleGeometry, bool includeChildren = false) = 0;*/ protected: /** Renders geometry */ void RenderGeometry(GtpVisibility::Mesh *geom); /** Materials for visualizing frustum and query culled nodes. */ void CreateNodeVizMaterials(); /** 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 pointer to current renderable bounding box geometry. */ SolidBoundingBox *GetSolidBoundingBox(); /** A pass that prepares an occlusion query. @remark disables depth write, colour write, lighting, vertex and fragment program. */ //void SetOcclusionPass(); /** Returns pointer to current renderable half bounding box geometry.*/ //SolidHalfBoundingBox *GetSolidHalfBoundingBox(); /** Renderable of an aabb. */ SolidBoundingBox *mSolidBoundingBox; SceneManager *mSceneManager; RenderSystem *mRenderSystem; Camera *mCamera; Camera *mCullCamera; AxisAlignedBox mBox; std::vector mOcclusionQueries; bool mOnlyShadowCasters; int mLeavePassesInQueue; bool mIsBoundingBoxQuery; }; } // namespace Ogre #endif // PlatformHierarchyInterface_H