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

Revision 897, 7.1 KB checked in by mattausch, 18 years ago (diff)

updated to ogre 1.2

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 "ViewCellsManager.h"
14
15//class GtpVisibilityPreprocessor::ViewCellsManager;
16
17
18namespace Ogre {
19
20/**
21        This class extends the octree scene manager, using
22        occlusion queries for visibility culling.
23*/
24class __declspec(dllexport) VisibilityOctreeSceneManager: public OctreeSceneManager
25{
26public:
27        VisibilityOctreeSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
28        ~VisibilityOctreeSceneManager();
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 QueuedRenderableCollection& objs,
60                        QueuedRenderableCollection::OrganisationMode om,
61            bool doLightIteration, const LightList* manualLightList = 0);
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, QueuedRenderableCollection::OrganisationMode om);
79
80        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
81        */
82        Entity* createEntity(const String& entityName, const String& meshName);
83
84        /** Returns pointer to visibility manager.
85        */
86        GtpVisibility::VisibilityManager *GetVisibilityManager();
87
88        /** Returns hierarchy interface.
89        */
90        OctreeHierarchyInterface *GetHierarchyInterface();
91
92        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
93                QueuedRenderableCollection::OrganisationMode om);
94        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
95                QueuedRenderableCollection::OrganisationMode om);
96
97        void loadVisibilityConfig(const String& filename);
98
99
100        /** Loads view cells for this particular scene.
101        */
102        void LoadViewCells(std::string filename);
103
104protected:
105       
106        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
107        */
108        void InitDepthPass();
109        /** Creates material for item buffer.
110        */
111        void InitItemBufferPass();
112        /** Fills render queue so that a visualization can be rendered.
113        */
114        void PrepareVisualization(Camera *cam);
115        /** Initialises necessary parameters for hierarchical visibility culling.
116        */
117        void InitVisibilityCulling(Camera *cam);
118       
119        /** Finds object corresponding to this bounding box in the scene.
120        */
121        Entity *FindCorrespondingObject(const AxisAlignedBox &box);
122
123        /** Identifies objects in the scene and gives them unique ids that
124                correspond to preprocessor ids.
125        */
126        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
127
128        /** Loads / unloads pvs of the view cell to set the visibility in the scene.
129        */
130        void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
131
132        /** updates pvs in current frame.
133        */
134        void updatePvs(Camera *cam);
135
136        /** Sets all objects invisible.
137        */
138        void SetObjectsVisible(const bool visible);
139
140        /// the interface to the scene hierarchy.
141        OctreeHierarchyInterface *mHierarchyInterface;
142        /// manages all visibility options
143        GtpVisibility::VisibilityManager *mVisibilityManager;
144       
145        /// if a visualization of the hierarchical culling is shown
146        bool mShowVisualization;
147
148        /// if the culled nodes are indicated in the visualization
149        bool mVisualizeCulledNodes;
150
151        /// if symbols for the nodes are shown in the visualization
152        bool mRenderNodesForViz;
153        /// if content of the nodes is shown in the visualization
154        bool mRenderNodesContentForViz;
155
156        /// render transparents after the hierarchical traversal
157        bool mDelayRenderTransparents;
158
159        /// use a depth pass (i.e., fill only the depth buffer in the first pass)
160        bool mUseDepthPass;
161        /// flag indicating if we currently render the depth pass
162        bool mIsDepthPassPhase;
163
164        /// if we use an item buffer for rendering (i.e., object ids as color codes
165        bool mUseItemBuffer;
166        /// if we currently render the item buffer
167        bool mIsItemBufferPhase;
168
169        /// if depth write should be enabled
170        bool mEnableDepthWrite;
171        /// if transparents are skipped during rendering
172        bool mSkipTransparents;
173
174        /// the depth pass (no lighting, just filling the depth buffer)
175        Pass *mDepthPass;
176        Pass *mItemBufferPass;
177
178        int mCurrentEntityId;
179        /// flag for passes which should not be deleted from queue during first traversal
180        int mLeavePassesInQueue;
181       
182
183        /// if transparent object are considered for item buffer visibility
184        bool mRenderTransparentsForItemBuffer;
185        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
186        bool mExecuteVertexProgramForAllPasses;
187
188        /// if hierarchical culling is currently in use
189        bool mIsHierarchicalCulling;
190
191        bool mViewCellsLoaded;
192        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
193
194        /// Used to assign Ogre meshes to view cell entries.
195        GtpVisibilityPreprocessor::ObjectContainer mObjects;
196
197        GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;
198        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell;
199
200        /// If view cells are used.
201        bool mUseViewCells;
202
203        /// if the view cells are filtered
204        bool mUseVisibilityFilter;
205};
206
207/// Factory for VisibilityOctreeSceneManager
208class VisibilityOctreeSceneManagerFactory : public SceneManagerFactory
209{
210protected:
211        void initMetaData(void) const;
212        GtpVisibility::VisibilityManager *visManager;
213public:
214        VisibilityOctreeSceneManagerFactory(GtpVisibility::VisibilityManager *vm)
215        {
216                visManager = vm;
217        }
218        ~VisibilityOctreeSceneManagerFactory() {}
219        /// Factory type name
220        static const String FACTORY_TYPE_NAME;
221        SceneManager* createInstance(const String& instanceName);
222        void destroyInstance(SceneManager* instance);
223};
224
225} // namespace Ogre
226
227#endif // VisibilityOctreeSceneManager_H
Note: See TracBrowser for help on using the repository browser.