[33] | 1 | #include "OgreOcclusionCullingTerrainSceneManager.h"
|
---|
| 2 | #include "OgreMath.h"
|
---|
| 3 | #include "OgreIteratorWrappers.h"
|
---|
| 4 | #include "OgreRenderSystem.h"
|
---|
| 5 | #include "OgreCamera.h"
|
---|
| 6 | #include "OgreHardwareOcclusionQuery.h"
|
---|
| 7 | #include "OgreSolidHalfBoundingBox.h"
|
---|
| 8 |
|
---|
[41] | 9 | #include <windows.h>
|
---|
[33] | 10 |
|
---|
| 11 | namespace Ogre {
|
---|
| 12 | //-----------------------------------------------------------------------
|
---|
| 13 | OcclusionCullingTerrainSceneManager::OcclusionCullingTerrainSceneManager()
|
---|
| 14 | {
|
---|
[48] | 15 | mOcclusionCullingOctreeSceneTraverser =
|
---|
| 16 | new OcclusionCullingOctreeSceneTraverser(this, mDestRenderSystem);
|
---|
[40] | 17 |
|
---|
[55] | 18 | //mShowBoxes = true;
|
---|
[41] | 19 | //mDisplayNodes = true;
|
---|
[55] | 20 | //mShowBoundingBoxes = true;
|
---|
[54] | 21 | mMaxDepth = 20;
|
---|
[33] | 22 | }
|
---|
| 23 | //-----------------------------------------------------------------------
|
---|
| 24 | OcclusionCullingTerrainSceneManager::~OcclusionCullingTerrainSceneManager()
|
---|
| 25 | {
|
---|
[48] | 26 | delete mOcclusionCullingOctreeSceneTraverser;
|
---|
[33] | 27 | }
|
---|
| 28 | //-----------------------------------------------------------------------
|
---|
[40] | 29 | void OcclusionCullingTerrainSceneManager::_renderVisibleObjects(void)
|
---|
[33] | 30 | {
|
---|
[40] | 31 | //-- render background
|
---|
| 32 | clearSpecialCaseRenderQueues();
|
---|
| 33 | addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
|
---|
| 34 | addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
|
---|
| 35 |
|
---|
| 36 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
|
---|
[52] | 37 | SceneManager::_renderVisibleObjects();
|
---|
[40] | 38 | _deleteRenderedQueueGroups();
|
---|
| 39 |
|
---|
| 40 | //-- render visible objects (i.e., all but overlay)
|
---|
| 41 | clearSpecialCaseRenderQueues();
|
---|
| 42 | addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
|
---|
| 43 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
|
---|
| 44 |
|
---|
[48] | 45 | mOcclusionCullingOctreeSceneTraverser->setSceneRoot(mOctree);
|
---|
| 46 | mOcclusionCullingOctreeSceneTraverser->renderScene(mCameraInProgress);
|
---|
[42] | 47 |
|
---|
[40] | 48 | _deleteRenderedQueueGroups();
|
---|
| 49 |
|
---|
| 50 | //-- render overlay
|
---|
| 51 | clearSpecialCaseRenderQueues();
|
---|
| 52 | SceneManager::_renderVisibleObjects( );
|
---|
[33] | 53 | }
|
---|
| 54 | //-----------------------------------------------------------------------
|
---|
| 55 | void OcclusionCullingTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
|
---|
| 56 | {
|
---|
| 57 | // must be empty because objects are found and rendered in an interleaved fashion
|
---|
| 58 | // in _renderVisibibleObjects
|
---|
| 59 | }
|
---|
| 60 | //-----------------------------------------------------------------------
|
---|
| 61 | void OcclusionCullingTerrainSceneManager::_updateSceneGraph(Camera* cam)
|
---|
| 62 | {
|
---|
[52] | 63 | mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size());
|
---|
[48] | 64 | mOcclusionCullingOctreeSceneTraverser->setRenderSystem(mDestRenderSystem);
|
---|
[44] | 65 |
|
---|
[48] | 66 | mOcclusionCullingOctreeSceneTraverser->setNumOctreeNodes(mNumOctreeNodes);
|
---|
[33] | 67 |
|
---|
| 68 | TerrainSceneManager::_updateSceneGraph(cam);
|
---|
[40] | 69 | }
|
---|
[33] | 70 | //-----------------------------------------------------------------------
|
---|
| 71 | bool OcclusionCullingTerrainSceneManager::setOption( const String & key, const void * val )
|
---|
| 72 | {
|
---|
[48] | 73 | return mOcclusionCullingOctreeSceneTraverser->setOption( key, val) || TerrainSceneManager::setOption( key, val );
|
---|
[33] | 74 | }
|
---|
| 75 | //-----------------------------------------------------------------------
|
---|
| 76 | bool OcclusionCullingTerrainSceneManager::getOption( const String & key, void *val )
|
---|
| 77 | {
|
---|
[48] | 78 | return mOcclusionCullingOctreeSceneTraverser->getOption( key, val) || TerrainSceneManager::getOption( key, val ) ;
|
---|
[33] | 79 | }
|
---|
| 80 | //-----------------------------------------------------------------------
|
---|
| 81 | bool OcclusionCullingTerrainSceneManager::getOptionValues( const String & key, StringVector &refValueList )
|
---|
| 82 | {
|
---|
| 83 | return TerrainSceneManager::getOptionValues( key, refValueList );
|
---|
| 84 | }
|
---|
| 85 | //-----------------------------------------------------------------------
|
---|
| 86 | bool OcclusionCullingTerrainSceneManager::getOptionKeys( StringVector & refKeys )
|
---|
| 87 | {
|
---|
[48] | 88 | return mOcclusionCullingOctreeSceneTraverser->getOptionKeys ( refKeys ) || TerrainSceneManager::getOptionKeys( refKeys );
|
---|
[33] | 89 | }
|
---|
[40] | 90 | //-----------------------------------------------------------------------
|
---|
[33] | 91 | }
|
---|