[657] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #include "OgreStableHeaders.h"
|
---|
| 26 | #include "OgreSceneManagerEnumerator.h"
|
---|
| 27 |
|
---|
| 28 | #include "OgreDynLibManager.h"
|
---|
| 29 | #include "OgreDynLib.h"
|
---|
| 30 | #include "OgreConfigFile.h"
|
---|
| 31 | #include "OgreMaterial.h"
|
---|
| 32 | #include "OgreException.h"
|
---|
| 33 | #include "OgreRoot.h"
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | namespace Ogre {
|
---|
| 37 |
|
---|
| 38 | //-----------------------------------------------------------------------
|
---|
| 39 | template<> SceneManagerEnumerator* Singleton<SceneManagerEnumerator>::ms_Singleton = 0;
|
---|
| 40 | SceneManagerEnumerator* SceneManagerEnumerator::getSingletonPtr(void)
|
---|
| 41 | {
|
---|
| 42 | return ms_Singleton;
|
---|
| 43 | }
|
---|
| 44 | SceneManagerEnumerator& SceneManagerEnumerator::getSingleton(void)
|
---|
| 45 | {
|
---|
| 46 | assert( ms_Singleton ); return ( *ms_Singleton );
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | //-----------------------------------------------------------------------
|
---|
| 50 | SceneManagerEnumerator::SceneManagerEnumerator()
|
---|
| 51 | {
|
---|
| 52 | // Create default manager
|
---|
| 53 | mDefaultManager = new SceneManager();
|
---|
| 54 |
|
---|
| 55 | // All scene types defaulted to begin with (plugins may alter this)
|
---|
| 56 | setSceneManager(ST_GENERIC, mDefaultManager);
|
---|
| 57 | setSceneManager(ST_EXTERIOR_REAL_FAR, mDefaultManager);
|
---|
| 58 | setSceneManager(ST_EXTERIOR_FAR, mDefaultManager);
|
---|
| 59 | setSceneManager(ST_EXTERIOR_CLOSE, mDefaultManager);
|
---|
| 60 | setSceneManager(ST_INTERIOR, mDefaultManager);
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | }
|
---|
| 65 | //-----------------------------------------------------------------------
|
---|
| 66 | SceneManagerEnumerator::~SceneManagerEnumerator()
|
---|
| 67 | {
|
---|
| 68 | delete mDefaultManager;
|
---|
| 69 | }
|
---|
| 70 | //-----------------------------------------------------------------------
|
---|
| 71 | SceneManager* SceneManagerEnumerator::getSceneManager(SceneType st)
|
---|
| 72 | {
|
---|
| 73 | SceneManagerList::iterator i = mSceneManagers.find(st);
|
---|
| 74 |
|
---|
| 75 | if (i != mSceneManagers.end())
|
---|
| 76 | {
|
---|
| 77 | return i->second;
|
---|
| 78 | }
|
---|
| 79 | else
|
---|
| 80 | {
|
---|
| 81 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Cannot find requested SceneManager.", "SceneManagerEnumerator::getSceneManager");
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | //-----------------------------------------------------------------------
|
---|
| 88 | void SceneManagerEnumerator::setRenderSystem(RenderSystem* rs)
|
---|
| 89 | {
|
---|
| 90 | std::set<SceneManager*>::iterator i = mUniqueSceneMgrs.begin();
|
---|
| 91 |
|
---|
| 92 | for(; i != mUniqueSceneMgrs.end(); ++i)
|
---|
| 93 | {
|
---|
| 94 | (*i)->_setDestinationRenderSystem(rs);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | //-----------------------------------------------------------------------
|
---|
| 100 | void SceneManagerEnumerator::setSceneManager(SceneType st, SceneManager* sm)
|
---|
| 101 | {
|
---|
| 102 | // Find entry (may exist)
|
---|
| 103 | SceneManagerList::iterator i = mSceneManagers.find(st);
|
---|
| 104 |
|
---|
| 105 | if (i == mSceneManagers.end())
|
---|
| 106 | {
|
---|
| 107 | // Insert
|
---|
| 108 | mSceneManagers.insert(SceneManagerList::value_type(st, sm));
|
---|
| 109 | }
|
---|
| 110 | else
|
---|
| 111 | {
|
---|
| 112 | // Override
|
---|
| 113 | i->second = sm;
|
---|
| 114 | }
|
---|
| 115 | // Add to unique set
|
---|
| 116 | mUniqueSceneMgrs.insert(sm);
|
---|
| 117 | }
|
---|
| 118 | //-----------------------------------------------------------------------
|
---|
| 119 | void SceneManagerEnumerator::shutdownAll(void)
|
---|
| 120 | {
|
---|
| 121 | std::set<SceneManager*>::iterator i;
|
---|
| 122 | for (i = mUniqueSceneMgrs.begin(); i != mUniqueSceneMgrs.end(); ++i)
|
---|
| 123 | {
|
---|
| 124 | (*i)->clearScene();
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | }
|
---|