source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h @ 1616

Revision 1616, 7.9 KB checked in by mattausch, 18 years ago (diff)

some shit happen

RevLine 
[675]1#ifndef _OcclusionCullingSceneManager_H__
2#define _OcclusionCullingSceneManager_H__
3
4#include <OgreSceneNode.h>
5#include <OgreTerrainSceneManager.h>
6#include <OgreOctreeNode.h>
7#include <OgreOctreeCamera.h>
8#include <OgrePrerequisites.h>
[897]9#include <OgreMovableObject.h>
[675]10#include "OgreOctreeHierarchyInterface.h"
11#include "OgrePlatformQueryManager.h"
12#include "VisibilityManager.h"
[897]13#include "Containers.h"
[828]14#include "ViewCellsManager.h"
[675]15
16namespace Ogre {
17
[1593]18
[675]19/**
20        This class extends the terrain scene manager,
21        using occlusion queries for visibility culling.
22*/
23class __declspec(dllexport) OcclusionCullingSceneManager: public TerrainSceneManager
24{
25public:
[897]26        OcclusionCullingSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
[675]27        ~OcclusionCullingSceneManager();
28
29        void _renderVisibleObjects();
30        void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
31        void _updateSceneGraph(Camera* cam);
32
33        /** Sets the given option for the SceneManager
34                @remarks Options are: "Algorithm", int *;                       
35        */
36       
37        virtual bool setOption(const String &, const void *);
38        /** Gets the given option for the Scene VisibilityManager.
39            @remarks
40                See setOption
41        */
42        virtual bool getOption(const String &, void *);
43
44        bool getOptionValues(const String & key, StringVector &refValueList);
45        bool getOptionKeys(StringVector &refKeys);
46
47        /** Sets the visibility manager.
48                @param visManager the visibility manager
49        */
50        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
51        /** See set.
52        */
53        GtpVisibility::VisibilityManager *getVisibilityManager();
54
[925]55        /** Render a queue group.
[675]56                Override so we can handle delayed rendering of transparent objects
57        */
[925]58        void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup,
59                                                                          QueuedRenderableCollection::OrganisationMode om);
[675]60
61        /** Writes out stats into the Ogre log file.
62        */
63        void WriteLog();
64
65        /** Override pass so we can do the z-fail pass.
66        */
[1221]67        virtual const Pass* _setPass(const Pass* pass, bool evenIfSuppressed = false);
[675]68
69        /** Override from SceneManager so we can skip all but first pass for depth pass.
70        */
71        bool validatePassForRendering(Pass* pass);
[897]72#ifdef ITEM_BUFFER
[675]73        void RenderItemBuffer(RenderPriorityGroup* pGroup);
74        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
[897]75#endif // ITEM_BUFFER
76        void _renderQueueGroupObjects(RenderQueueGroup* pGroup,
77                QueuedRenderableCollection::OrganisationMode om);
[675]78
79        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
80        */
81        Entity* createEntity(const String& entityName, const String& meshName);
82
83        /** Returns pointer to visibility manager.
84        */
85        GtpVisibility::VisibilityManager *GetVisibilityManager();
86
87        /** Returns hierarchy interface.
88        */
89        OctreeHierarchyInterface *GetHierarchyInterface();
90
[897]91        /** Inherited from scene manager. Neccesary to draw terrain properly.
[675]92        */
93        void endFrame();
94
[897]95        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
96                QueuedRenderableCollection::OrganisationMode om);
97        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
98                QueuedRenderableCollection::OrganisationMode om);
[931]99       
[675]100        /** Override standard function so octree boxes are always of equal side length.
101                This has advantages for CHC, because terrain tiles are in different octree nodes
102                and can be culled.
[897]103                msz: Modified to reflect changes in Ogre::TerrainSceneManager
[675]104        */
[925]105#if 1
[897]106        virtual void setWorldGeometry( DataStreamPtr& stream, const String& typeName );
[925]107#endif
[897]108       
[828]109        /** Loads view cells for this particular scene.
110        */
[938]111        bool LoadViewCells(const String &filename);
[828]112
[675]113protected:
114       
115        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
116        */
117        void InitDepthPass();
118        /** Creates material for item buffer.
119        */
120        void InitItemBufferPass();
121        /** Fills render queue so that a visualization can be rendered.
122        */
123        void PrepareVisualization(Camera *cam);
124        /** Initialises necessary parameters for hierarchical visibility culling.
125        */
126        void InitVisibilityCulling(Camera *cam);
[903]127        /** Loads / unloads pvs of the view cell to set the visibility in the scene.
128        */
[1593]129        void ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
[903]130
131        /** updates pvs in current frame.
132        */
[1593]133        void UpdatePvs(Camera *cam);
[903]134
135        /** Sets all objects invisible.
136        */
137        void SetObjectsVisible(const bool visible);
138
[1593]139        /** Creates view cells geometry from the loaded view cells.
140        */
141        void CreateViewCellsGeometry();
[1602]142        void VisualizeViewCells(const bool visualize);
[1593]143
[1221]144        //////////////////////////////////////////
145
[675]146        /// the interface to the scene hierarchy.
147        OctreeHierarchyInterface *mHierarchyInterface;
[1593]148
[675]149        /// manages all visibility options
150        GtpVisibility::VisibilityManager *mVisibilityManager;
151
152        /// if a visualization of the hierarchical culling is shown
153        bool mShowVisualization;
154
155        /// if the culled nodes are indicated in the visualization
156        bool mVisualizeCulledNodes;
157
158        /// if symbols for the nodes are shown in the visualization
159        bool mRenderNodesForViz;
160        /// if content of the nodes is shown in the visualization
161        bool mRenderNodesContentForViz;
162
[903]163        /// render transparents after the hierarchical traversal
[675]164        bool mDelayRenderTransparents;
165
[903]166        /// use a depth pass (i.e., fill only the depth buffer in the first pass)
[675]167        bool mUseDepthPass;
[903]168        /// flag indicating if we currently render the depth pass
[675]169        bool mIsDepthPassPhase;
170       
171        /// if we use an item buffer for rendering (i.e., object ids as color codes
172        bool mUseItemBuffer;
173        /// if we currently render the item buffer
174        bool mIsItemBufferPhase;
175
176        /// if depth write should be enabled
177        bool mEnableDepthWrite;
178        /// if transparents are skipped during rendering
179        bool mSkipTransparents;
180
181        /// the depth pass (no lighting, just filling the depth buffer)
182        Pass *mDepthPass;
[1593]183        /// the pass for item buffer setting a color id
[675]184        Pass *mItemBufferPass;
185
186        /// flag for passes which should not be deleted from queue during first traversal
187        int mLeavePassesInQueue;
188
189        /// if transparent object are considered for item buffer visibility
190        bool mRenderTransparentsForItemBuffer;
191        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
192        bool mExecuteVertexProgramForAllPasses;
[868]193
[863]194        /// if hierarchical culling is currently in use
[675]195        bool mIsHierarchicalCulling;
[828]196
[1593]197        /// do we use preprocessed visibility
[903]198        bool mViewCellsLoaded;
[1593]199
200        /// the view cells manager handling the preprocesor stuff
[863]201        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
[903]202
203
204        /// Used to assign Ogre meshes to view cell entries.
205        GtpVisibilityPreprocessor::ObjectContainer mObjects;
206
207        GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;
208        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell;
209
210        /// If view cells are used.
211        bool mUseViewCells;
212
[1606]213        /// if view cells visualization should be shown
214        bool mShowViewCells;
215
[903]216        /// if the view cells are filtered
217        bool mUseVisibilityFilter;
[1251]218
219        bool mDeleteQueueAfterRendering;
[1276]220
221        // normal terrain rendering
222        bool mNormalExecution;
[1593]223
224        // helper variable to provide sequential numbering for sub-entities
225        int mCurrentEntityId;
226
[1616]227        typedef map<int, MovableObject *> MovableMap;
[1593]228
229        /// hash table for view cells geometry
[1616]230    MovableMap mViewCellsGeometry;
231
232        bool mViewCellsGeometryLoaded;
[675]233};
234
[1593]235
236/** Factory for VisibilityOctreeSceneManager.
237*/
[903]238class OcclusionCullingSceneManagerFactory : public SceneManagerFactory
239{
240protected:
[925]241        typedef std::vector<TerrainPageSource*> TerrainPageSources;
242        TerrainPageSources mTerrainPageSources;
[903]243        void initMetaData(void) const;
244        GtpVisibility::VisibilityManager *visManager;
245public:
246        OcclusionCullingSceneManagerFactory(GtpVisibility::VisibilityManager *vm)
247        {
248                visManager = vm;
249        }
[925]250
[903]251        /// Factory type name
252        static const String FACTORY_TYPE_NAME;
253        SceneManager* createInstance(const String& instanceName);
254        void destroyInstance(SceneManager* instance);
255};
256
[675]257} // namespace Ogre
258
[903]259#endif // OcclusionCullingSceneManager_H
Note: See TracBrowser for help on using the repository browser.