source: trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp @ 155

Revision 155, 4.8 KB checked in by mattausch, 19 years ago (diff)

added node traversal interface

RevLine 
[59]1#include <OgreMath.h>
2#include <OgreIteratorWrappers.h>
3#include <OgreRenderSystem.h>
4#include <OgreCamera.h>
5#include "OgreVisibilitySceneManager.h"
6#include "OgreSceneNodeHierarchyInterface.h"
[74]7#include "OgreVisibilityOptionsManager.h"
[59]8
9
10namespace Ogre {
[96]11
[59]12//-----------------------------------------------------------------------
13VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager)
[115]14:mVisibilityManager(visManager), mUseDepthPass(false), mShowVisualization(false)
[59]15{
[103]16        mHierarchyInterface =
17                new SceneNodeHierarchyInterface(this, mDestRenderSystem);
[59]18}
19//-----------------------------------------------------------------------
20VisibilitySceneManager::~VisibilitySceneManager()
21{
22        delete mHierarchyInterface;
23}
24//-----------------------------------------------------------------------
25void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
26{
[111]27        mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
[103]28        // does nothing if hierarchical culling is used =>
[87]29        // we interleave identification and rendering of objects
[103]30        // in _renderVisibibleObjects
[115]31        if (!mUseDepthPass)
[87]32        {
33                SceneManager::_findVisibleObjects(cam, onlyShadowCasters);
[103]34                return;
[87]35        }
[59]36}
37//-----------------------------------------------------------------------
38void VisibilitySceneManager::_renderVisibleObjects()
39{
[112]40        if (!mShowVisualization)
41        {
[155]42                mHierarchyInterface->SetHierarchyRoot(mSceneRoot);
43                mHierarchyInterface->InitTraversal(mCameraInProgress);
[103]44
[139]45                // reset culling manager stats
[112]46                mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
47        }
[87]48
[103]49        // standard terrain scenemanager rendering without hierarchical culling
[115]50        if (!mUseDepthPass || mShowVisualization)
[87]51        {       
52                SceneManager::_renderVisibleObjects();
[112]53       
[87]54                return;
55        }
[112]56
[87]57        //-- hierarchical culling
58        // the objects of different layers (e.g., background, scene,
59        // overlay) must be identified and rendered one after another
60
61        //-- render background
[59]62        clearSpecialCaseRenderQueues();
63        addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
64        addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
65
66        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
[87]67        SceneManager::_renderVisibleObjects();
[103]68
[59]69#ifdef GTP_VISIBILITY_MODIFIED_OGRE
[139]70        _deleteRenderedQueueGroups();
[59]71#endif
[87]72
[59]73        //-- render visible objects (i.e., all but overlay)
74        clearSpecialCaseRenderQueues();
75        addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
76        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
77
[103]78
79        /**
80        * the hierarchical culling algorithm
81        **/
[59]82        mVisibilityManager->ApplyVisibilityCulling();
83
[103]84
[59]85#ifdef GTP_VISIBILITY_MODIFIED_OGRE
[139]86        _deleteRenderedQueueGroups();
[59]87#endif
88
89        //-- render overlay
90        clearSpecialCaseRenderQueues();
[87]91        SceneManager::_renderVisibleObjects();
[103]92
93        //WriteLog(); // write out stats
[59]94}
95//-----------------------------------------------------------------------
96void VisibilitySceneManager::_updateSceneGraph(Camera* cam)
97{
98        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
99        mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
100       
101        SceneManager::_updateSceneGraph(cam);
102}
103//-----------------------------------------------------------------------
104bool VisibilitySceneManager::setOption(const String & key, const void * val)
105{
[74]106        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
107                setOption(key, val) || SceneManager::setOption(key, val);
[59]108}
109//-----------------------------------------------------------------------
110bool VisibilitySceneManager::getOption(const String & key, void *val)
111{
[74]112        if (key == "NumHierarchyNodes")
113        {
114                * static_cast<unsigned int *>(val) = (unsigned int)mSceneNodes.size();
115                return true;
116        }
[59]117       
[74]118        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
119                getOption(key, val) && SceneManager::getOption(key, val);
[59]120}
121//-----------------------------------------------------------------------
122bool VisibilitySceneManager::getOptionValues(const String & key, StringVector  &refValueList)
123{
124        return SceneManager::getOptionValues(key, refValueList);
125}
126//-----------------------------------------------------------------------
127bool VisibilitySceneManager::getOptionKeys(StringVector & refKeys)
128{
[74]129        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
130                getOptionKeys(refKeys) || SceneManager::getOptionKeys(refKeys);
[59]131}
132//-----------------------------------------------------------------------
133void VisibilitySceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
134{
135        mVisibilityManager = visManager;
136}
137//-----------------------------------------------------------------------
[115]138GtpVisibility::VisibilityManager *VisibilitySceneManager::getVisibilityManager()
[59]139{
140        return mVisibilityManager;
141}
142
143} // namespace Ogre
Note: See TracBrowser for help on using the repository browser.