source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h @ 925

Revision 925, 7.0 KB checked in by mattausch, 18 years ago (diff)

update for ogre 1.2
OcclusionCullingSceneManager? is the only scenemanager in the solution now

Line 
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#include <OgreMovableObject.h>
10#include "OgreOctreeHierarchyInterface.h"
11#include "OgrePlatformQueryManager.h"
12#include "VisibilityManager.h"
13#include "Containers.h"
14#include "ViewCellsManager.h"
15
16//class GtpVisibilityPreprocessor::ViewCellsManager;
17
18
19namespace Ogre {
20
21/**
22        This class extends the octree scene manager, using
23        occlusion queries for visibility culling.
24*/
25class __declspec(dllexport) VisibilityOctreeSceneManager: public OctreeSceneManager
26{
27public:
28        VisibilityOctreeSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
29        ~VisibilityOctreeSceneManager();
30
31        void _renderVisibleObjects();
32        void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
33        void _updateSceneGraph(Camera* cam );
34
35        /** Sets the given option for the SceneManager
36                @remarks Options are: "Algorithm", int *;                       
37        */
38       
39        virtual bool setOption(const String &, const void *);
40        /** Gets the given option for the Scene VisibilityManager.
41            @remarks
42                See setOption
43        */
44        virtual bool getOption(const String &, void *);
45
46        bool getOptionValues(const String & key, StringVector &refValueList);
47        bool getOptionKeys(StringVector &refKeys);
48
49        /** Sets the visibility manager.
50                @param visManager the visibility manager
51        */
52        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
53        /** See set.
54        */
55        GtpVisibility::VisibilityManager *getVisibilityManager();
56       
57        /** Render a queue group.
58                Override so we can handle delayed rendering of transparent objects
59        */
60        void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup,
61                                                                 QueuedRenderableCollection::OrganisationMode om);
62
63        /** Writes out stats into the Ogre log file.
64        */
65        void WriteLog();
66
67        /** Override pass so we can do the z-fail pass.
68        */
69        const Pass* _setPass(Pass* pass);
70
71        /** Override from SceneManager so we can skip all but first pass for depth pass.
72        */
73        bool validatePassForRendering(Pass* pass);
74#ifdef ITEM_BUFFER
75        void RenderItemBuffer(RenderPriorityGroup* pGroup);
76        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
77#endif // ITEM_BUFFER
78        void _renderQueueGroupObjects(RenderQueueGroup* pGroup,
79                QueuedRenderableCollection::OrganisationMode om);
80
81        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
82        */
83        Entity* createEntity(const String& entityName, const String& meshName);
84
85        /** Returns pointer to visibility manager.
86        */
87        GtpVisibility::VisibilityManager *GetVisibilityManager();
88
89        /** Returns hierarchy interface.
90        */
91        OctreeHierarchyInterface *GetHierarchyInterface();
92
93        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
94                QueuedRenderableCollection::OrganisationMode om);
95        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
96                QueuedRenderableCollection::OrganisationMode om);
97
98        void loadVisibilityConfig(const String& filename);
99
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        /** Finds object corresponding to this bounding box in the scene.
121        */
122        Entity *FindCorrespondingObject(const AxisAlignedBox &box);
123
124        /** Identifies objects in the scene and gives them unique ids that
125                correspond to preprocessor ids.
126        */
127        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
128
129        /** Loads / unloads pvs of the view cell to set the visibility in the scene.
130        */
131        void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
132
133        /** updates pvs in current frame.
134        */
135        void updatePvs(Camera *cam);
136
137        /** Sets all objects invisible.
138        */
139        void SetObjectsVisible(const bool visible);
140
141        /// the interface to the scene hierarchy.
142        OctreeHierarchyInterface *mHierarchyInterface;
143        /// manages all visibility options
144        GtpVisibility::VisibilityManager *mVisibilityManager;
145       
146        /// if a visualization of the hierarchical culling is shown
147        bool mShowVisualization;
148
149        /// if the culled nodes are indicated in the visualization
150        bool mVisualizeCulledNodes;
151
152        /// if symbols for the nodes are shown in the visualization
153        bool mRenderNodesForViz;
154        /// if content of the nodes is shown in the visualization
155        bool mRenderNodesContentForViz;
156
157        /// render transparents after the hierarchical traversal
158        bool mDelayRenderTransparents;
159
160        /// use a depth pass (i.e., fill only the depth buffer in the first pass)
161        bool mUseDepthPass;
162        /// flag indicating if we currently render the depth pass
163        bool mIsDepthPassPhase;
164
165        /// if we use an item buffer for rendering (i.e., object ids as color codes
166        bool mUseItemBuffer;
167        /// if we currently render the item buffer
168        bool mIsItemBufferPhase;
169
170        /// if depth write should be enabled
171        bool mEnableDepthWrite;
172        /// if transparents are skipped during rendering
173        bool mSkipTransparents;
174
175        /// the depth pass (no lighting, just filling the depth buffer)
176        Pass *mDepthPass;
177        Pass *mItemBufferPass;
178
179        int mCurrentEntityId;
180        /// flag for passes which should not be deleted from queue during first traversal
181        int mLeavePassesInQueue;
182       
183
184        /// if transparent object are considered for item buffer visibility
185        bool mRenderTransparentsForItemBuffer;
186        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
187        bool mExecuteVertexProgramForAllPasses;
188
189        /// if hierarchical culling is currently in use
190        bool mIsHierarchicalCulling;
191
192        bool mViewCellsLoaded;
193        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
194
195
196        /// Used to assign Ogre meshes to view cell entries.
197        GtpVisibilityPreprocessor::ObjectContainer mObjects;
198
199        GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;
200        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell;
201
202        /// If view cells are used.
203        bool mUseViewCells;
204
205        /// if the view cells are filtered
206        bool mUseVisibilityFilter;
207};
208
209/// Factory for VisibilityOctreeSceneManager
210class VisibilityOctreeSceneManagerFactory : public SceneManagerFactory
211{
212protected:
213        void initMetaData(void) const;
214        GtpVisibility::VisibilityManager *visManager;
215public:
216        VisibilityOctreeSceneManagerFactory(GtpVisibility::VisibilityManager *vm)
217        {
218                visManager = vm;
219        }
220        ~VisibilityOctreeSceneManagerFactory() {}
221        /// Factory type name
222        static const String FACTORY_TYPE_NAME;
223        SceneManager* createInstance(const String& instanceName);
224        void destroyInstance(SceneManager* instance);
225};
226
227} // namespace Ogre
228
229#endif // VisibilityOctreeSceneManager_H
Note: See TracBrowser for help on using the repository browser.