source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h @ 726

Revision 726, 5.4 KB checked in by mattausch, 19 years ago (diff)

improved performance of TerrainSceneManager?
revisit octreescenemanager

Line 
1#ifndef _VisibilityTerrainSceneManager_H__
2#define _VisibilityTerrainSceneManager_H__
3
4#include <OgreSceneNode.h>
5#include <OgreTerrainSceneManager.h>
6#include <OgreOctreeNode.h>
7#include <OgreOctreeCamera.h>
8#include <OgrePrerequisites.h>
9
10#include "OgreOctreeHierarchyInterface.h"
11#include "OgrePlatformQueryManager.h"
12#include "VisibilityManager.h"
13
14namespace Ogre {
15
16/**
17        This class extends the terrain scene manager,
18        using occlusion queries for visibility culling.
19*/
20class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager
21{
22public:
23        VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager);
24        ~VisibilityTerrainSceneManager();
25
26        void _renderVisibleObjects();
27        void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
28        void _updateSceneGraph(Camera* cam);
29
30        /** Sets the given option for the SceneManager
31                @remarks Options are: "Algorithm", int *;                       
32        */
33       
34        virtual bool setOption(const String &, const void *);
35        /** Gets the given option for the Scene VisibilityManager.
36            @remarks
37                See setOption
38        */
39        virtual bool getOption(const String &, void *);
40
41        bool getOptionValues(const String & key, StringVector &refValueList);
42        bool getOptionKeys(StringVector &refKeys);
43
44        /** Sets the visibility manager.
45                @param visManager the visibility manager
46        */
47        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
48        /** See set.
49        */
50        GtpVisibility::VisibilityManager *getVisibilityManager();
51
52        /** Render a set of objects, see renderSingleObject for param definitions
53                Override so we can handle delayed rendering of transparent objects
54        */
55        virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,
56            bool doLightIteration, const LightList* manualLightList = 0);
57        /** Writes out stats into the Ogre log file.
58        */
59        void WriteLog();
60
61        /** We override this because we want to include the z-fail pass.
62        */
63        Pass* setPass(Pass* pass);
64        /** Override from SceneManager so we can skip all but first pass for depth pass.
65        */
66        bool validatePassForRendering(Pass* pass);
67        /** This function renders renderables using false color ids.
68        */
69        void RenderItemBuffer(RenderPriorityGroup* pGroup);
70        /** Renders a single object using false color id.
71        */
72        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
73        /** Overritten from scene manager to include the false color id rendering of the
74                scene objects.
75        */
76        void renderQueueGroupObjects(RenderQueueGroup* pGroup);
77
78        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
79        */
80        Entity* createEntity(const String& entityName, const String& meshName);
81
82        /** Returns pointer to visibility manager.
83        */
84        GtpVisibility::VisibilityManager *GetVisibilityManager();
85
86        /** Returns hierarchy interface.
87        */
88        OctreeHierarchyInterface *GetHierarchyInterface();
89
90        /** Inherited from scene manager. Neccesary to draw terrain properly.
91        */
92        void endFrame();
93
94        /** Override this because we must handle shadows differently.
95        */
96        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
97        /** Override this because we must handle shadows differently.
98        */
99        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
100
101protected:
102       
103        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
104        */
105        void InitDepthPass();
106        /** Creates material for item buffer.
107        */
108        void InitItemBufferPass();
109        /** Fills render queue so that a visualization can be rendered.
110        */
111        void PrepareVisualization(Camera *cam);
112        /** Initialises necessary parameters for hierarchical visibility culling.
113        */
114        void InitVisibilityCulling(Camera *cam);
115
116        /// the interface to the scene hierarchy.
117        OctreeHierarchyInterface *mHierarchyInterface;
118        /// manages all visibility options
119        GtpVisibility::VisibilityManager *mVisibilityManager;
120
121        /// if a visualization of the hierarchical culling is shown
122        bool mShowVisualization;
123
124        /// if the culled nodes are indicated in the visualization
125        bool mVisualizeCulledNodes;
126
127        /// if symbols for the nodes are shown in the visualization
128        bool mRenderNodesForViz;
129        /// if content of the nodes is shown in the visualization
130        bool mRenderNodesContentForViz;
131
132        /// if we render transparents after the hierarchical traversal
133        bool mDelayRenderTransparents;
134
135        /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
136        bool mUseDepthPass;
137        /// if we currently rendering the depth pass
138        bool mIsDepthPassPhase;
139       
140        /// if we use an item buffer for rendering (i.e., object ids as color codes
141        bool mUseItemBuffer;
142        /// if we currently render the item buffer
143        bool mIsItemBufferPhase;
144
145        /// if depth write should be enabled
146        bool mEnableDepthWrite;
147        /// if transparents are skipped during rendering
148        bool mSkipTransparents;
149
150        /// the depth pass (no lighting, just filling the depth buffer)
151        Pass *mDepthPass;
152        Pass *mItemBufferPass;
153
154        int mCurrentEntityId;
155        /// flag for passes which should not be deleted from queue during first traversal
156        int mLeavePassesInQueue;
157
158        /// if transparent object are considered for item buffer visibility
159        bool mRenderTransparentsForItemBuffer;
160        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
161        bool mExecuteVertexProgramForAllPasses;
162
163        bool mIsHierarchicalCulling;
164
165        std::ofstream mDummyLog;
166};
167
168} // namespace Ogre
169
170#endif // CullingTerrainSceneManager_H
Note: See TracBrowser for help on using the repository browser.