[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] | 19 | myless(Camera *cam) { mCamera = cam; } |
---|
[12] | 20 | //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
|
---|
| 21 | bool operator() (T v1, T v2) const
|
---|
| 22 | {
|
---|
[19] | 23 | return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera);
|
---|
[12] | 24 | }
|
---|
[19] | 25 | private:
|
---|
| 26 | Camera *mCamera;
|
---|
[12] | 27 | };
|
---|
| 28 |
|
---|
| 29 | typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | Class which implements a scene mangager which uses occlusion queries for culling occluded objects
|
---|
| 33 | */
|
---|
| 34 | class OcclusionCullingSceneManager : public SceneManager
|
---|
| 35 | {
|
---|
| 36 | public:
|
---|
| 37 | enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
|
---|
| 38 |
|
---|
| 39 | OcclusionCullingSceneManager();
|
---|
| 40 |
|
---|
| 41 | /** Overriden from SceneManager. */
|
---|
| 42 | void _renderVisibleObjects(void);
|
---|
[19] | 43 | void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
|
---|
| 44 |
|
---|
[12] | 45 | protected:
|
---|
| 46 |
|
---|
[19] | 47 | void renderZPass();
|
---|
| 48 | void traverseNode(SceneNode *node);
|
---|
| 49 | void renderSceneNode(SceneNode *node);
|
---|
[12] | 50 | /** renders the scene with view frustum culling only */
|
---|
| 51 | void renderCullFrustum();
|
---|
| 52 |
|
---|
| 53 | /** we use a priority queue rather than a renderstack */
|
---|
[19] | 54 | PriorityQueue *mDistanceQueue;
|
---|
| 55 | // RenderQueue* mDistanceQueue;
|
---|
| 56 |
|
---|
[12] | 57 | int mFrameID;
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | }
|
---|
| 61 | #endif // OCCLUSIONCULLINGSCENEMANAGER_H |
---|