1 | #include "OgreVisibilityTerrainSceneManager.h"
|
---|
2 | #include "OgreOctreeHierarchyInterface.h"
|
---|
3 | #include "OgreVisibilityOptionsManager.h"
|
---|
4 | #include <OgreMath.h>
|
---|
5 | #include <OgreIteratorWrappers.h>
|
---|
6 | #include <OgreRenderSystem.h>
|
---|
7 | #include <OgreCamera.h>
|
---|
8 |
|
---|
9 | //#include <windows.h>
|
---|
10 |
|
---|
11 | namespace Ogre {
|
---|
12 | //namespace GtpVisibility {
|
---|
13 | //-----------------------------------------------------------------------
|
---|
14 | VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager)
|
---|
15 | :mVisibilityManager(visManager)
|
---|
16 | {
|
---|
17 | mHierarchyInterface =
|
---|
18 | new OctreeHierarchyInterface(this, mDestRenderSystem);
|
---|
19 |
|
---|
20 | setVisibilityManager(visManager);
|
---|
21 | mShowBoxes = true;
|
---|
22 | //mDisplayNodes = true;
|
---|
23 | mShowBoundingBoxes = true;
|
---|
24 | mMaxDepth = 20;
|
---|
25 | }
|
---|
26 | //-----------------------------------------------------------------------
|
---|
27 | VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()
|
---|
28 | {
|
---|
29 | delete mHierarchyInterface;
|
---|
30 | }
|
---|
31 | //-----------------------------------------------------------------------
|
---|
32 | void VisibilityTerrainSceneManager::_renderVisibleObjects()
|
---|
33 | {
|
---|
34 | //-- render background
|
---|
35 | clearSpecialCaseRenderQueues();
|
---|
36 | addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
|
---|
37 | addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
|
---|
38 |
|
---|
39 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
|
---|
40 | SceneManager::_renderVisibleObjects();
|
---|
41 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
42 | _deleteRenderedQueueGroups();
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | //-- render visible objects (i.e., all but overlay)
|
---|
46 | clearSpecialCaseRenderQueues();
|
---|
47 | addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
|
---|
48 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
|
---|
49 |
|
---|
50 | mHierarchyInterface->InitFrame(mOctree, mCameraInProgress);
|
---|
51 | mVisibilityManager->ApplyVisibilityCulling();
|
---|
52 |
|
---|
53 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
54 | _deleteRenderedQueueGroups();
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | //-- render overlay
|
---|
58 | clearSpecialCaseRenderQueues();
|
---|
59 | SceneManager::_renderVisibleObjects( );
|
---|
60 | }
|
---|
61 | //-----------------------------------------------------------------------
|
---|
62 | void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
|
---|
63 | {
|
---|
64 | // must be empty because objects are found and rendered in an interleaved fashion
|
---|
65 | // in _renderVisibibleObjects
|
---|
66 | }
|
---|
67 | //-----------------------------------------------------------------------
|
---|
68 | void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)
|
---|
69 | {
|
---|
70 | //mHierarchyInterface->setNumSceneNodes((int)mSceneNodes.size());
|
---|
71 | mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
|
---|
72 | mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
|
---|
73 |
|
---|
74 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
75 | mHierarchyInterface->SetNumOctreeNodes(mNumOctreeNodes);
|
---|
76 | #endif
|
---|
77 | TerrainSceneManager::_updateSceneGraph(cam);
|
---|
78 | }
|
---|
79 | //-----------------------------------------------------------------------
|
---|
80 | bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)
|
---|
81 | {
|
---|
82 | return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
|
---|
83 | setOption(key, val) || TerrainSceneManager::setOption(key, val);
|
---|
84 | }
|
---|
85 | //-----------------------------------------------------------------------
|
---|
86 | bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)
|
---|
87 | {
|
---|
88 | if (key == "NumHierarchyNodes")
|
---|
89 | {
|
---|
90 | * static_cast<unsigned int *>(val) = (unsigned int)mNumOctreeNodes;
|
---|
91 | return true;
|
---|
92 | }
|
---|
93 |
|
---|
94 | return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
|
---|
95 | getOption(key, val) && TerrainSceneManager::getOption(key, val);
|
---|
96 | }
|
---|
97 | //-----------------------------------------------------------------------
|
---|
98 | bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector &refValueList)
|
---|
99 | {
|
---|
100 | return TerrainSceneManager::getOptionValues( key, refValueList);
|
---|
101 | }
|
---|
102 | //-----------------------------------------------------------------------
|
---|
103 | bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)
|
---|
104 | {
|
---|
105 | return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
|
---|
106 | getOptionKeys(refKeys) || TerrainSceneManager::getOptionKeys(refKeys);
|
---|
107 | }
|
---|
108 | //-----------------------------------------------------------------------
|
---|
109 | void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
|
---|
110 | {
|
---|
111 | mVisibilityManager = visManager;
|
---|
112 | }
|
---|
113 | //-----------------------------------------------------------------------
|
---|
114 | GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void )
|
---|
115 | {
|
---|
116 | return mVisibilityManager;
|
---|
117 | }
|
---|
118 | //} // namespace GtpVisibility
|
---|
119 | } // namespace Ogre
|
---|