Commits

Anonymous committed 5cae544

Renamed Scene to Level
Fixed misc bugs

Comments (0)

Files changed (47)

PolyMain/PolyMain.vcxproj

     <ClInclude Include="include\game\PolyGame.h" />
     <ClInclude Include="include\game\PolyGameState.h" />
     <ClInclude Include="include\game\PolyGameStateManager.h" />
-    <ClInclude Include="include\game\PolyLevelFile.h" />
-    <ClInclude Include="include\game\PolyLevelFileSerializer.h" />
-    <ClInclude Include="include\game\PolyLevelFileSerializerImpl1.h" />
+    <ClInclude Include="include\game\PolyLevel.h" />
     <ClInclude Include="include\game\PolyLevelManager.h" />
     <ClInclude Include="include\game\PolyLightComponent.h" />
     <ClInclude Include="include\game\PolyMeshColliderComponent.h" />
     <ClInclude Include="include\game\PolyPhysicsEntityLogic.h" />
     <ClInclude Include="include\game\PolyPhysicsStaticComponent.h" />
     <ClInclude Include="include\game\PolyProperty.h" />
-    <ClInclude Include="include\game\PolyScene.h" />
-    <ClInclude Include="include\game\PolySceneManager.h" />
     <ClInclude Include="include\game\PolyTransformComponent.h" />
     <ClInclude Include="include\input\PolyInput.h" />
     <ClInclude Include="include\input\PolyInputKeyboard.h" />
     <ClCompile Include="include\game\PolyEntityTemplateTranslator.cpp" />
     <ClCompile Include="include\game\PolyGameState.cpp" />
     <ClCompile Include="include\game\PolyGameStateManager.cpp" />
-    <ClCompile Include="include\game\PolyLevelFile.cpp" />
-    <ClCompile Include="include\game\PolyLevelFileSerializer.cpp" />
-    <ClCompile Include="include\game\PolyLevelFileSerializerImpl1.cpp" />
+    <ClCompile Include="include\game\PolyLevel.cpp" />
     <ClCompile Include="include\game\PolyLevelManager.cpp" />
     <ClCompile Include="include\game\PolyLightComponent.cpp" />
     <ClCompile Include="include\game\PolyMeshColliderComponent.cpp" />
     <ClCompile Include="include\game\PolyPhysicsDynamicComponent.cpp" />
     <ClCompile Include="include\game\PolyPhysicsEntityLogic.cpp" />
     <ClCompile Include="include\game\PolyPhysicsStaticComponent.cpp" />
-    <ClCompile Include="include\game\PolyScene.cpp" />
-    <ClCompile Include="include\game\PolySceneManager.cpp" />
     <ClCompile Include="include\game\PolyTransformComponent.cpp" />
     <ClCompile Include="include\network\PolyNetworkDispatcher.cpp" />
     <ClCompile Include="include\physics\PolyPhysicsSubScene.cpp" />

PolyMain/PolyMain.vcxproj.filters

     <ClInclude Include="include\util\PolyFileWatcherWin32.h">
       <Filter>util</Filter>
     </ClInclude>
-    <ClInclude Include="include\game\PolyLevelManager.h">
-      <Filter>game</Filter>
-    </ClInclude>
-    <ClInclude Include="include\game\PolyLevelFileSerializer.h">
-      <Filter>game</Filter>
-    </ClInclude>
-    <ClInclude Include="include\game\PolyLevelFile.h">
-      <Filter>game</Filter>
-    </ClInclude>
-    <ClInclude Include="include\game\PolyLevelFileSerializerImpl1.h">
-      <Filter>game</Filter>
-    </ClInclude>
     <ClInclude Include="include\util\PolyStream.h">
       <Filter>util</Filter>
     </ClInclude>
     <ClInclude Include="include\game\PolyTransformComponent.h">
       <Filter>game\entity</Filter>
     </ClInclude>
-    <ClInclude Include="include\game\PolySceneManager.h">
-      <Filter>game\scene</Filter>
-    </ClInclude>
-    <ClInclude Include="include\game\PolyScene.h">
-      <Filter>game\scene</Filter>
-    </ClInclude>
     <ClInclude Include="include\game\PolyAnimationComponent.h">
       <Filter>game\entity</Filter>
     </ClInclude>
     <ClInclude Include="include\audio\PolySoundTemplate.h">
       <Filter>audio</Filter>
     </ClInclude>
+    <ClInclude Include="include\game\PolyLevel.h">
+      <Filter>game\level</Filter>
+    </ClInclude>
+    <ClInclude Include="include\game\PolyLevelManager.h">
+      <Filter>game\level</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="include\PolyPrerequisites.cpp" />
     <ClCompile Include="include\util\PolyFileWatcherWin32.cpp">
       <Filter>util</Filter>
     </ClCompile>
-    <ClCompile Include="include\game\PolyLevelManager.cpp">
-      <Filter>game</Filter>
-    </ClCompile>
-    <ClCompile Include="include\game\PolyLevelFileSerializer.cpp">
-      <Filter>game</Filter>
-    </ClCompile>
-    <ClCompile Include="include\game\PolyLevelFile.cpp">
-      <Filter>game</Filter>
-    </ClCompile>
-    <ClCompile Include="include\game\PolyLevelFileSerializerImpl1.cpp">
-      <Filter>game</Filter>
-    </ClCompile>
     <ClCompile Include="include\util\PolyBitStream.cpp">
       <Filter>util</Filter>
     </ClCompile>
     <ClCompile Include="include\game\PolyTransformComponent.cpp">
       <Filter>game\entity</Filter>
     </ClCompile>
-    <ClCompile Include="include\game\PolyScene.cpp">
-      <Filter>game\scene</Filter>
-    </ClCompile>
-    <ClCompile Include="include\game\PolySceneManager.cpp">
-      <Filter>game\scene</Filter>
-    </ClCompile>
     <ClCompile Include="include\game\PolyAnimationComponent.cpp">
       <Filter>game\entity</Filter>
     </ClCompile>
     <ClCompile Include="include\audio\PolySoundManager.cpp">
       <Filter>audio</Filter>
     </ClCompile>
+    <ClCompile Include="include\game\PolyLevel.cpp">
+      <Filter>game\level</Filter>
+    </ClCompile>
+    <ClCompile Include="include\game\PolyLevelManager.cpp">
+      <Filter>game\level</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="audio">
     <Filter Include="render">
       <UniqueIdentifier>{bffc50c4-4e3d-46ed-9a3d-29a15e60d004}</UniqueIdentifier>
     </Filter>
-    <Filter Include="game\scene">
-      <UniqueIdentifier>{143cfec8-3847-4e6c-8bd1-b0fe73e3ee50}</UniqueIdentifier>
-    </Filter>
     <Filter Include="animation">
       <UniqueIdentifier>{a947d170-9997-45be-b0d6-08e450a4f400}</UniqueIdentifier>
     </Filter>
     <Filter Include="game\entity">
       <UniqueIdentifier>{87df32a6-d459-4a52-bf15-2a141bfc06f8}</UniqueIdentifier>
     </Filter>
