source: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h @ 26

Revision 26, 3.6 KB checked in by gametools, 20 years ago (diff)
RevLine 
[12]1#ifndef _OcclusionCullingSceneManager_H__
2#define _OcclusionCullingSceneManager_H__
3
4#include "OgreSceneNode.h"
5#include "OgreSceneManager.h"
6#include "OgrePrerequisites.h"
[26]7#include "OgreSolidHalfBoundingBox.h"
[12]8#include <queue>
9
10using namespace std;
11
12namespace Ogre {
13        /**
14                This class implements the compare operator for the priority queue.
15                a lower distance has a higher value in the queue
16        */
17        template <typename T> class myless
18        {
19        public:
[19]20                myless(Camera *cam) { mCamera = cam; }
[12]21                //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
22                bool operator() (T v1, T v2) const
23                {
[19]24                        return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera);
[12]25                }
[19]26        private:
27                Camera *mCamera;
[12]28        };
29
[26]30        typedef pair<SceneNode *, HardwareOcclusionQuery *> query_pair;
[12]31        typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;
[26]32        typedef queue<query_pair> QueryQueue;
[12]33        /**
34                Class which implements a scene mangager which uses occlusion queries for culling occluded objects
35        */
36        class OcclusionCullingSceneManager : public SceneManager
37        {
38        public:
39                OcclusionCullingSceneManager();
[22]40                ~OcclusionCullingSceneManager();
[12]41       
[26]42
43                enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
44               
45                /** Overriden from SceneManager. Renders the scene with the specified algorithm
46                /**
47                        The algorithm is one of
48                        RENDER_CULL_FRUSTUM: renders the scene with view frustum culling only
49                        RENDER_STOP_AND_WAIT: renders the scene with the hierarchical stop and wait algorithm
50                        RENDER_COHERENT: renders the scene with the coherent hierarchical algorithm
51                */
[12]52                void _renderVisibleObjects(void);
[19]53                void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
[22]54                void _updateSceneGraph(Camera* cam);
55
[12]56        protected:
[22]57                enum {MODE_QUERY, MODE_RENDER};
[12]58
[22]59                int isLeaf(SceneNode *node);
60                int countSceneNodes(SceneNode *node);
[19]61                void renderZPass();
62                void traverseNode(SceneNode *node);
[22]63                /** Renders current node */
64                void render(SceneNode *node);
65                /** Sets rendering mode, e.g. query mode or render mode*/
66                void setRenderingMode(int mode);
[21]67               
[22]68                /** Renders the scene with view frustum culling only. */
69                void renderCullFrustum();
70                /** Renders the scene with the hierarchical stop and wait algorithm. */
71                void renderStopAndWait();
72                /** Renders the scene with the coherent hierarchical algorithm and the query queye. */
73                void renderCoherentWithQueue();
74                /** Issue a occlusion query for this node. */
[26]75                HardwareOcclusionQuery *issueOcclusionQuery(SceneNode *node, bool wasVisible);
[22]76                /** Pulls up the visibility from the child nodes. */
77                void pullUpVisibility(SceneNode *node);
[26]78                /** delete all previously defined occlusion queries */
[22]79                void deleteQueries();
[26]80                /** Renders bounding box of specified node.
81                @param the node which bounding box is to be rendered
82                */
83                void renderBoundingBox(SceneNode *node);
84                /** Returns one half of the bounding box.
85                @param the half of the bouding box
86                */
87                SolidHalfBoundingBox *getSolidHalfBoundingBox(int half);
88                /** sets the type of the algorithm
89                @param algorithm type
90                */
91                void setAlgorithmType(int type);
92       
93                int getAlgorithmType();
[22]94
[26]95                // we use a priority queue rather than a renderstack
[19]96                PriorityQueue *mDistanceQueue;
[26]97               
[23]98                unsigned int mFrameId;
[22]99                unsigned int mVisibilityThreshold;
100                unsigned int mNumSceneNodes;
[21]101                int mCurrentTestIdx;
[22]102                int mQueryMode;
103               
[21]104                std::vector<HardwareOcclusionQuery *> mOcclusionQueries;
[26]105                // two halfes of a aabb
106                SolidHalfBoundingBox *mHalfBoundingBox[2];     
107                int mAlgorithmType;
[12]108        };
109
110}
111#endif // OCCLUSIONCULLINGSCENEMANAGER_H
Note: See TracBrowser for help on using the repository browser.