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