#ifndef _VisibilityTerrainSceneManager_H__ #define _VisibilityTerrainSceneManager_H__ #include #include #include #include #include #include "OgreOctreeHierarchyInterface.h" #include "OgrePlatformQueryManager.h" #include "VisibilityManager.h" namespace Ogre { /** This class extends the terrain scene manager, using occlusion queries for visibility culling. */ class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager { public: VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager); ~VisibilityTerrainSceneManager(); void _renderVisibleObjects(); void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); void _updateSceneGraph(Camera* cam); /** Sets the given option for the SceneManager @remarks Options are: "Algorithm", int *; */ virtual bool setOption( const String &, const void * ); /** Gets the given option for the Scene VisibilityManager. @remarks See setOption */ virtual bool getOption( const String &, void * ); bool getOptionValues( const String & key, StringVector &refValueList ); bool getOptionKeys( StringVector &refKeys ); /** Sets the visibility manager. @param visManager the visibility manager */ void setVisibilityManager(GtpVisibility::VisibilityManager *visManager); /** See set. */ GtpVisibility::VisibilityManager *getVisibilityManager(); /** Render a set of objects, see renderSingleObject for param definitions Override so we can handle delayed rendering of transparent objects */ virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, bool doLightIteration, const LightList* manualLightList = 0); /** Writes out stats into the Ogre log file. */ void WriteLog(); /** Override pass so we can do the z-fail pass. */ Pass* setPass(Pass* pass); /** Override from SceneManager so we can skip all but first pass for depth pass. */ bool validatePassForRendering(Pass* pass); void RenderItemBuffer(RenderPriorityGroup* pGroup); void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); void renderQueueGroupObjects(RenderQueueGroup* pGroup); /** Override from SceneManager so that sub entities can be assigned an id for item buffer. */ //Entity* createEntity(const String& entityName, const String& meshName); /** Returns pointer to visibility manager. */ GtpVisibility::VisibilityManager *GetVisibilityManager(); /** Returns hierarchy interface. */ OctreeHierarchyInterface *GetHierarchyInterface(); void endFrame(); protected: /** Creates material for depth pass, e.g., a pass that only fills the depth buffer. */ void InitDepthPass(); /** Creates material for item buffer. */ void InitItemBufferPass(); /** Fills render queue so that a visualization can be rendered. */ void PrepareVisualization(Camera *cam); /** Initialises necessary parameters for hierarchical visibility culling. */ void InitVisibilityCulling(Camera *cam); /// the interface to the scene hierarchy. OctreeHierarchyInterface *mHierarchyInterface; /// manages all visibility options GtpVisibility::VisibilityManager *mVisibilityManager; /// if a visualization of the hierarchical culling is shown bool mShowVisualization; /// if the culled nodes are indicated in the visualization bool mVisualizeCulledNodes; /// if symbols for the nodes are shown in the visualization bool mRenderNodesForViz; /// if content of the nodes is shown in the visualization bool mRenderNodesContentForViz; /// if we render transparents after the hierarchical traversal bool mDelayRenderTransparents; /// if we use a depth pass (i.e., fill only the depth buffer in the first pass) bool mUseDepthPass; /// if we currently render the depth pass bool mRenderDepthPass; /// if we use an item buffer for rendering (i.e., object ids as color codes bool mUseItemBuffer; /// if we currently render the item buffer bool mRenderItemBuffer; /// if depth write should be enabled bool mEnableDepthWrite; /// if transparents are skipped during rendering bool mSkipTransparents; /// the depth pass (no lighting, just filling the depth buffer) Pass *mDepthPass; Pass *mItemBufferPass; int mCurrentEntityId; /// flag for passes which should not be deleted from queue during first traversal int mLeavePassesInQueue; ShadowTechnique mSavedShadowTechnique; /// if transparent object are considered for item buffer visibility bool mRenderTransparentsForItemBuffer; /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer bool mExecuteVertexProgramForAllPasses; }; } // namespace Ogre #endif // CullingTerrainSceneManager_H