[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 | #ifndef __SceneManagerEnumerator_H__
|
---|
| 26 | #define __SceneManagerEnumerator_H__
|
---|
| 27 |
|
---|
| 28 | #include "OgrePrerequisites.h"
|
---|
| 29 |
|
---|
| 30 | #include "OgreSceneManager.h"
|
---|
| 31 | #include "OgreSingleton.h"
|
---|
| 32 |
|
---|
| 33 | namespace Ogre {
|
---|
| 34 | /** Classification of a scene to allow a decision of what type of
|
---|
| 35 | SceenManager to provide back to the application.
|
---|
| 36 | */
|
---|
| 37 | enum SceneType
|
---|
| 38 | {
|
---|
| 39 | ST_GENERIC,
|
---|
| 40 | ST_EXTERIOR_CLOSE,
|
---|
| 41 | ST_EXTERIOR_FAR,
|
---|
| 42 | ST_EXTERIOR_REAL_FAR,
|
---|
| 43 | ST_INTERIOR
|
---|
| 44 | };
|
---|
| 45 | /** Enumerates the SceneManager classes available to applications.
|
---|
| 46 | @remarks
|
---|
| 47 | As described in the SceneManager class, SceneManagers are responsible
|
---|
| 48 | for organising the scene and issuing rendering commands to the
|
---|
| 49 | RenderSystem. Certain scene types can benefit from different
|
---|
| 50 | rendering approaches, and it is intended that subclasses will
|
---|
| 51 | be created to special case this.
|
---|
| 52 | @par
|
---|
| 53 | In order to give applications easy access to these implementations,
|
---|
| 54 | the Root object has a getSceneManager method to retrieve a SceneManager
|
---|
| 55 | which is appropriate to the scene type. However, this is the class
|
---|
| 56 | which implements this behaviour and defines the scene types, because
|
---|
| 57 | it is intended that the Root class is not customised by everybody
|
---|
| 58 | (and it may be restricted access in the future).
|
---|
| 59 | @par
|
---|
| 60 | If you customise Ogre and want to add a new SceneManager implementation
|
---|
| 61 | (e.g. an Octree-based scene manager for outside locations), feel
|
---|
| 62 | free to customise this class so that it is passed back where
|
---|
| 63 | required.
|
---|
| 64 | @par
|
---|
| 65 | For this early release of Ogre, only the basic SceneManager implementation
|
---|
| 66 | is passed back for all scene types. This is a highly generic and
|
---|
| 67 | extremely unoptimised reference implementation.
|
---|
| 68 | */
|
---|
| 69 | class _OgreExport SceneManagerEnumerator : public Singleton<SceneManagerEnumerator>
|
---|
| 70 | {
|
---|
| 71 | private:
|
---|
| 72 | // Set of SceneManagers (unique entries)
|
---|
| 73 | std::set<SceneManager*> mUniqueSceneMgrs;
|
---|
| 74 | // Collection of loaded scene managers, keyed by scene type
|
---|
| 75 | typedef std::map<SceneType, SceneManager*> SceneManagerList ;
|
---|
| 76 | SceneManagerList mSceneManagers;
|
---|
| 77 |
|
---|
| 78 | /// Standard scene manager for default management
|
---|
| 79 | SceneManager* mDefaultManager;
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | public:
|
---|
| 83 | SceneManagerEnumerator();
|
---|
| 84 | ~SceneManagerEnumerator();
|
---|
| 85 |
|
---|
| 86 | /** Sets a SceneManager implementation.
|
---|
| 87 | */
|
---|
| 88 | void setSceneManager(SceneType st, SceneManager* sm);
|
---|
| 89 |
|
---|
| 90 | /** Implementation of SceneManager retrieval.
|
---|
| 91 | */
|
---|
| 92 | SceneManager* getSceneManager(SceneType st);
|
---|
| 93 |
|
---|
| 94 | /** Notifies all SceneManagers of the destination rendering system.
|
---|
| 95 | */
|
---|
| 96 | void setRenderSystem(RenderSystem* rs);
|
---|
| 97 |
|
---|
| 98 | /// Utility method to control shutdown of the managers
|
---|
| 99 | void shutdownAll(void);
|
---|
| 100 | /** Override standard Singleton retrieval.
|
---|
| 101 | @remarks
|
---|
| 102 | Why do we do this? Well, it's because the Singleton
|
---|
| 103 | implementation is in a .h file, which means it gets compiled
|
---|
| 104 | into anybody who includes it. This is needed for the
|
---|
| 105 | Singleton template to work, but we actually only want it
|
---|
| 106 | compiled into the implementation of the class based on the
|
---|
| 107 | Singleton, not all of them. If we don't change this, we get
|
---|
| 108 | link errors when trying to use the Singleton-based class from
|
---|
| 109 | an outside dll.
|
---|
| 110 | @par
|
---|
| 111 | This method just delegates to the template version anyway,
|
---|
| 112 | but the implementation stays in this single compilation unit,
|
---|
| 113 | preventing link errors.
|
---|
| 114 | */
|
---|
| 115 | static SceneManagerEnumerator& getSingleton(void);
|
---|
| 116 | /** Override standard Singleton retrieval.
|
---|
| 117 | @remarks
|
---|
| 118 | Why do we do this? Well, it's because the Singleton
|
---|
| 119 | implementation is in a .h file, which means it gets compiled
|
---|
| 120 | into anybody who includes it. This is needed for the
|
---|
| 121 | Singleton template to work, but we actually only want it
|
---|
| 122 | compiled into the implementation of the class based on the
|
---|
| 123 | Singleton, not all of them. If we don't change this, we get
|
---|
| 124 | link errors when trying to use the Singleton-based class from
|
---|
| 125 | an outside dll.
|
---|
| 126 | @par
|
---|
| 127 | This method just delegates to the template version anyway,
|
---|
| 128 | but the implementation stays in this single compilation unit,
|
---|
| 129 | preventing link errors.
|
---|
| 130 | */
|
---|
| 131 | static SceneManagerEnumerator* getSingletonPtr(void);
|
---|
| 132 |
|
---|
| 133 | };
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | #endif
|
---|