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

Revision 868, 6.1 KB checked in by mattausch, 19 years ago (diff)

fitting objects to bb, debug

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
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 terrain scene manager,
22        using occlusion queries for visibility culling.
23*/
24class __declspec(dllexport) OcclusionCullingSceneManager: public TerrainSceneManager
25{
26public:
27        OcclusionCullingSceneManager(GtpVisibility::VisibilityManager *visManager);
28        ~OcclusionCullingSceneManager();
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        /** Override this because we must handle shadows differently.
97        */
98        void endFrame();
99
100        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
101        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
102
103        /** Override standard function so octree boxes are always of equal side length.
104                This has advantages for CHC, because terrain tiles are in different octree nodes
105                and can be culled.
106        */
107        void setWorldGeometry( const String& filename );
108
109        /** Loads view cells for this particular scene.
110        */
111        void LoadViewCells(std::string filename);
112
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);
127
128        /** Finds object corresponding to this bounding box in the scene.
129        */
130        MovableObject *FindCorrespondingObject(const AxisAlignedBox &box);
131
132        /** Identifies objects in the scene and gives them unique ids that
133                correspond to preprocessor ids.
134        */
135        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
136
137        /// the interface to the scene hierarchy.
138        OctreeHierarchyInterface *mHierarchyInterface;
139        /// manages all visibility options
140        GtpVisibility::VisibilityManager *mVisibilityManager;
141
142        /// if a visualization of the hierarchical culling is shown
143        bool mShowVisualization;
144
145        /// if the culled nodes are indicated in the visualization
146        bool mVisualizeCulledNodes;
147
148        /// if symbols for the nodes are shown in the visualization
149        bool mRenderNodesForViz;
150        /// if content of the nodes is shown in the visualization
151        bool mRenderNodesContentForViz;
152
153        /// if we render transparents after the hierarchical traversal
154        bool mDelayRenderTransparents;
155
156        /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
157        bool mUseDepthPass;
158        /// if we currently rendering the depth pass
159        bool mIsDepthPassPhase;
160       
161        /// if we use an item buffer for rendering (i.e., object ids as color codes
162        bool mUseItemBuffer;
163        /// if we currently render the item buffer
164        bool mIsItemBufferPhase;
165
166        /// if depth write should be enabled
167        bool mEnableDepthWrite;
168        /// if transparents are skipped during rendering
169        bool mSkipTransparents;
170
171        /// the depth pass (no lighting, just filling the depth buffer)
172        Pass *mDepthPass;
173        Pass *mItemBufferPass;
174
175        int mCurrentEntityId;
176        /// flag for passes which should not be deleted from queue during first traversal
177        int mLeavePassesInQueue;
178
179
180        /// if transparent object are considered for item buffer visibility
181        bool mRenderTransparentsForItemBuffer;
182        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
183        bool mExecuteVertexProgramForAllPasses;
184
185        /// if hierarchical culling is currently in use
186        bool mIsHierarchicalCulling;
187
188        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
189};
190
191} // namespace Ogre
192
193#endif // CullingTerrainSceneManager_H
Note: See TracBrowser for help on using the repository browser.