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

Revision 880, 6.6 KB checked in by mattausch, 18 years ago (diff)

added filter to online stuff (not fully working, too slow
)

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
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(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 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        /** This function renders renderables using false color ids.
74        */
75        void RenderItemBuffer(RenderPriorityGroup* pGroup);
76        /** Renders a single object using false color id.
77        */
78        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
79        /** Overritten from scene manager to include the false color id rendering of the
80                scene objects.
81        */
82        void renderQueueGroupObjects(RenderQueueGroup* pGroup);
83
84        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
85        */
86        Entity* createEntity(const String& entityName, const String& meshName);
87
88        /** Returns pointer to visibility manager.
89        */
90        GtpVisibility::VisibilityManager *GetVisibilityManager();
91
92        /** Returns hierarchy interface.
93        */
94        OctreeHierarchyInterface *GetHierarchyInterface();
95
96        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
97        /** Override this because we must handle shadows differently.
98        */
99        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
100
101        void loadVisibilityConfig(const String& filename);
102
103
104        /** Loads view cells for this particular scene.
105        */
106        void LoadViewCells(std::string filename);
107
108protected:
109       
110        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
111        */
112        void InitDepthPass();
113        /** Creates material for item buffer.
114        */
115        void InitItemBufferPass();
116        /** Fills render queue so that a visualization can be rendered.
117        */
118        void PrepareVisualization(Camera *cam);
119        /** Initialises necessary parameters for hierarchical visibility culling.
120        */
121        void InitVisibilityCulling(Camera *cam);
122       
123        /** Finds object corresponding to this bounding box in the scene.
124        */
125        Entity *FindCorrespondingObject(const AxisAlignedBox &box);
126
127        /** Identifies objects in the scene and gives them unique ids that
128                correspond to preprocessor ids.
129        */
130        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
131
132        /** Loads / unloads pvs of the view cell to set the visibility in the scene.
133        */
134        void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
135
136        /** updates pvs in current frame.
137        */
138        void updatePvs(Camera *cam);
139
140        /** Sets all objects invisible.
141        */
142        void SetObjectsVisible(const bool visible);
143
144        /// the interface to the scene hierarchy.
145        OctreeHierarchyInterface *mHierarchyInterface;
146        /// manages all visibility options
147        GtpVisibility::VisibilityManager *mVisibilityManager;
148       
149        /// if a visualization of the hierarchical culling is shown
150        bool mShowVisualization;
151
152        /// if the culled nodes are indicated in the visualization
153        bool mVisualizeCulledNodes;
154
155        /// if symbols for the nodes are shown in the visualization
156        bool mRenderNodesForViz;
157        /// if content of the nodes is shown in the visualization
158        bool mRenderNodesContentForViz;
159
160        /// if we render transparents after the hierarchical traversal
161        bool mDelayRenderTransparents;
162
163        /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
164        bool mUseDepthPass;
165        /// if we currently rendering the depth pass
166        bool mIsDepthPassPhase;
167
168        /// if we use an item buffer for rendering (i.e., object ids as color codes
169        bool mUseItemBuffer;
170        /// if we currently render the item buffer
171        bool mIsItemBufferPhase;
172
173        /// if depth write should be enabled
174        bool mEnableDepthWrite;
175        /// if transparents are skipped during rendering
176        bool mSkipTransparents;
177
178        /// the depth pass (no lighting, just filling the depth buffer)
179        Pass *mDepthPass;
180        Pass *mItemBufferPass;
181
182        int mCurrentEntityId;
183        /// flag for passes which should not be deleted from queue during first traversal
184        int mLeavePassesInQueue;
185       
186
187        /// if transparent object are considered for item buffer visibility
188        bool mRenderTransparentsForItemBuffer;
189        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
190        bool mExecuteVertexProgramForAllPasses;
191
192        /// if hierarchical culling is currently in use
193        bool mIsHierarchicalCulling;
194
195        bool mViewCellsLoaded;
196        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
197
198        /// Used to assign Ogre meshes to view cell entries.
199        GtpVisibilityPreprocessor::ObjectContainer mObjects;
200
201        GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;
202        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell;
203
204        /// If view cells are used.
205        bool mUseViewCells;
206
207        /// if the view cells are filtered
208        bool mUseVisibilityFilter;
209};
210
211} // namespace Ogre
212
213#endif // VisibilityOctreeSceneManager_H
Note: See TracBrowser for help on using the repository browser.