+    <Filter Include="game\level">
+      <UniqueIdentifier>{143cfec8-3847-4e6c-8bd1-b0fe73e3ee50}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
 </Project>

PolyMain/include/PolyEnvironment.h

 		SafePtr<EntityManager>		entityMgr;
 		SafePtr<AnimationManager>	animationMgr;
 		SafePtr<GameStateManager>	gameStateMgr;
-		SafePtr<SceneManager>		sceneMgr;
 		SafePtr<LevelManager>		levelMgr;
 		SafePtr<SaveManager>		saveMgr;
 		SafePtr<EventHub>			globalEventHub;

PolyMain/include/PolyPrerequisites.h

 	class EntityManager;
 	class EntityLogic;
 	class GameStateManager;
-	class SceneManager;
+	class LevelManager;
 	class SoundManager;
 	class LevelManager;
 	class SaveManager;

PolyMain/include/core/PolyEngine.cpp

 #include "game/PolyComponentManager.h"
 #include "game/PolyEntityManager.h"
 #include "game/PolyGameStateManager.h"
-#include "game/PolySceneManager.h"
 #include "game/PolyLevelManager.h"
 #include "animation/PolyAnimationManager.h"
 #include "PolySaveManager.h"
 		POLY_LOG("*-*-* Poly Shutdown");
 
 		gEnv.entityMgr->destroyAllEntitiesImmediate();
-		gEnv.sceneMgr->destroyAllScenes();
+		gEnv.levelMgr->destroyAllLevels();
 		gEnv.componentMgr->removeAllFactories();
 
 		delete gEnv.levelMgr.get(); gEnv.levelMgr.reset();
 		delete gEnv.globalEventHub.get(); gEnv.globalEventHub.reset();
 		POLY_LOG_TRIVIAL("saveMgr");
 		delete gEnv.saveMgr.get(); gEnv.saveMgr.reset();
-		POLY_LOG_TRIVIAL("sceneMgr");
-		delete gEnv.sceneMgr.get(); gEnv.sceneMgr.reset();
+		POLY_LOG_TRIVIAL("levelMgr");
+		delete gEnv.levelMgr.get(); gEnv.levelMgr.reset();
 		POLY_LOG_TRIVIAL("gameStateMgr");
 		delete gEnv.gameStateMgr.get(); gEnv.gameStateMgr.reset();
 		POLY_LOG_TRIVIAL("soundMgr");
 		gEnv.entityMgr.set(new EntityManager());
 		gEnv.animationMgr.set(new AnimationManager());
 		gEnv.gameStateMgr.set(new GameStateManager());
-		gEnv.sceneMgr.set(new SceneManager());
+		gEnv.levelMgr.set(new LevelManager());
 		gEnv.saveMgr.set(new SaveManager());
 		gEnv.globalEventHub.set(new EventHub());
 		

PolyMain/include/core/PolyLog.cpp

 	}
 
 	void Log::logMessage(const String& msg, LogLevel lvl, const String& file, uint line) {
+		BOOST_FOREACH(ILogListener* listener, mListeners)
+			listener->logMessage(msg, lvl, file, line);
+
 		ulong time = TimeUtil::getMS();
 
 		mFile << "<div class='msg lvl-" << (int)lvl.underlying() << "'>"

PolyMain/include/core/PolyLog.h

 
 	typedef SafeEnum<LogLevelEnum> LogLevel;
 
+	class ILogListener {
+	public:
+		virtual void logMessage(const String& msg, LogLevel lvl, const String& file, uint line) = 0;
+	};
+
 	/**
 	@ingroup Core
 	*/
 
 		void	logMessage(const String& msg, LogLevel lvl=LogLevel::INFO, const String& file="", uint line=0);
 
+		void	addListener(ILogListener* listener);
+
 	private:
 		std::ofstream mFile;
+
+		typedef vector<ILogListener*>::type ListenerContainer;
+		ListenerContainer mListeners;
 	};
+
+	inline void Log::addListener(ILogListener* listener) {
+		mListeners.push_back(listener);
+	}
 }
 
 #endif

