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

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

updated to ogre 1.2

Line 
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>
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
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:
25        OcclusionCullingSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
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
54        /** Render a set of objects, see renderSingleObject for param definitions
55                Override so we can handle delayed rendering of transparent objects
56        */
57        virtual void renderObjects(const QueuedRenderableCollection& objs,
58                        QueuedRenderableCollection::OrganisationMode om,
59            bool doLightIteration, const LightList* manualLightList = 0);
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        */
67        const Pass* _setPass(Pass* pass);
68
69        /** Override from SceneManager so we can skip all but first pass for depth pass.
70        */
71        bool validatePassForRendering(Pass* pass);
72#ifdef ITEM_BUFFER
73        void RenderItemBuffer(RenderPriorityGroup* pGroup);
74        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
75#endif // ITEM_BUFFER
76        void _renderQueueGroupObjects(RenderQueueGroup* pGroup,
77                QueuedRenderableCollection::OrganisationMode om);
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
91        /** Inherited from scene manager. Neccesary to draw terrain properly.
92        */
93        void endFrame();
94
95        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
96                QueuedRenderableCollection::OrganisationMode om);
97        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
98                QueuedRenderableCollection::OrganisationMode om);
99
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.
103                msz: Modified to reflect changes in Ogre::TerrainSceneManager
104        */
105        virtual void setWorldGeometry( DataStreamPtr& stream, const String& typeName );
106
107       
108        /** Loads view cells for this particular scene.
109        */
110        void LoadViewCells(std::string filename);
111
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
127        /** Finds object corresponding to this bounding box in the scene.
128        */
129        MovableObject *FindCorrespondingObject(const AxisAlignedBox &box);
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
136        /// the interface to the scene hierarchy.
137        OctreeHierarchyInterface *mHierarchyInterface;
138        /// manages all visibility options
139        GtpVisibility::VisibilityManager *mVisibilityManager;
140
141        /// if a visualization of the hierarchical culling is shown
142        bool mShowVisualization;
143
144        /// if the culled nodes are indicated in the visualization
145        bool mVisualizeCulledNodes;
146
147        /// if symbols for the nodes are shown in the visualization
148        bool mRenderNodesForViz;
149        /// if content of the nodes is shown in the visualization
150        bool mRenderNodesContentForViz;
151
152        /// if we render transparents after the hierarchical traversal
153        bool mDelayRenderTransparents;
154
155        /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
156        bool mUseDepthPass;
157        /// if we currently rendering the depth pass
158        bool mIsDepthPassPhase;
159       
160        /// if we use an item buffer for rendering (i.e., object ids as color codes
161        bool mUseItemBuffer;
162        /// if we currently render the item buffer
163        bool mIsItemBufferPhase;
164
165        /// if depth write should be enabled
166        bool mEnableDepthWrite;
167        /// if transparents are skipped during rendering
168        bool mSkipTransparents;
169
170        /// the depth pass (no lighting, just filling the depth buffer)
171        Pass *mDepthPass;
172        Pass *mItemBufferPass;
173
174        int mCurrentEntityId;
175        /// flag for passes which should not be deleted from queue during first traversal
176        int mLeavePassesInQueue;
177
178
179        /// if transparent object are considered for item buffer visibility
180        bool mRenderTransparentsForItemBuffer;
181        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
182        bool mExecuteVertexProgramForAllPasses;
183
184        /// if hierarchical culling is currently in use
185        bool mIsHierarchicalCulling;
186
187        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
188};
189
190} // namespace Ogre
191
192#endif // CullingTerrainSceneManager_H
Note: See TracBrowser for help on using the repository browser.