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

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

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

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