[12] | 1 | #ifndef _OcclusionCullingSceneManager_H__
|
---|
| 2 | #define _OcclusionCullingSceneManager_H__
|
---|
| 3 |
|
---|
| 4 | #include "OgreSceneNode.h"
|
---|
| 5 | #include "OgreSceneManager.h"
|
---|
| 6 | #include "OgrePrerequisites.h"
|
---|
| 7 | #include <queue>
|
---|
| 8 |
|
---|
| 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | namespace Ogre { |
---|
| 12 | /** |
---|
| 13 | This class implements the compare operator for the priority queue. |
---|
| 14 | a lower distance has a higher value in the queue |
---|
| 15 | */ |
---|
| 16 | template <typename T> class myless
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
| 19 | |
---|
| 20 | //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
|
---|
| 21 | bool operator() (T v1, T v2) const
|
---|
| 22 | {
|
---|
| 23 | return true;//(v1->getSquaredViewDepth(cam) > v2->getSquaredViewDepth(cam));
|
---|
| 24 | }
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | Class which implements a scene mangager which uses occlusion queries for culling occluded objects
|
---|
| 31 | */
|
---|
| 32 | class OcclusionCullingSceneManager : public SceneManager
|
---|
| 33 | {
|
---|
| 34 | public:
|
---|
| 35 | enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
|
---|
| 36 |
|
---|
| 37 | OcclusionCullingSceneManager();
|
---|
| 38 |
|
---|
| 39 | /** Overriden from SceneManager. */
|
---|
| 40 | void _renderVisibleObjects(void);
|
---|
| 41 |
|
---|
| 42 | protected:
|
---|
| 43 |
|
---|
| 44 | void walkTree(SceneNode *node);
|
---|
| 45 |
|
---|
| 46 | /** renders the scene with view frustum culling only */
|
---|
| 47 | void renderCullFrustum();
|
---|
| 48 |
|
---|
| 49 | /** we use a priority queue rather than a renderstack */
|
---|
| 50 | PriorityQueue mDistanceQueue;
|
---|
| 51 |
|
---|
| 52 | int mFrameID;
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | }
|
---|
| 56 | #endif // OCCLUSIONCULLINGSCENEMANAGER_H |
---|