source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h @ 828

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