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