#ifndef _PlatformHierarchyInterface_H__ #define _PlatformHierarchyInterface_H__ #include #include #include #include #include "OgreSolidBoundingBox.h" #include "HierarchyInterface.h" #include "VisibilityInfo.h" #include "OgrePlatformOcclusionQuery.h" #include "VisibilityMesh.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 */ virtual 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 gives a parameters that decideds on the type of occlusion query. @returns occlusion query for this node */ GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery( GtpVisibility::HierarchyNode *node, const bool testGeometry = false); /** 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 */ SceneManager *GetSceneManager(); /** see set */ RenderSystem *GetRenderSystem(); /** true if bounding box query is currently active. */ bool IsBoundingBoxQuery(); /** Issues occlusion queries for a patch. */ GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch); /** Deletes all occlusion queries. */ void ResetQueries(); /** Returns the geometry of a given hierarchy node. @param node the hierarchy node containing the geometry @param geometryList geometry is returned in this list @param includeChildren if the geometry of the children should be taken into account */ virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, GeometryVector *geometryList, bool includeChildren) = 0; void PullUpLastVisited(GtpVisibility::HierarchyNode *node, const int frameId) const {} GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node) { return NULL; } /** Returns #frames this node is assumed to be visible. */ virtual int GetNodeAssumedVisible(GtpVisibility::HierarchyNode *node) { return 0; }; /** Sets #frames this node is assumed to be visible. */ virtual void SetNodeAssumedVisible(GtpVisibility::HierarchyNode *node, int assumedVisible) {}; /** Decreases #frames this node is assumed to be visible. */ virtual void DecNodeAssumedVisible(GtpVisibility::HierarchyNode *node) {}; /** Test tigher geometry bounds instead of hierarchy node. */ void SetTestGeometryBounds(bool testGeometryForLeaves); /** See get */ int GetTestGeometryBounds(); virtual void AddToQueue(GtpVisibility::HierarchyNode *node) {}; virtual void RenderQueue() {}; virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) {}; virtual GtpVisibility::OcclusionQuery *IssueMultiQuery( const GtpVisibility::HierarchyNodeContainer &nodes); 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(); /** Renders given bounding box. @param box the bounding box of the scene node to be rendered */ void RenderBoundingBox(AxisAlignedBox *box); /** Renders bounding boxes of the geometry. @param node the node to be rendered */ virtual void RenderGeometryBounds(GtpVisibility::HierarchyNode *node) {}; ///////////////////// /** 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; bool mTestGeometryBounds; bool mTestMode; }; } // namespace Ogre #endif // PlatformHierarchyInterface_H