#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 */ typedef std::vector OcclusionQueryContainer; 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 *IssueNodeOcclusionQuery( GtpVisibility::HierarchyNode *node, const bool wasVisible); /** Issue a occlusion query for this mesh. @param mesh the mesh for which an occlusion query is issued. @returns occlusion query for this mesh. */ GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(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(); GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch); /** Deletes all occlusion queries. */ void ResetQueries(); protected: /** Renders the given geometry */ void RenderGeometry(GtpVisibility::Mesh *geom); /** Renders the given patch */ void RenderPatch(GtpVisibility::Patch *patch); /** Materials for visualizing frustum and query culled nodes. */ void CreateNodeVizMaterials(); /** 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(); /** Renders given bounding box. @param box the bounding box of the scene node to be rendered */ void RenderBoundingBox(AxisAlignedBox *box); /** Renderable of an aabb. */ SolidBoundingBox *mSolidBoundingBox; SceneManager *mSceneManager; RenderSystem *mRenderSystem; Camera *mCamera; Camera *mCullCamera; AxisAlignedBox mBox; OcclusionQueryContainer mOcclusionQueries; Vector3 mCameraPosition; bool mOnlyShadowCasters; int mLeavePassesInQueue; bool mIsBoundingBoxQuery; }; } // namespace Ogre #endif // PlatformHierarchyInterface_H