Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreSceneManagerEnumerator.cpp

Go to the documentation of this file.
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     SceneManagerEnumerator* SceneManagerEnumerator::getSingletonPtr(void)
00041     {
00042         return ms_Singleton;
00043     }
00044     SceneManagerEnumerator& SceneManagerEnumerator::getSingleton(void)
00045     {  
00046         assert( ms_Singleton );  return ( *ms_Singleton );  
00047     }
00048 
00049     //-----------------------------------------------------------------------
00050     SceneManagerEnumerator::SceneManagerEnumerator()
00051     {
00052         // Create default manager
00053         mDefaultManager = new SceneManager();
00054 
00055         // All scene types defaulted to begin with (plugins may alter this)
00056         setSceneManager(ST_GENERIC, mDefaultManager);
00057         setSceneManager(ST_EXTERIOR_REAL_FAR, mDefaultManager);
00058         setSceneManager(ST_EXTERIOR_FAR, mDefaultManager);
00059         setSceneManager(ST_EXTERIOR_CLOSE, mDefaultManager);
00060         setSceneManager(ST_INTERIOR, mDefaultManager);
00061 
00062 
00063 
00064     }
00065     //-----------------------------------------------------------------------
00066     SceneManagerEnumerator::~SceneManagerEnumerator()
00067     {
00068         delete mDefaultManager;
00069     }
00070     //-----------------------------------------------------------------------
00071     SceneManager* SceneManagerEnumerator::getSceneManager(SceneType st)
00072     {
00073         SceneManagerList::iterator i = mSceneManagers.find(st);
00074 
00075         if (i != mSceneManagers.end())
00076         {
00077             return i->second;
00078         }
00079         else
00080         {
00081             Except(Exception::ERR_INTERNAL_ERROR, "Cannot find requested SceneManager.", "SceneManagerEnumerator::getSceneManager");
00082         }
00083     }
00084 
00085 
00086 
00087     //-----------------------------------------------------------------------
00088     void SceneManagerEnumerator::setRenderSystem(RenderSystem* rs)
00089     {
00090         std::set<SceneManager*>::iterator i = mUniqueSceneMgrs.begin();
00091 
00092         for(; i != mUniqueSceneMgrs.end(); ++i)
00093         {
00094             (*i)->_setDestinationRenderSystem(rs);
00095         }
00096 
00097     }
00098 
00099     //-----------------------------------------------------------------------
00100     void SceneManagerEnumerator::setSceneManager(SceneType st, SceneManager* sm)
00101     {
00102         // Find entry (may exist)
00103         SceneManagerList::iterator i = mSceneManagers.find(st);
00104 
00105         if (i == mSceneManagers.end())
00106         {
00107             // Insert
00108             mSceneManagers.insert(SceneManagerList::value_type(st, sm));
00109         }
00110         else
00111         {
00112             // Override
00113             i->second = sm;
00114         }
00115         // Add to unique set
00116         mUniqueSceneMgrs.insert(sm);
00117 
00118 
00119         // Set rendersystem, incase this one is late & rendersystem already picked
00120         sm->_setDestinationRenderSystem(Root::getSingleton().getRenderSystem());
00121 
00122 
00123 
00124     }
00125     //-----------------------------------------------------------------------
00126     void SceneManagerEnumerator::shutdownAll(void)
00127     {
00128         std::set<SceneManager*>::iterator i;
00129         for (i = mUniqueSceneMgrs.begin(); i != mUniqueSceneMgrs.end(); ++i)
00130         {
00131             (*i)->clearScene();
00132         }
00133 
00134     }
00135 
00136 
00137 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:44 2004