PolyMain/include/core/PolySaveManager.h

 namespace Poly {
 	class _PolyExport SaveManager {
 	public:
-		void save(Scene scene) {
+		void save(Level scene) {
 		}
 
-		void load(Scene scene) {
+		void load(Level scene) {
 		}
 
 	protected:

PolyMain/include/core/PolySystemManager.cpp

 #include "network/PolyNetworkSystemFactory.h"
 #include "physics/PolyPhysicsSystem.h"
 #include "render/PolyRenderSystem.h"
-#include "game/PolyScene.h"
+#include "game/PolyLevel.h"
 
 #include "core/PolySystemManager.h"
 

PolyMain/include/core/PolySystemManager.h

 	class PhysicsSystem;
 	class PhysicsSystemFactory;
 	class RenderSystem;
-	class Scene;
+	class Level;
 
 	/** Responsible for creating/destroying systems.
 	@ingroup Core

PolyMain/include/game/PolyBoxColliderComponent.cpp

 		PhysicsComponent* physicsC = static_cast<PhysicsComponent*>(other);
 
 		if(physicsC->rigidActor->getScene())
-			gEnv.physics->removeRigidBodyFromScene(mEntity.getScene(), physicsC->rigidActor);
+			gEnv.physics->removeRigidBodyFromScene(mEntity.getLevel(), physicsC->rigidActor);
 
 		physicsC->rigidActor->createShape(physx::PxBoxGeometry(mExtends.x, mExtends.y, mExtends.z), *defaultMaterial, transform);
-		gEnv.physics->addRigidBodyToScene(mEntity.getScene(), physicsC->rigidActor);
+		gEnv.physics->addRigidBodyToScene(mEntity.getLevel(), physicsC->rigidActor);
 	}
 }

PolyMain/include/game/PolyCameraComponent.cpp

 	void CameraComponent::initialize(Entity entity, const StringVariantMap& values) {
 		RenderComponent::initialize(entity, values);
 
-		RenderSubScene* renderScene = mEntity.getScene().getRender();
+		RenderSubLevel* renderScene = mEntity.getLevel().getRender();
 		camera = renderScene->sceneMgr->createCamera(RandomUtil::randString(16));
 		camera->setFOVy(gEnv.render->getDefaultFov());
 		camera->setNearClipDistance(0.1f);

PolyMain/include/game/PolyCharacterControllerComponent.cpp

 		desc.stepOffset = values.get<float>("CharacterController/StepOffset", 0.5f);
 		desc.contactOffset = values.get<float>("CharacterController/ContactOffset", 0.1f);
 
-		controller = gEnv.physics->createCharacterController(entity.getScene(), desc, entity);
+		controller = gEnv.physics->createCharacterController(entity.getLevel(), desc, entity);
 
 		TransformComponent* transformComponent = entity.getComponent<TransformComponent>();
 		if(transformComponent) {

PolyMain/include/game/PolyEntity.cpp

 
 #include "PolyPrerequisites.h"
 #include "core/PolyEngine.h"
-#include "game/PolyScene.h"
+#include "game/PolyLevel.h"
 #include "game/PolyEntityManager.h"
 #include "game/PolyComponentManager.h"
 #include "game/PolyComponent.h"
 
 namespace Poly {
 	bool Entity::msValid[(EntityID)-1];
-	Scene Entity::msScene[(EntityID)-1];
+	Level Entity::msScene[(EntityID)-1];
 	InternString Entity::msTypeName[(EntityID)-1];
 	TagSet Entity::msTags[(EntityID)-1];
 	TagSet Entity::msAllTags;

PolyMain/include/game/PolyEntity.h

 #ifndef PolyEntity_h
 #define PolyEntity_h
 
-#include "PolyScene.h"
+#include "PolyLevel.h"
 
 
 namespace Poly {
 		bool						operator <(const Entity& other) const;
 		bool						isValid() const;
 
-		Scene						getScene() const;
+		Level						getLevel() const;
 		void						_setID(EntityID eid);
 		EntityID					getID() const;
 
 		EntityID					mEID;
 
 		static bool					msValid[(EntityID)-1];
-		static Scene				msScene[(EntityID)-1];
+		static Level				msScene[(EntityID)-1];
 		static InternString			msTypeName[(EntityID)-1];
 
 		static TagSet				msTags[(EntityID)-1];
 		return mEID != UNASSIGNED_ENTITY_ID && msValid[mEID];
 	}
 
-	inline Scene Entity::getScene() const {
+	inline Level Entity::getLevel() const {
 		POLY_ASSERT(mEID != UNASSIGNED_ENTITY_ID);
 		return msScene[mEID];
 	}

PolyMain/include/game/PolyEntityManager.cpp

 			POLY_LOG_WARNING("Entity type '" << typeName << "' not found to remove it!");
 	}
 
-	Entity EntityManager::createEntity(Scene scene) {
+	Entity EntityManager::createEntity(Level scene) {
 		EntityID id = allocateEntityID();
 
 		Entity::msValid[id] = true;
 		return newEntity;
 	}
 
-	Entity EntityManager::createEntity(Scene scene, const String& typeName, const StringVariantMap& _properties) {
+	Entity EntityManager::createEntity(Level scene, const String& typeName, const StringVariantMap& _properties) {
 		POLY_ASSERT(scene);
 
 		InternString internTypeName(typeName);
 
 		EntityID id = entity.getID();
 		Entity::msValid[id] = false;
-		Entity::msScene[id] = Scene();
+		Entity::msScene[id] = Level();
 		Entity::msTypeName[id] = InternString(); 
 		Entity::msTags[id].clear();
 		// TODO msAllTags

PolyMain/include/game/PolyEntityManager.h

 
 
 namespace Poly {
-	class Scene;
+	class Level;
 	class EntityLogic;
 
 	/**
 
 		/** Create empty Entity without a specific type.
 		*/
-		Entity				createEntity(Scene scene);
+		Entity				createEntity(Level scene);
 
 		/** Create Entity with previously registered type.
 		*/
-		Entity				createEntity(	Scene scene,
+		Entity				createEntity(	Level scene,
 											const String& typeName,
 											const StringVariantMap& _properties=StringVariantMap());
 

PolyMain/include/game/PolyGame.h

 #include "PolyGameState.h"
 #include "PolyGameStateManager.h"
 
-#include "PolyScene.h"
-#include "PolySceneManager.h"
+#include "PolyLevel.h"
+#include "PolyLevelManager.h"
 
 #include "PolyComponent.h"
 #include "PolyComponentManager.h"
 #include "PolyAudioListenerComponent.h"
 #include "PolyAnimationComponent.h"
 
-#include "PolyLevelManager.h"
-
 /** @} */
 
 #endif

PolyMain/include/game/PolyLevel.cpp

+/*
+    Copyright (c) Oliver 'SirPolly' Weitzel
+                                                                                  
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+                                                                                  
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+                                                                                  
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE. 
+    
+*/
+
+#include "PolyPrerequisites.h"
+#include "core/PolyEngine.h"
+#include "render/PolyRenderSystem.h"
+#include "physics/PolyPhysicsSystem.h"
+
+#include "game/PolyLevel.h"
+
+
+namespace Poly {
+	RenderSubLevel* Level::getRender() {
+		return gEnv.render->getScene(*this);
+	}
+
+	PhysicsSubLevel* Level::getPhysics() {
+		return gEnv.physics->getScene(*this);
+	}
+}

PolyMain/include/game/PolyLevel.h

+/*
+    Copyright (c) Oliver 'SirPolly' Weitzel
+                                                                                  
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+                                                                                  
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+                                                                                  
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE. 
+    
+*/
+
+#ifndef PolyLevel_h
+#define PolyLevel_h
+
+namespace Poly {
+	class RenderSubLevel;
+	class PhysicsSubLevel;
+
+	/**
+	@ingroup Game
+	*/
+	class _PolyExport Level {
+	public:
+		friend class LevelManager;
+
+							Level();
+							Level(const Level& other);
+
+							operator bool() const;
+		bool				isValid() const;
+
+		bool				operator==(const Level& other) const;
+
+		SceneID				getID() const;
+
+		RenderSubLevel*		getRender();
+		PhysicsSubLevel*	getPhysics();
+
+	private:
+		SceneID				mSID;
+	};
+
+	inline Level::Level()
+	:	mSID(UNASSIGNED_SCENE_ID) {
+	}
+
+	inline Level::Level(const Level& other)
+	:	mSID(other.mSID) {
+	}
+
+	inline Level::operator bool() const {
+		return isValid();
+	}
+	inline bool Level::isValid() const {
+		return mSID != UNASSIGNED_SCENE_ID;
+	}
+
+	inline bool Level::operator==(const Level& other) const {
+		return mSID == other.mSID;
+	}
+
+	inline SceneID Level::getID() const {
+		return mSID;
+	}
+}
+
+#endif

PolyMain/include/game/PolyLevelFile.cpp

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#include "PolyPrerequisites.h"
-#include "game/PolyLevelFileSerializer.h"
-
-#include "game/PolyLevelFile.h"
-
-
-namespace Poly {
-	LevelFile::LevelFile(Ogre::ResourceManager* creator, const Ogre::String &name, 
-                     Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual, 
-                     Ogre::ManualResourceLoader *loader)
-	:	Ogre::Resource(creator, name, handle, group, isManual, loader) {
-		createParamDictionary("LevelFile");
-	}
- 
-	LevelFile::~LevelFile() {
-		unload();
-	}
-
-	void LevelFile::loadImpl() {
-		LevelFileSerializer serializer;
-		Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(mName, mGroup, true, this);
-		serializer.importLevelFile(mScene, stream, this);
-	 }
- 
-	 void LevelFile::unloadImpl() {
-	 }
- 
-	 size_t LevelFile::calculateSize() const {
-		 return 0;
-	 }
-}

PolyMain/include/game/PolyLevelFile.h

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#ifndef PolyLevelFile_h
-#define PolyLevelFile_h
-
-#include "PolyScene.h"
-
-
-namespace Poly {
-	class _PolyExport LevelFile : public Ogre::Resource {
-	public:
-				LevelFile(	Ogre::ResourceManager* creator, const String& name, 
-							Ogre::ResourceHandle handle, const String& group, bool isManual = false, 
-							Ogre::ManualResourceLoader* loader = 0);
-
-		virtual	~LevelFile();
-
-		void setScene(Scene scene) { mScene = scene; }
-
-	protected:
-		Scene		mScene;
-
-		// Implement Ogre::Resource
-		void		loadImpl();
-		void		unloadImpl();
-		size_t		calculateSize() const;
-	};
-
-	class LevelFilePtr : public Ogre::SharedPtr<LevelFile> {
-	public:
-		LevelFilePtr() : Ogre::SharedPtr<LevelFile>() {}
-		explicit LevelFilePtr(LevelFile *rep) : Ogre::SharedPtr<LevelFile>(rep) {}
-		LevelFilePtr(const LevelFilePtr& r) : Ogre::SharedPtr<LevelFile>(r) {} 
-		LevelFilePtr(const Ogre::ResourcePtr& r) : Ogre::SharedPtr<LevelFile>() {
-			if( r.isNull() )
-				return;
-			// lock & copy other mutex pointer
-			OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
-			OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
-			pRep = static_cast<LevelFile*>(r.getPointer());
-			pUseCount = r.useCountPointer();
-			useFreeMethod = r.freeMethod();
-			if (pUseCount) {
-				++(*pUseCount);
-			}
-		}
-
-		LevelFilePtr& operator=(const Ogre::ResourcePtr& r) {
-			if(pRep == static_cast<LevelFile*>(r.getPointer()))
-				return *this;
-			release();
-			if( r.isNull() )
-				return *this; // resource ptr is null, so the call to release above has done all we need to do.
-			// lock & copy other mutex pointer
-			OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
-			OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
-			pRep = static_cast<LevelFile*>(r.getPointer());
-			pUseCount = r.useCountPointer();
-			useFreeMethod = r.freeMethod();
-			if (pUseCount) {
-				++(*pUseCount);
-			}
-			return *this;
-		}
-	};
-}
-
-#endif

PolyMain/include/game/PolyLevelFileSerializer.cpp

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#include "PolyPrerequisites.h"
-#include "game/PolyScene.h"
-#include "game/PolyLevelFileSerializerImpl1.h"
-
-#include "game/PolyLevelFileSerializer.h"
-
-
-namespace Poly {
-	LevelFileSerializer::LevelFileSerializer() {
-	}
-
-	LevelFileSerializer::~LevelFileSerializer() {
-	}
-
-	void LevelFileSerializer::importLevelFile(Scene scene, Ogre::DataStreamPtr& stream, LevelFile* pDest) {
-		using namespace rapidxml;
-
-		POLY_LOG("Loading level '" << stream->getName() << "'...");
-
-		char* buffer = POLY_NULLPTR;
-		try {
-			buffer = new char[stream->size() + 1];
-			stream->read(buffer, stream->size());
-
-			buffer[stream->size()] = '\0';
-		}
-		catch(const Exception& e) {
-			POLY_LOG_CRITICAL("Failed to load level! Error: " << e.what());
-
-			delete[] buffer; buffer = POLY_NULLPTR;
-
-			return;
-		}
-
-		xml_document<> doc;
-		try {
-			doc.parse<0>(buffer);
-
-			xml_node<>* root = doc.first_node();
-
-			int version = 0;
-			xml_attribute<>* versionAttribute = root->first_attribute("formatVersion");
-			if(versionAttribute)
-				version = (int)StringConverter::parseReal(versionAttribute->value());
-
-			if(version == 1 || version == 0) {
-				detail::LevelFileSerializerImpl1::loadMap(scene, root);
-			}
-			else {
-				POLY_LOG_CRITICAL("Failed to load level! Wrong Version: " << version);
-			}
-
-			doc.clear();
-			delete[] buffer; buffer = POLY_NULLPTR;
-		}
-		catch(const parse_error& e) {
-			POLY_LOG_CRITICAL("Failed to load level! Xml error: " << e.what());
-
-			doc.clear();
-			delete[] buffer; buffer = POLY_NULLPTR;
-		}
-		catch(const Ogre::Exception& e) {
-			POLY_LOG_CRITICAL("Failed to load level! Error: " << e.what());
-
-			doc.clear();
-			delete[] buffer; buffer = POLY_NULLPTR;
-		}
-	}
-}

PolyMain/include/game/PolyLevelFileSerializer.h

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#ifndef PolyLevelFileSerializer_h
-#define PolyLevelFileSerializer_h
-
-namespace Poly {
-	class Scene;
-	class LevelFile;
-
-	class LevelFileSerializer : public Ogre::Serializer {
-	public:
-					LevelFileSerializer();
-		virtual		~LevelFileSerializer();
-
-		void		importLevelFile(Scene scene, Ogre::DataStreamPtr& stream, LevelFile* pDest);
-	};
-}
-
-#endif

PolyMain/include/game/PolyLevelFileSerializerImpl1.cpp

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#include "PolyPrerequisites.h"
-#include "core/PolyEngine.h"
-#include "game/PolyComponent.h"
-#include "game/PolyEntity.h"
-#include "game/PolyEntityManager.h"
-#include "game/PolyMeshComponent.h"
-
-#include "game/PolyLevelFileSerializerImpl1.h"
-
-
-namespace Poly {
-	namespace detail {
-		using namespace rapidxml;
-
-		void LevelFileSerializerImpl1::loadMap(Scene scene, rapidxml::xml_node<>* root) {
-			try {
-				xml_node<>* nodes = root->first_node("nodes");
-
-
-				// Node
-				xml_node<>* node = nodes->first_node("node");
-				while(node) {
-					StringVariantMap params;
-
-
-					// Position
-					xml_node<>* positionNode = node->first_node("position");
-					params["Transform/Position"] = parseVector3(positionNode, Vector3::ZERO);
-
-
-					// Scale
-					xml_node<>* scaleNode = node->first_node("scale");
-					params["Transform/Scale"] = parseVector3(scaleNode, Vector3::UNIT_SCALE);
-
-
-					// Rotation
-					xml_node<>* rotationNode = node->first_node("rotation");
-					params["Transform/Orientation"] = parseQuaternion(rotationNode, Quaternion::IDENTITY);
-
-
-					// Entity
-					xml_node<>* entityNode = node->first_node("entity");
-					while(entityNode) {
-						parseEntity(scene, entityNode, params);
-
-						entityNode = entityNode->next_sibling("entity");
-					}
-
-
-					// Light
-					xml_node<>* lightNode = node->first_node("light");
-					while(lightNode) {
-						parseLight(scene, lightNode, params);
-
-						lightNode = lightNode->next_sibling("light");
-					}
-
-					node = node->next_sibling("node");
-				}
-			}
-			catch(const parse_error& e) {
-				POLY_LOG_CRITICAL("Failed to load map! XML Error: " << e.what());
-			}
-			catch(const Exception& e) {
-				POLY_LOG_CRITICAL("Failed to load map! Error: " << e.what());
-			}
-		}
-
-		void LevelFileSerializerImpl1::parseEntity(Scene scene, rapidxml::xml_node<>* node, const StringVariantMap& params) {
-			StringVariantMap entityParams;
-
-			xml_attribute<>* meshFile = node->first_attribute("meshFile");
-			if(meshFile) {
-				entityParams["Mesh/Name"] = meshFile->value();
-			}
-			else
-				return;
-
-
-			entityParams.defaults(params);
-
-			Entity entity = gEnv.entityMgr->createEntity(scene);
-			entity.createComponent("Transform", entityParams);
-			entity.createComponent("Mesh", entityParams);
-
-			entity.addTag(DONT_SERIALIZE_TAG);
-
-
-			// TODO Assign materials to subentities
-// 			IMeshComponent* meshComponent = gameObject.getComponent<IMeshComponent>();
-// 
-// 
-// 			// Subentities
-// 			xml_node<>* subentities = node->first_node("subentities");
-// 			if(subentities) {
-// 				// Subentity
-// 				xml_node<>* subentityNode = subentities->first_node("subentity");
-// 				while(subentityNode) {
-// 					// Index
-// 					xml_attribute<>* index = subentityNode->first_attribute("index");
-// 					if(!index)
-// 						continue;
-// 
-// 
-// 					// MaterialName
-// 					xml_attribute<>* materialName = subentityNode->first_attribute("materialName");
-// 					if(!materialName)
-// 						continue;
-// 
-// 					uint subEntityIndex = StringConverter::parseUnsignedInt(index->value());
-// 
-// 					Ogre::SubEntity* subEntity;
-// 					subEntity = meshComponent->getEntity()->getSubEntity(subEntityIndex);
-// 
-// 					subEntity->setMaterialName(materialName->value());
-// 
-// 					subentityNode = subentityNode->next_sibling("subentity");
-// 				}
-// 			}
-		}
-
-		void LevelFileSerializerImpl1::parseLight(Scene scene, rapidxml::xml_node<>* node, const StringVariantMap& params) {
-			StringVariantMap lightParams;
-			lightParams["Light/CastShadows"] = parseBool(node->first_attribute("castShadows"), false);
-			lightParams["Light/DiffuseColour"] = parseColourValue(node->first_node("colourDiffuse"), ColourValue::White);
-
-			rapidxml::xml_attribute<>* type = node->first_attribute("type");
-			if(type) {
-				lightParams["Light/Type"] = type->value();
-			}
-			
-
-			rapidxml::xml_node<>* rotationNode = node->first_node("rotation");
-			Vector3 foo = parseQuaternion(rotationNode, Quaternion::IDENTITY) * Vector3::UNIT_Z;
-			lightParams["Light/Direction"] = foo;
-
-			rapidxml::xml_node<>* attenuationNode = node->first_node("lightAttenuation");
-			if(attenuationNode) {
-				lightParams["Light/Attenuation/Range"] = parseFloat(attenuationNode->first_attribute("range"), 1000.0f);
-				lightParams["Light/Attenuation/Constant"] = parseFloat(attenuationNode->first_attribute("constant"), 0.0f);
-				lightParams["Light/Attenuation/Linear"] = parseFloat(attenuationNode->first_attribute("linear"), 0.0f);
-				lightParams["Light/Attenuation/Quadric"] = parseFloat(attenuationNode->first_attribute("quadric"), 0.0f);
-			}
-
-			rapidxml::xml_node<>* lightRangeNode = node->first_node("lightRange");
-			if(lightRangeNode) {
-				lightParams["Light/Range/Inner"] = parseFloat(lightRangeNode->first_attribute("inner"), 0.9f);
-				lightParams["Light/Range/Outer"] = parseFloat(lightRangeNode->first_attribute("outer"), 0.8f);
-			}
-
-			lightParams["Light/Power"] = parseFloat(node->first_attribute("power"), false);
-
-			lightParams.defaults(params);
-
-			Entity entity = gEnv.entityMgr->createEntity(scene);
-			entity.createComponent("Transform", lightParams);
-			entity.createComponent("Light", lightParams);
-
-			entity.addTag(DONT_SERIALIZE_TAG);
-		}
-
-		bool LevelFileSerializerImpl1::parseBool(xml_attribute<>* attr, bool default) {
-			if(attr) {
-				return StringConverter::parseBool(attr->value(), default);
-			}
-			else
-				return default;
-		}
-
-		float LevelFileSerializerImpl1::parseFloat(xml_attribute<>* attr, float default) {
-			if(attr) {
-				return StringConverter::parseReal(attr->value());
-			}
-			else
-				return default;
-		}
-
-		Vector3 LevelFileSerializerImpl1::parseVector3(rapidxml::xml_node<>* node, const Vector3& default) {
-			if(node) {
-				Vector3 val = default;
-
-				if(xml_attribute<>* x = node->first_attribute("x"))
-					val.x = StringConverter::parseReal(x->value());
-				if(xml_attribute<>* y = node->first_attribute("y"))
-					val.y = StringConverter::parseReal(y->value());
-				if(xml_attribute<>* z = node->first_attribute("z"))
-					val.z = StringConverter::parseReal(z->value());
-
-				return val;
-			}
-			else
-				return default;
-		}
-
-		ColourValue LevelFileSerializerImpl1::parseColourValue(rapidxml::xml_node<>* node, const ColourValue& default) {
-			if(node) {
-				ColourValue colour = default;
-
-				if(xml_attribute<>* r = node->first_attribute("r"))
-					colour.r = StringConverter::parseReal(r->value());
-				if(xml_attribute<>* g = node->first_attribute("g"))
-					colour.g = StringConverter::parseReal(g->value());
-				if(xml_attribute<>* b = node->first_attribute("b"))
-					colour.b = StringConverter::parseReal(b->value());
-				if(xml_attribute<>* a = node->first_attribute("a"))
-					colour.a = StringConverter::parseReal(a->value());
-
-				return colour;
-			}
-			else
-				return default;
-		}
-
-		Quaternion LevelFileSerializerImpl1::parseQuaternion(rapidxml::xml_node<>* node, const Quaternion& default) {
-			if(node) {
-				Quaternion val = default;
-
-				if(xml_attribute<>* x = node->first_attribute("qx"))
-					val.x = StringConverter::parseReal(x->value());
-
-				if(xml_attribute<>* y = node->first_attribute("qy"))
-					val.y = StringConverter::parseReal(y->value());
-
-				if(xml_attribute<>* z = node->first_attribute("qz"))
-					val.z = StringConverter::parseReal(z->value());
-
-				if(xml_attribute<>* w = node->first_attribute("qw"))
-					val.w = StringConverter::parseReal(w->value());
-
-				return val;
-			}
-			else
-				return default;
-		}
-	}
-}

PolyMain/include/game/PolyLevelFileSerializerImpl1.h

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#ifndef PolyLevelFileSerializerImpl1_h
-#define PolyLevelFileSerializerImpl1_h
-
-namespace Poly {
-	class Scene;
-
-	namespace detail {
-		class LevelFileSerializerImpl1 : public Noncopyable {
-		public:
-			static void			loadMap(Scene scene, rapidxml::xml_node<>* root);
-
-		protected:
-			static void			parseEntity(Scene scene, rapidxml::xml_node<>* node, const StringVariantMap& params);
-			static void			parseLight(Scene scene, rapidxml::xml_node<>* node, const StringVariantMap& params);
-
-			static bool			parseBool(rapidxml::xml_attribute<>* attr, bool default);
-			static float		parseFloat(rapidxml::xml_attribute<>* attr, float default);
-			static Vector3		parseVector3(rapidxml::xml_node<>* node, const Vector3& default);
-			static ColourValue	parseColourValue(rapidxml::xml_node<>* node, const ColourValue& default);
-			static Quaternion	parseQuaternion(rapidxml::xml_node<>* node, const Quaternion& default);
-		};
-	}
-}
-
-#endif

PolyMain/include/game/PolyLevelManager.cpp

 */
 
 #include "PolyPrerequisites.h"
+#include "core/PolyEngine.h"
+#include "game/PolyLevel.h"
+#include "render/PolyRenderSystem.h"
+#include "physics/PolyPhysicsSystem.h"
 
 #include "game/PolyLevelManager.h"
 
 
 namespace Poly {
-	LevelManager::LevelManager() {
-		mResourceType = "Scene";
-		mLoadOrder = 20.0f;
-
-		Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
+	LevelManager::LevelManager()
+	:	mNextFreeSceneID(0) {
 	}
 
 	LevelManager::~LevelManager() {
-		Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
+		destroyAllLevels();
 	}
 
-	LevelFilePtr LevelManager::load(Scene scene, const String& name, const String& group) {
-		LevelFilePtr level = getByName(name);
+	Level LevelManager::createLevel(const String& name, LevelType sceneType) {
+		SceneID sid = mNextFreeSceneID++;
 
-		if(level.isNull()) {
-			level = create(name, group);
-			level->setScene(scene);
-		}
+		POLY_LOG("Creating scene '" << name << "' (sid=" << (uint)sid << ")");
 
-		level->load();
-		return level;
+		Level scene;
+		scene.mSID = sid;
+
+		mScenes.push_back(scene);
+		if(name != "")
+			mScenesByName.insert(std::make_pair(name, scene));
+
+		// Create SubScenes
+		gEnv.render->_createScene(scene);
+		gEnv.physics->_createScene(scene);
+
+		return scene;
 	}
 
-	Ogre::Resource* LevelManager::createImpl(const Ogre::String &name, Ogre::ResourceHandle handle, 
-		const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader, 
-		const Ogre::NameValuePairList *createParams) {
-		return new LevelFile(this, name, handle, group, isManual, loader);
+	Level LevelManager::getLevel(const String& name) const {
+		NameSceneMap::const_iterator itr;
+		itr = mScenesByName.find(name);
+
+		if(itr != mScenesByName.end())
+			return itr->second;
+
+		POLY_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
+			"Scene with name '" + name + "' not found!",
+			"SceneManager::getScene");
+	}
+
+	void LevelManager::destroyLevel(Level scene) {
+		// Destroy SubScenes
+		gEnv.render->_destroyScene(scene);
+		gEnv.physics->_destroyScene(scene);
+
+		// Remove from containers
+		{
+			SceneContainer::iterator itr, end = mScenes.end();
+			for(itr = mScenes.begin(); itr != end; ++itr) {
+				if(*itr == scene) {
+					mScenes.erase(itr);
+					break;
+				}
+			}
+		}
+		{
+			NameSceneMap::iterator itr, end = mScenesByName.end();
+			for(itr = mScenesByName.begin(); itr != end; ++itr) {
+				if(itr->second == scene) {
+					mScenesByName.erase(itr);
+					break;
+				}
+			}
+		}
+	}
+
+	void LevelManager::destroyAllLevels() {
+		while(!mScenes.empty())
+			destroyLevel(mScenes.back());
 	}
 }

PolyMain/include/game/PolyLevelManager.h

 #ifndef PolyLevelManager_h
 #define PolyLevelManager_h
 
-#include "PolyLevelFile.h"
+namespace Poly {
+	class Level;
 
+	struct LevelTypeEnum {
+		enum Enum {
+			GENERIC,
+			OUTDOOR
+		};
+	};
+	typedef SafeEnum<LevelTypeEnum> LevelType;
 
-namespace Poly {
-	class _PolyExport LevelManager : public Ogre::ResourceManager {
+	class _PolyExport LevelManager {
 	public:
-							LevelManager();
-		virtual				~LevelManager();
+						LevelManager();
+						~LevelManager();
 
-		virtual	LevelFilePtr load(Scene scene, const String &name, const String& group);
+		Level			createLevel(const String& name="", LevelType sceneType=LevelType::GENERIC);
+		Level			getLevel(const String& name) const;
+		void			destroyLevel(Level scene);
+		void			destroyAllLevels();
 
-	protected:
-		Ogre::Resource*		createImpl(	const String& name, Ogre::ResourceHandle handle, 
-										const String& group, bool isManual, Ogre::ManualResourceLoader* loader, 
-										const Ogre::NameValuePairList* createParams);
+	private:
+		SceneID			mNextFreeSceneID;
+
+		typedef HashMap<String, Level> NameSceneMap;
+		NameSceneMap	mScenesByName;
+
+		typedef vector<Level>::type SceneContainer;
+		SceneContainer	mScenes;
 	};
 }
 

PolyMain/include/game/PolyLightComponent.cpp

 		gEnv.render->_unregisterComponent(this);
 
 
-		RenderSubScene* renderScene = mEntity.getScene().getRender();
+		RenderSubLevel* renderScene = mEntity.getLevel().getRender();
 		renderScene->sceneMgr->destroyLight(light);
 	}
 
 	void LightComponent::initialize(Entity entity, const StringVariantMap& values) {
 		RenderComponent::initialize(entity, values);
 
-		RenderSubScene* renderScene = mEntity.getScene().getRender();
+		RenderSubLevel* renderScene = mEntity.getLevel().getRender();
 
 		light = renderScene->sceneMgr->createLight();
 

PolyMain/include/game/PolyMeshColliderComponent.cpp

 		PhysicsComponent* physicsC = static_cast<PhysicsComponent*>(other);
 
 		if(physicsC->rigidActor->getScene())
-			gEnv.physics->removeRigidBodyFromScene(mEntity.getScene(), physicsC->rigidActor);
+			gEnv.physics->removeRigidBodyFromScene(mEntity.getLevel(), physicsC->rigidActor);
 
 		physicsC->rigidActor->createShape(physx::PxTriangleMeshGeometry(triMesh), *defaultMaterial, transform);
-		gEnv.physics->addRigidBodyToScene(mEntity.getScene(), physicsC->rigidActor);
+		gEnv.physics->addRigidBodyToScene(mEntity.getLevel(), physicsC->rigidActor);
 	}
 }

PolyMain/include/game/PolyMeshComponent.cpp

 	MeshComponent::~MeshComponent() {
 		gEnv.render->_unregisterComponent(this);
 
-		RenderSubScene* renderScene = mEntity.getScene().getRender();
+		RenderSubLevel* renderScene = mEntity.getLevel().getRender();
 		renderScene->sceneMgr->destroyEntity(ogreEntity);
 	}
 
 	void MeshComponent::initialize(Entity entity, const StringVariantMap& values) {
 		RenderComponent::initialize(entity, values);
 
-		RenderSubScene* renderScene = entity.getScene().getRender();
+		RenderSubLevel* renderScene = entity.getLevel().getRender();
 
 		ogreEntity = renderScene->sceneMgr->createEntity(mMeshName);
 		ogreEntity->setVisible(mVisible);

PolyMain/include/game/PolyPhysicsEntityLogic.cpp

 					Quaternion transformCOrientation = transformC->sceneNode->_getDerivedOrientation();
 					bool transformMoved = transformCPosition.squaredDistance(PhysicsUtil::convert(transform.p)) > 1.0f;
 					if(transformMoved) {
-						gEnv.physics->removeRigidBodyFromScene(entity.getScene(), staticC->rigidStatic);
+						gEnv.physics->removeRigidBodyFromScene(entity.getLevel(), staticC->rigidStatic);
 
 						transform.p = PhysicsUtil::convert(transformCPosition);
 						transform.q = PhysicsUtil::convert(transformCOrientation);
 						staticC->rigidStatic->setGlobalPose(transform);
 
-						gEnv.physics->addRigidBodyToScene(entity.getScene(), staticC->rigidStatic);
+						gEnv.physics->addRigidBodyToScene(entity.getLevel(), staticC->rigidStatic);
 					}
 				}
 			}

PolyMain/include/game/PolyProperty.h

 	struct PropertyTypeEnum {
 		enum Enum {
 			BOOLEAN,
+			INT8,
 			UINT8,
+			INT16,
 			UINT16,
 			INT32,
+			UINT32,
 			FLOAT,
 			STRING,
 			COLOUR,
 			mProps.push_back(prop);
 		}
 
+		void addProperty(const String& name, int8* ptr, bool optional=false) {
+			Property prop;
+			prop.name = name;
+			prop.ptr = ptr;
+			prop.type = PropertyType::INT8;
+			prop.optional = optional;
+			mProps.push_back(prop);
+		}
+
 		void addProperty(const String& name, uint8* ptr, bool optional=false) {
 			Property prop;
 			prop.name = name;
 			mProps.push_back(prop);
 		}
 
+		void addProperty(const String& name, int16* ptr, bool optional=false) {
+			Property prop;
+			prop.name = name;
+			prop.ptr = ptr;
+			prop.type = PropertyType::INT16;
+			prop.optional = optional;
+			mProps.push_back(prop);
+		}
+
 		void addProperty(const String& name, uint16* ptr, bool optional=false) {
 			Property prop;
 			prop.name = name;
 			mProps.push_back(prop);
 		}
 
+		void addProperty(const String& name, uint32* ptr, bool optional=false) {
+			Property prop;
+			prop.name = name;
+			prop.ptr = ptr;
+			prop.type = PropertyType::UINT32;
+			prop.optional = optional;
+			mProps.push_back(prop);
+		}
+
 		void addProperty(const String& name, float* ptr, bool optional=false) {
 			Property prop;
 			prop.name = name;
 
 		void applyValues(const StringVariantMap& values) {
 			BOOST_FOREACH(const Property& prop, mProps) {
-				if(prop.ptr == POLY_NULLPTR)
+				if(!prop.ptr)
 					continue;
 
 				if(values.contains(prop.name)) {
 					if(prop.type == PropertyType::BOOLEAN)
 						*((bool*)prop.ptr) = values.get<int>(prop.name) != 0;
+					else if(prop.type == PropertyType::INT8)
+						*((int8*)prop.ptr) = static_cast<int8>(values.get<int8>(prop.name));
 					else if(prop.type == PropertyType::UINT8)
-						*((int8*)prop.ptr) = static_cast<uint8>(values.get<uint8>(prop.name));
+						*((uint8*)prop.ptr) = static_cast<uint8>(values.get<uint8>(prop.name));
+					else if(prop.type == PropertyType::INT16)
+						*((int16*)prop.ptr) = values.get<int16>(prop.name);
 					else if(prop.type == PropertyType::UINT16)
-						*((int16*)prop.ptr) = static_cast<uint16>(values.get<uint16>(prop.name));
+						*((uint16*)prop.ptr) = values.get<uint16>(prop.name);
 					else if(prop.type == PropertyType::INT32)
 						*((int32*)prop.ptr) = values.get<int32>(prop.name);
+					else if(prop.type == PropertyType::UINT32)
+						*((uint32*)prop.ptr) = values.get<uint32>(prop.name);
+					else if(prop.type == PropertyType::FLOAT)
+						*((float*)prop.ptr) = values.get<float>(prop.name);
 					else if(prop.type == PropertyType::STRING)
 						*((String*)prop.ptr) = values.get<String>(prop.name);
 					else if(prop.type == PropertyType::VECTOR3)
 						*((Vector3*)prop.ptr) = values.get<Vector3>(prop.name);
 					else if(prop.type == PropertyType::QUATERNION)
 						*((Quaternion*)prop.ptr) = values.get<Quaternion>(prop.name);
+					else
+						POLY_ASSERT(0 && "Property::applyValues - Unknown type");
 				}
 				else if(!prop.optional) {
 					POLY_LOG_WARNING("Missing property '" << prop.name << "'!");

PolyMain/include/game/PolyScene.cpp

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#include "PolyPrerequisites.h"
-#include "core/PolyEngine.h"
-#include "render/PolyRenderSystem.h"
-#include "physics/PolyPhysicsSystem.h"
-
-#include "game/PolyScene.h"
-
-
-namespace Poly {
-	RenderSubScene* Scene::getRender() {
-		return gEnv.render->getScene(*this);
-	}
-
-	PhysicsSubScene* Scene::getPhysics() {
-		return gEnv.physics->getScene(*this);
-	}
-}

PolyMain/include/game/PolyScene.h

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#ifndef PolyScene_h
-#define PolyScene_h
-
-namespace Poly {
-	class RenderSubScene;
-	class PhysicsSubScene;
-
-	/**
-	@ingroup Game
-	*/
-	class _PolyExport Scene {
-	public:
-		friend class SceneManager;
-
-							Scene();
-							Scene(const Scene& other);
-
-							operator bool() const;
-		bool				isValid() const;
-
-		bool				operator==(const Scene& other) const;
-
-		SceneID				getID() const;
-
-		RenderSubScene*		getRender();
-		PhysicsSubScene*	getPhysics();
-
-	private:
-		SceneID				mSID;
-	};
-
-	inline Scene::Scene()
-	:	mSID(UNASSIGNED_SCENE_ID) {
-	}
-
-	inline Scene::Scene(const Scene& other)
-	:	mSID(other.mSID) {
-	}
-
-	inline Scene::operator bool() const {
-		return isValid();
-	}
-	inline bool Scene::isValid() const {
-		return mSID != UNASSIGNED_SCENE_ID;
-	}
-
-	inline bool Scene::operator==(const Scene& other) const {
-		return mSID == other.mSID;
-	}
-
-	inline SceneID Scene::getID() const {
-		return mSID;
-	}
-}
-
-#endif

PolyMain/include/game/PolySceneManager.cpp

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#include "PolyPrerequisites.h"
-#include "core/PolyEngine.h"
-#include "game/PolyScene.h"
-#include "render/PolyRenderSystem.h"
-#include "physics/PolyPhysicsSystem.h"
-
-#include "game/PolySceneManager.h"
-
-
-namespace Poly {
-	SceneManager::SceneManager()
-	:	mNextFreeSceneID(0) {
-	}
-
-	SceneManager::~SceneManager() {
-		destroyAllScenes();
-	}
-
-	Scene SceneManager::createScene(const String& name, SceneType sceneType) {
-		SceneID sid = mNextFreeSceneID++;
-
-		POLY_LOG("Creating scene '" << name << "' (sid=" << (uint)sid << ")");
-
-		Scene scene;
-		scene.mSID = sid;
-
-		mScenes.push_back(scene);
-		if(name != "")
-			mScenesByName.insert(std::make_pair(name, scene));
-
-		// Create SubScenes
-		gEnv.render->_createScene(scene);
-		gEnv.physics->_createScene(scene);
-
-		return scene;
-	}
-
-	Scene SceneManager::getScene(const String& name) const {
-		NameSceneMap::const_iterator itr;
-		itr = mScenesByName.find(name);
-
-		if(itr != mScenesByName.end())
-			return itr->second;
-
-		POLY_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
-			"Scene with name '" + name + "' not found!",
-			"SceneManager::getScene");
-	}
-
-	void SceneManager::destroyScene(Scene scene) {
-		// Destroy SubScenes
-		gEnv.render->_destroyScene(scene);
-		gEnv.physics->_destroyScene(scene);
-
-		// Remove from containers
-		{
-			SceneContainer::iterator itr, end = mScenes.end();
-			for(itr = mScenes.begin(); itr != end; ++itr) {
-				if(*itr == scene) {
-					mScenes.erase(itr);
-					break;
-				}
-			}
-		}
-		{
-			NameSceneMap::iterator itr, end = mScenesByName.end();
-			for(itr = mScenesByName.begin(); itr != end; ++itr) {
-				if(itr->second == scene) {
-					mScenesByName.erase(itr);
-					break;
-				}
-			}
-		}
-	}
-
-	void SceneManager::destroyAllScenes() {
-		while(!mScenes.empty())
-			destroyScene(mScenes.back());
-	}
-}

PolyMain/include/game/PolySceneManager.h

-/*
-    Copyright (c) Oliver 'SirPolly' Weitzel
-                                                                                  
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-                                                                                  
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-                                                                                  
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE. 
-    
-*/
-
-#ifndef PolySceneManager_h
-#define PolySceneManager_h
-
-namespace Poly {
-	class Scene;
-
-	struct SceneTypeEnum {
-		enum Enum {
-			GENERIC,
-			OUTDOOR
-		};
-	};
-	typedef SafeEnum<SceneTypeEnum> SceneType;
-
-	class _PolyExport SceneManager {
-	public:
-						SceneManager();
-						~SceneManager();
-
-		Scene			createScene(const String& name="", SceneType sceneType=SceneType::GENERIC);
-		Scene			getScene(const String& name) const;
-		void			destroyScene(Scene scene);
-		void			destroyAllScenes();
-
-	private:
-		SceneID			mNextFreeSceneID;
-
-		typedef HashMap<String, Scene> NameSceneMap;
-		NameSceneMap	mScenesByName;
-
-		typedef vector<Scene>::type SceneContainer;
-		SceneContainer	mScenes;
-	};
-}
-
-#endif

PolyMain/include/game/PolyTransformComponent.cpp

 	void TransformComponent::initialize(Entity entity, const StringVariantMap& values) {
 		Component::initialize(entity, values);
 
-		RenderSubScene* renderScene = entity.getScene().getRender();
+		RenderSubLevel* renderScene = entity.getLevel().getRender();
 
 		sceneNode = renderScene->sceneMgr->getRootSceneNode()->createChildSceneNode();
 		sceneNode->setPosition(values.get<Vector3>("Transform/Position", Vector3::ZERO));
 
 	void TransformComponent::resetParent() {
 		sceneNode->getParent()->removeChild(sceneNode);
-		mEntity.getScene().getRender()->sceneMgr->getRootSceneNode()->addChild(sceneNode);
+		mEntity.getLevel().getRender()->sceneMgr->getRootSceneNode()->addChild(sceneNode);
 	}
 }

PolyMain/include/physics/PolyPhysicsSubScene.cpp

 
 
 namespace Poly {
-	PhysicsSubScene::PhysicsSubScene(physx::PxPhysics* sdk) {
+	PhysicsSubLevel::PhysicsSubLevel(physx::PxPhysics* sdk) {
 		POLY_ASSERT(sdk);
 
 		physx::PxSceneDesc sceneDesc(sdk->getTolerancesScale());
 		}
 	}
 
-	PhysicsSubScene::~PhysicsSubScene() {
+	PhysicsSubLevel::~PhysicsSubLevel() {
 		scene->release();
 		mCpuDispatcher->release();
 	}
 
-	void PhysicsSubScene::update() {
+	void PhysicsSubLevel::update() {
 		// TODO timestep, fixed wont work here!
 		// TODO threading
 
 		//scene->flush();
 	}
 
-	void PhysicsSubScene::onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, physx::PxU32 nbPairs) {
+	void PhysicsSubLevel::onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, physx::PxU32 nbPairs) {
 		// TODO
 	}
 }

PolyMain/include/physics/PolyPhysicsSubScene.h

 	/**
 	@ingroup Physics
 	*/
-	class PhysicsSubScene : public physx::PxSimulationEventCallback {
+	class PhysicsSubLevel : public physx::PxSimulationEventCallback {
 	public:
 		physx::PxScene*					scene;
 
-										PhysicsSubScene(physx::PxPhysics* sdk);
-										~PhysicsSubScene();
+										PhysicsSubLevel(physx::PxPhysics* sdk);
+										~PhysicsSubLevel();
 
 		void							update();