00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreStableHeaders.h" 00026 #include "OgreSceneManagerEnumerator.h" 00027 00028 #include "OgreDynLibManager.h" 00029 #include "OgreDynLib.h" 00030 #include "OgreConfigFile.h" 00031 #include "OgreMaterial.h" 00032 #include "OgreException.h" 00033 #include "OgreRoot.h" 00034 00035 00036 namespace Ogre { 00037 00038 //----------------------------------------------------------------------- 00039 template<> SceneManagerEnumerator* Singleton<SceneManagerEnumerator>::ms_Singleton = 0; 00040 00041 //----------------------------------------------------------------------- 00042 SceneManagerEnumerator::SceneManagerEnumerator() 00043 { 00044 // Create default manager 00045 mDefaultManager = new SceneManager(); 00046 00047 // All scene types defaulted to begin with (plugins may alter this) 00048 setSceneManager(ST_GENERIC, mDefaultManager); 00049 setSceneManager(ST_EXTERIOR_REAL_FAR, mDefaultManager); 00050 setSceneManager(ST_EXTERIOR_FAR, mDefaultManager); 00051 setSceneManager(ST_EXTERIOR_CLOSE, mDefaultManager); 00052 setSceneManager(ST_INTERIOR, mDefaultManager); 00053 00054 00055 00056 } 00057 //----------------------------------------------------------------------- 00058 SceneManagerEnumerator::~SceneManagerEnumerator() 00059 { 00060 delete mDefaultManager; 00061 } 00062 //----------------------------------------------------------------------- 00063 SceneManager* SceneManagerEnumerator::getSceneManager(SceneType st) 00064 { 00065 SceneManagerList::iterator i = mSceneManagers.find(st); 00066 00067 if (i != mSceneManagers.end()) 00068 { 00069 return i->second; 00070 } 00071 else 00072 { 00073 Except(Exception::ERR_INTERNAL_ERROR, "Cannot find requested SceneManager.", "SceneManagerEnumerator::getSceneManager"); 00074 } 00075 } 00076 00077 00078 00079 //----------------------------------------------------------------------- 00080 void SceneManagerEnumerator::setRenderSystem(RenderSystem* rs) 00081 { 00082 std::set<SceneManager*>::iterator i = mUniqueSceneMgrs.begin(); 00083 00084 for(; i != mUniqueSceneMgrs.end(); ++i) 00085 { 00086 (*i)->_setDestinationRenderSystem(rs); 00087 } 00088 00089 } 00090 00091 //----------------------------------------------------------------------- 00092 void SceneManagerEnumerator::setSceneManager(SceneType st, SceneManager* sm) 00093 { 00094 // Find entry (may exist) 00095 SceneManagerList::iterator i = mSceneManagers.find(st); 00096 00097 if (i == mSceneManagers.end()) 00098 { 00099 // Insert 00100 mSceneManagers.insert(SceneManagerList::value_type(st, sm)); 00101 } 00102 else 00103 { 00104 // Override 00105 i->second = sm; 00106 } 00107 // Add to unique set 00108 mUniqueSceneMgrs.insert(sm); 00109 00110 00111 // Set rendersystem, incase this one is late & rendersystem already picked 00112 sm->_setDestinationRenderSystem(Root::getSingleton().getRenderSystem()); 00113 00114 00115 00116 } 00117 //----------------------------------------------------------------------- 00118 void SceneManagerEnumerator::shutdownAll(void) 00119 { 00120 std::set<SceneManager*>::iterator i; 00121 for (i = mUniqueSceneMgrs.begin(); i != mUniqueSceneMgrs.end(); ++i) 00122 { 00123 (*i)->clearScene(); 00124 } 00125 00126 } 00127 //----------------------------------------------------------------------- 00128 SceneManagerEnumerator& SceneManagerEnumerator::getSingleton(void) 00129 { 00130 return Singleton<SceneManagerEnumerator>::getSingleton(); 00131 } 00132 00133 00134 }
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:26 2004