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

Revision 868, 5.7 KB checked in by mattausch, 18 years ago (diff)

fitting objects to bb, debug

Line 
1#ifndef _VisibilityTerrainSceneManager_H__
2#define _VisibilityTerrainSceneManager_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
14
15namespace Ogre {
16
17/**
18        This class extends the terrain scene manager,
19        using occlusion queries for visibility culling.
20*/
21class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager
22{
23public:
24        VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager);
25        ~VisibilityTerrainSceneManager();
26
27        void _renderVisibleObjects();
28        void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
29        void _updateSceneGraph(Camera* cam);
30
31        /** Sets the given option for the SceneManager
32                @remarks Options are: "Algorithm", int *;                       
33        */
34       
35        virtual bool setOption(const String &, const void *);
36        /** Gets the given option for the Scene VisibilityManager.
37            @remarks
38                See setOption
39        */
40        virtual bool getOption(const String &, void *);
41
42        bool getOptionValues(const String & key, StringVector &refValueList);
43        bool getOptionKeys(StringVector &refKeys);
44
45        /** Sets the visibility manager.
46                @param visManager the visibility manager
47        */
48        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
49        /** See set.
50        */
51        GtpVisibility::VisibilityManager *getVisibilityManager();
52
53        /** Render a set of objects, see renderSingleObject for param definitions
54                Override so we can handle delayed rendering of transparent objects
55        */
56        virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,
57            bool doLightIteration, const LightList* manualLightList = 0);
58
59        /** Writes out stats into the Ogre log file.
60        */
61        void WriteLog();
62
63        /** Override pass so we can do the z-fail pass.
64        */
65        Pass* setPass(Pass* pass);
66
67        /** Override from SceneManager so we can skip all but first pass for depth pass.
68        */
69        bool validatePassForRendering(Pass* pass);
70        /** This function renders renderables using false color ids.
71        */
72        void RenderItemBuffer(RenderPriorityGroup* pGroup);
73        /** Renders a single object using false color id.
74        */
75        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
76        /** Overritten from scene manager to include the false color id rendering of the
77                scene objects.
78        */
79        void renderQueueGroupObjects(RenderQueueGroup* pGroup);
80
81        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
82        */
83        Entity* createEntity(const String& entityName, const String& meshName);
84
85        /** Returns pointer to visibility manager.
86        */
87        GtpVisibility::VisibilityManager *GetVisibilityManager();
88
89        /** Returns hierarchy interface.
90        */
91        OctreeHierarchyInterface *GetHierarchyInterface();
92
93        /** Inherited from scene manager. Neccesary to draw terrain properly.
94        */
95        void endFrame();
96
97        /** Override this because we must handle shadows differently.
98        */
99        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
100        /** Override this because we must handle shadows differently.
101        */
102        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
103
104        /** Override standard function so octree boxes are always of equal side length.
105                This has advantages for CHC, because terrain tiles are in different octree nodes
106                and can be culled.
107        */
108        void setWorldGeometry(const String& filename);
109
110protected:
111       
112        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
113        */
114        void InitDepthPass();
115        /** Creates material for item buffer.
116        */
117        void InitItemBufferPass();
118        /** Fills render queue so that a visualization can be rendered.
119        */
120        void PrepareVisualization(Camera *cam);
121        /** Initialises necessary parameters for hierarchical visibility culling.
122        */
123        void InitVisibilityCulling(Camera *cam);
124
125
126
127        /// the interface to the scene hierarchy.
128        OctreeHierarchyInterface *mHierarchyInterface;
129        /// manages all visibility options
130        GtpVisibility::VisibilityManager *mVisibilityManager;
131
132        /// if a visualization of the hierarchical culling is shown
133        bool mShowVisualization;
134
135        /// if the culled nodes are indicated in the visualization
136        bool mVisualizeCulledNodes;
137
138        /// if symbols for the nodes are shown in the visualization
139        bool mRenderNodesForViz;
140        /// if content of the nodes is shown in the visualization
141        bool mRenderNodesContentForViz;
142
143        /// if we render transparents after the hierarchical traversal
144        bool mDelayRenderTransparents;
145
146        /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
147        bool mUseDepthPass;
148        /// if we currently rendering the depth pass
149        bool mIsDepthPassPhase;
150       
151        /// if we use an item buffer for rendering (i.e., object ids as color codes
152        bool mUseItemBuffer;
153        /// if we currently render the item buffer
154        bool mIsItemBufferPhase;
155
156        /// if depth write should be enabled
157        bool mEnableDepthWrite;
158        /// if transparents are skipped during rendering
159        bool mSkipTransparents;
160
161        /// the depth pass (no lighting, just filling the depth buffer)
162        Pass *mDepthPass;
163        Pass *mItemBufferPass;
164
165        int mCurrentEntityId;
166        /// flag for passes which should not be deleted from queue during first traversal
167        int mLeavePassesInQueue;
168
169
170        /// if transparent object are considered for item buffer visibility
171        bool mRenderTransparentsForItemBuffer;
172        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
173        bool mExecuteVertexProgramForAllPasses;
174
175        bool mIsHierarchicalCulling;
176
177        std::ofstream mDummyLog;
178};
179
180} // namespace Ogre
181
182#endif // CullingTerrainSceneManager_H
Note: See TracBrowser for help on using the repository browser.