1 | #ifndef _VisibilityOctreeSceneManager_H__
|
---|
2 | #define _VisibilityOctreeSceneManager_H__
|
---|
3 |
|
---|
4 | #include <OgreSceneNode.h>
|
---|
5 | #include <OgreOctreeSceneManager.h>
|
---|
6 | #include <OgreOctreeNode.h>
|
---|
7 | #include <OgreOctreeCamera.h>
|
---|
8 | #include <OgrePrerequisites.h>
|
---|
9 |
|
---|
10 | #include "OgreOctreeHierarchyInterface.h"
|
---|
11 | #include "VisibilityManager.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | namespace Ogre {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | This class extends the octree scene manager, using
|
---|
18 | occlusion queries for visibility culling.
|
---|
19 | */
|
---|
20 | class __declspec(dllexport) VisibilityOctreeSceneManager: public OctreeSceneManager
|
---|
21 | {
|
---|
22 | public:
|
---|
23 | VisibilityOctreeSceneManager(GtpVisibility::VisibilityManager *visManager);
|
---|
24 | ~VisibilityOctreeSceneManager();
|
---|
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 |
|
---|
58 | /** Writes out stats into the Ogre log file.
|
---|
59 | */
|
---|
60 | void WriteLog();
|
---|
61 |
|
---|
62 | /** Override pass so we can do the z-fail pass.
|
---|
63 | */
|
---|
64 | Pass* setPass(Pass* pass);
|
---|
65 |
|
---|
66 | /** Override from SceneManager so we can skip all but first pass for depth pass.
|
---|
67 | */
|
---|
68 | bool validatePassForRendering(Pass* pass);
|
---|
69 |
|
---|
70 | void RenderItemBuffer(RenderPriorityGroup* pGroup);
|
---|
71 | void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
|
---|
72 | void renderQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
73 |
|
---|
74 | /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
|
---|
75 | */
|
---|
76 | //Entity* createEntity(const String& entityName, const String& meshName);
|
---|
77 |
|
---|
78 | /** Returns pointer to visibility manager.
|
---|
79 | */
|
---|
80 | GtpVisibility::VisibilityManager *GetVisibilityManager();
|
---|
81 |
|
---|
82 | /** Returns hierarchy interface.
|
---|
83 | */
|
---|
84 | OctreeHierarchyInterface *GetHierarchyInterface();
|
---|
85 |
|
---|
86 | void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
87 | void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
88 |
|
---|
89 | void loadVisibilityConfig(const String& filename);
|
---|
90 |
|
---|
91 | protected:
|
---|
92 |
|
---|
93 | /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
|
---|
94 | */
|
---|
95 | void InitDepthPass();
|
---|
96 | /** Creates material for item buffer.
|
---|
97 | */
|
---|
98 | void InitItemBufferPass();
|
---|
99 | /** Fills render queue so that a visualization can be rendered.
|
---|
100 | */
|
---|
101 | void PrepareVisualization(Camera *cam);
|
---|
102 | /** Initialises necessary parameters for hierarchical visibility culling.
|
---|
103 | */
|
---|
104 | void InitVisibilityCulling(Camera *cam);
|
---|
105 |
|
---|
106 |
|
---|
107 |
|
---|
108 | /// the interface to the scene hierarchy.
|
---|
109 | OctreeHierarchyInterface *mHierarchyInterface;
|
---|
110 | /// manages all visibility options
|
---|
111 | GtpVisibility::VisibilityManager *mVisibilityManager;
|
---|
112 |
|
---|
113 | /// if a visualization of the hierarchical culling is shown
|
---|
114 | bool mShowVisualization;
|
---|
115 |
|
---|
116 | /// if the culled nodes are indicated in the visualization
|
---|
117 | bool mVisualizeCulledNodes;
|
---|
118 |
|
---|
119 | /// if symbols for the nodes are shown in the visualization
|
---|
120 | bool mRenderNodesForViz;
|
---|
121 | /// if content of the nodes is shown in the visualization
|
---|
122 | bool mRenderNodesContentForViz;
|
---|
123 |
|
---|
124 | /// render transparents after the hierarchical traversal
|
---|
125 | bool mDelayRenderTransparents;
|
---|
126 |
|
---|
127 | /// use a depth pass (i.e., fill only the depth buffer in the first pass)
|
---|
128 | bool mUseDepthPass;
|
---|
129 | /// flag indicating if we currently render the depth pass
|
---|
130 | bool mIsDepthPassPhase;
|
---|
131 |
|
---|
132 | /// if we use an item buffer for rendering (i.e., object ids as color codes
|
---|
133 | bool mUseItemBuffer;
|
---|
134 | /// if we currently render the item buffer
|
---|
135 | bool mIsItemBufferPhase;
|
---|
136 |
|
---|
137 | /// if depth write should be enabled
|
---|
138 | bool mEnableDepthWrite;
|
---|
139 | /// if transparents are skipped during rendering
|
---|
140 | bool mSkipTransparents;
|
---|
141 |
|
---|
142 | /// the depth pass (no lighting, just filling the depth buffer)
|
---|
143 | Pass *mDepthPass;
|
---|
144 | Pass *mItemBufferPass;
|
---|
145 |
|
---|
146 | int mCurrentEntityId;
|
---|
147 | /// flag for passes which should not be deleted from queue during first traversal
|
---|
148 | int mLeavePassesInQueue;
|
---|
149 |
|
---|
150 |
|
---|
151 | /// if transparent object are considered for item buffer visibility
|
---|
152 | bool mRenderTransparentsForItemBuffer;
|
---|
153 | /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
|
---|
154 | bool mExecuteVertexProgramForAllPasses;
|
---|
155 |
|
---|
156 | bool mIsHierarchicalCulling;
|
---|
157 | };
|
---|
158 |
|
---|
159 | } // namespace Ogre
|
---|
160 |
|
---|
161 | #endif // VisibilityOctreeSceneManager_H |
---|