Example #1
0
 void AppendParams(params_t& params, const ::std::string& data)
 {
     if( StringIsBlank(data) )
     {
         return;
     }
     ::std::istringstream strm(data);
     T param;
     strm >> param;
     params.push_back(param);
 }
Example #2
0
		void OgitorWorld::Load(const MapLoader &loader, const Register::Table &worldEntityDef)
		{
			const auto &hive = loader.GetStaticEntitiesHive();

			for(auto it : hive)		
			{
				Register::Table *dict = static_cast<Register::Table *>(it.second);

				try
				{
					const String_t &name = dict->GetString("name");
					const String_t &type = dict->GetString("typename");

					if(this->LoadGlobalObject(type, *dict))
						continue;

					//make sure this is not duplicated
					StaticObjectsMap_t::iterator objIt = m_mapStaticObjects.lower_bound(name);
					if((objIt != m_mapStaticObjects.end()) && !(m_mapStaticObjects.key_comp()(name, objIt->first)))
					{
						LogMakeStream() << "[OgitorWorld::Load] Static object " << name << " is duplicated\n";
						continue;
					}

					StaticObject_s object;
					if(!this->LoadStaticObject(object, name, type, *dict))
						continue;

					m_mapStaticObjects.insert(objIt, std::make_pair(name, object));

				}
				catch(Exception &ex)
				{
					LogMakeStream() << "[OgitorWorld::Load] Exception loading static object: " << ex.what();
				}
			}

			//time to fix parents
			for(StaticObjectsMap_t::value_type &pair : m_mapStaticObjects)
			{
				StaticObject_s &object = pair.second;

				if(StringIsBlank(object.strParent) || (object.strParent.compare("SceneManager") == 0))
					continue;

				StaticObjectsMap_t::iterator it = m_mapStaticObjects.find(object.strParent);
				if(it == m_mapStaticObjects.end())
				{
					LogMakeStream() << "[OgitorWorld::Load] Static object " << pair.first << " without parent " << object.strParent << "\n";
					continue;
				}

				if(object.m_pclSceneNode->getParent())
					object.m_pclSceneNode->getParent()->removeChild(object.m_pclSceneNode);
				it->second.m_pclSceneNode->addChild(object.m_pclSceneNode);
			}

			//configure physics
			Physics::Manager &physicsManager = Physics::Manager::GetInstance();

			Physics::CollisionTag staticCollisionTag = Physics::Settings::CreateStaticWorldCollisionTag();

			for(auto &pair : m_mapStaticObjects)
			{
				StaticObject_s &object = pair.second;

				if(object.m_pclEntity == NULL)
					continue;

				//Why using those _ functions: http://89.151.96.106/forums/viewtopic.php?f=22&t=62386
				//http://www.ogre3d.org/forums/viewtopic.php?p=221113
				//http://www.ogre3d.org/tikiwiki/-SceneNode
				Engine::Math::Transform transform(
					object.m_pclSceneNode->_getDerivedPosition(), 
					object.m_pclSceneNode->_getDerivedOrientation()
				);

				BaseOgreWorld::CreateStaticObjectRigidBody(object, transform, object.m_pclSceneNode->_getDerivedScale(), staticCollisionTag);
			}
		

			if(m_pclTerrainGroupTable != NULL)
			{
				this->LoadTerrainGroup(*m_pclTerrainGroupTable);
				m_pclTerrainGroupTable = NULL;
			}

			if(m_pclTerrainPageTable != NULL)
			{
				this->LoadTerrainPage(*m_pclTerrainPageTable, worldEntityDef);
				m_pclTerrainPageTable = NULL;
			}		
		}