source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h @ 1285

Revision 1285, 9.4 KB checked in by szydlowski, 18 years ago (diff)

saving and loading entities to file

RevLine 
[1163]1/*
2-----------------------------------------------------------------------------
3This source file is part of the GameTools Project
4http://www.gametools.org
5
6Author: Martin Szydlowski
7-----------------------------------------------------------------------------
8*/
9
10#ifndef _KdTreeSceneManager_H__
11#define _KdTreeSceneManager_H__
12
13#include <OgreSceneManager.h>
[1175]14#include <VisibilityManager.h>
[1258]15
[1163]16#include "OgreKdTree.h"
[1206]17#include "OgreKdTreeCamera.h"
[1258]18#include "OgreKdTreeHierarchyInterface.h"
[1163]19
[1187]20#define KDTREE_MAX_DEPTH 12
[1165]21
[1163]22namespace Ogre
23{
24
[1185]25class KdTreeSceneNode;
[1163]26
[1185]27class KdTreeSceneManager : public SceneManager
28{
29public:
30        KdTreeSceneManager(const String& name, GtpVisibility::VisibilityManager *vm);
31        ~KdTreeSceneManager(void);
[1175]32
[1185]33        virtual const String& getTypeName(void) const;
[1182]34
[1185]35        //typedef std::list<KdTreeSceneNode *> NodeList;
36        //typedef std::list<WireBoundingBox *> BoxList;
[1182]37
[1185]38        /************************************************************************/
39        /* Functions overridden form SceneManager for KdTree                    */
40        /************************************************************************/
[1177]41
[1206]42        /** Override from Scenemanager to create Camera as instance of KdTreeCamera
43        */
44        virtual Camera* createCamera(const String& name);
45
[1185]46        /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode
47        */
48        virtual SceneNode* createSceneNode(void);
49        /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode
50        */
51        virtual SceneNode* createSceneNode(const String& name);
[1182]52
[1185]53        /** Override from Scenemanager, employ kd-tree based culling or CHC
54        */
55        virtual void _findVisibleObjects(Camera *cam, bool onlyShadowCasters);
[1182]56
[1185]57        virtual bool setOption(const String& strKey, const void* pValue);
58        virtual bool getOption(const String& strKey, void* pDestValue);
[1182]59
[1185]60        bool getOptionValues(const String & key, StringVector &refValueList);
61        bool getOptionKeys(StringVector &refKeys);
[1182]62
[1185]63        /** Overide from scene manager to destroy kdtree properly (before the scene graph is destroyed)
64        */
[1285]65        virtual void clearScene();
[1182]66
[1185]67        /************************************************************************/
68        /* Functions overridden from SceneManager for CHC                       */
69        /************************************************************************/
[1163]70
[1185]71        /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
72        */
73        Entity* createEntity(const String& entityName, const String& meshName);
[1182]74
[1185]75        /** Override from scene manager to set up culling manager
76        */
77        virtual void _updateSceneGraph(Camera* cam);
[1182]78
[1185]79        /** Override from SceneManager, employ normal rendering or CHC
80        */
81        virtual void _renderVisibleObjects();
[1182]82
[1185]83        /** Override pass so we can do the z-fail pass.
84        */
[1221]85        virtual const Pass* _setPass(const Pass* pass, bool evenIfSuppressed = false);
[1182]86
[1185]87        /** Render a queue group.
88        Override so we can handle delayed rendering of transparent objects
89        */
90        void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup,
91                QueuedRenderableCollection::OrganisationMode om);
[1182]92
[1185]93        /** Override from scene manager
94        */
95        void _renderQueueGroupObjects(RenderQueueGroup* pGroup,
96                QueuedRenderableCollection::OrganisationMode om);
[1182]97
[1185]98        /** Override from SceneManager so we can skip all but first pass for depth pass.
99        */
100        bool validatePassForRendering(Pass* pass);
[1182]101
[1185]102        /** Override from SceneManager because idontknow
103        */
104        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
105                QueuedRenderableCollection::OrganisationMode om);
106        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
107                QueuedRenderableCollection::OrganisationMode om);
[1182]108
[1175]109
[1185]110        /************************************************************************/
111        /* Functions which are specific to the KdTree                           */
112        /************************************************************************/
113       
114        /** Update the KdTree with the node (more or less disabled now)
115        */
116        virtual void _updateNode(KdTreeSceneNode *node); // TODO:
[1163]117
[1185]118        /** Show or hide the bounding boxes of KdTree nodes - obsolete, use options
119        */
120        virtual void setShowBoxes(bool showboxes);
121        /** Tell if show boxes is enabled - obsolete, use options
122        */
123        virtual bool getShowBoxes(void) const;
[1182]124
[1185]125        /************************************************************************/
126        /* Functions for CHC                                                    */
127        /************************************************************************/
[1173]128
[1185]129        /** Render a list of scenenodes
130        */
[1187]131        //virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam,
132        //      bool onlyShadowCasters, int leavePassesInQueue);
133        virtual void _renderNode(KdTree::NodePtr node, Camera * cam,
[1185]134                bool onlyShadowCasters, int leavePassesInQueue);
[1175]135
[1185]136        /** Sets the visibility manager.
137        @param visManager the visibility manager
138        */
139        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
140        /** See set.
141        */
142        GtpVisibility::VisibilityManager *getVisibilityManager();
[1175]143
[1185]144        /** Returns pointer to visibility manager.
145        */
146        GtpVisibility::VisibilityManager *GetVisibilityManager();
[1175]147
[1185]148        /** Returns hierarchy interface.
149        */
150        KdTreeHierarchyInterface *GetHierarchyInterface();
[1175]151
[1185]152protected:
153        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
154        */
155        void InitDepthPass();
156        /** Creates material for item buffer.
157        */
158        void InitItemBufferPass();
159        /** Fills render queue so that a visualization can be rendered.
160        */
161        void PrepareVisualization(Camera *cam);
162        /** Initialises necessary parameters for hierarchical visibility culling.
163        */
164        void InitVisibilityCulling(Camera *cam);
[1175]165
[1185]166        /** Writes out stats into the Ogre log file.
167        */
168        void WriteLog();
[1175]169
[1206]170        /** Switches between simple & enhanced visibility
171        */
[1211]172        //void setEnhancedVis(bool enhanced);
[1175]173
[1206]174
[1185]175        /************************************************************************/
176        /* CHC-specific options & members                                       */
177        /************************************************************************/
178        // pointer to the visibility manager
179        GtpVisibility::VisibilityManager *mVisibilityManager;
[1163]180
[1185]181        // the hierarchy interface for CHC
182        KdTreeHierarchyInterface *mHierarchyInterface;
[1165]183
[1185]184        // if hierarchical culling is currently in use
185        bool mIsHierarchicalCulling;
[1182]186
[1185]187        // if a visualization of the hierarchical culling is shown
188        bool mShowVisualization;
189       
190        // if the culled nodes are indicated in the visualization
191        bool mVisualizeCulledNodes;
[1182]192
[1185]193        // consecutive number for sub-entities
194        int mCurrentEntityId;
[1175]195
[1185]196        // flag for passes which should not be deleted from queue during first traversal
197        int mLeavePassesInQueue;
[1182]198
[1185]199        // if symbols for the nodes are shown in the visualization
200        bool mRenderNodesForViz;
201        // if content of the nodes is shown in the visualization
202        bool mRenderNodesContentForViz;
203        /// render transparents after the hierarchical traversal
204        bool mDelayRenderTransparents;
205       
206        // if transparent object are considered for item buffer visibility
207        bool mRenderTransparentsForItemBuffer;
208        // Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
209        bool mExecuteVertexProgramForAllPasses;
[1182]210
[1185]211        // the depth pass (no lighting, just filling the depth buffer)
212        Pass *mDepthPass;
213        // use a depth pass (i.e., fill only the depth buffer in the first pass)
214        bool mUseDepthPass;
215        // flag indicating if we currently render the depth pass
216        bool mIsDepthPassPhase;
217        // if depth write should be enabled
218        bool mEnableDepthWrite;
219        // if transparents are skipped during rendering
220        bool mSkipTransparents;
221        // the item buffer pass (render items color-coded)
222        Pass *mItemBufferPass;
223        // if we use an item buffer for rendering (i.e., object ids as color codes
224        bool mUseItemBuffer;
225        // if we currently render the item buffer
226        bool mIsItemBufferPhase;
[1182]227
[1185]228        // remember visited scene nodes for viz
[1187]229        //KdRenderableList mVisibleNodes;
230        KdTree::NodeList mVisibleNodes;
[1163]231
[1251]232        bool mDeleteQueueAfterRendering;
233
[1185]234        /************************************************************************/
235        /* Kd-Tree specific options & members                                   */
236        /************************************************************************/
237        // maximum depth of the kdtree
238        int mMaxDepth;
[1163]239
[1185]240        // the kdtree which holds the scene
241        KdTree *mKdTree;
[1163]242
[1185]243        // if bounding boxes of kdtree nodes are shown
244        bool mShowBoxes;
[1192]245        // bounding boxes of kd nodes will be highlighted on this level of the kd tree
246        int mHiLiteLevel;
247        // if all bounding boxes shall be displayed, not only the highlighted level
248        bool mShowAllBoxes;
249        // visualize kdtree nodes or bounding boxes of objects in nodes
250        bool mShowNodes;
[1170]251
[1214]252        // vis mode
253        bool mEnhancedVisiblity;
254
[1185]255        // the method/algorithm used when rendering the scene
256        KdTree::RenderMethod mRenderMethod;
257
258        // the method of building the tree
259        KdTree::BuildMethod mBuildMethod;
260};
[1163]261
262
263
[1185]264/// Factory for KdTreeSceneManager
265class KdTreeSceneManagerFactory : public SceneManagerFactory
266{
267protected:
268        void initMetaData(void) const;
269        GtpVisibility::VisibilityManager *visManager;
270public:
271        KdTreeSceneManagerFactory(GtpVisibility::VisibilityManager * vm)
[1163]272        {
[1185]273                visManager = vm;
[1163]274        };
[1185]275        ~KdTreeSceneManagerFactory(void) {};
276        /// Factory type name
277        static const String FACTORY_TYPE_NAME;
278        SceneManager* createInstance(const String& instanceName);
279        void destroyInstance(SceneManager* instance);
280};
[1163]281
282} // namespace Ogre
283
284#endif // _KdTreeSceneManager_H__
Note: See TracBrowser for help on using the repository browser.