Пример #1
0
void TerrainManager::loadTerrainConfigBasics(Ogre::DataStreamPtr &ds)
{
	// now generate the hash of it
	generateHashFromDataStream(ds, file_hash);

	m_terrain_config.load(ds, "\t:=", true);

	// read in the settings
	terrain_name = m_terrain_config.getSetting("Name", "General");
	if (terrain_name.empty())
	{
		ErrorUtils::ShowError(_L("Terrain loading error"), _L("the terrain name cannot be empty"));
		exit(125);
	}

	ogre_terrain_config_filename = m_terrain_config.getSetting("GeometryConfig", "General");
	// otc = ogre terrain config
	if (ogre_terrain_config_filename.find(".otc") == String::npos)
	{
		ErrorUtils::ShowError(_L("Terrain loading error"), _L("the new terrain mode only supports .otc configurations"));
		exit(125);
	}

	ambient_color = StringConverter::parseColourValue(m_terrain_config.getSetting("AmbientColor", "General"), ColourValue::White);
	category_id = StringConverter::parseInt(m_terrain_config.getSetting("CategoryID", "General"), 129);
	guid = m_terrain_config.getSetting("GUID", "General");
	start_position = StringConverter::parseVector3(m_terrain_config.getSetting("StartPosition", "General"), Vector3(512.0f, 0.0f, 512.0f));
	version = StringConverter::parseInt(m_terrain_config.getSetting("Version", "General"), 1);
	gravity = StringConverter::parseReal(m_terrain_config.getSetting("Gravity", "General"), -9.81);

	// parse author info
	ConfigFile::SettingsIterator it = m_terrain_config.getSettingsIterator("Authors");

	authors.clear();

	while (it.hasMoreElements())
	{
		String type = it.peekNextKey();   // e.g. terrain
		String name = it.peekNextValue(); // e.g. john doe

		if (!name.empty())
		{
			authorinfo_t author;

			author.type = type;
			author.name = name;

			authors.push_back(author);
		}

		it.moveNext();
	}
}
Пример #2
0
void TerrainManager::loadTerrainObjects()
{
	try
	{
		ConfigFile::SettingsIterator objectsIterator = m_terrain_config.getSettingsIterator("Objects");

		while (objectsIterator.hasMoreElements())
		{
			String sname = objectsIterator.peekNextKey();
			StringUtil::trim(sname);

			object_manager->loadObjectConfigFile(sname);
			objectsIterator.moveNext();
		}
	} catch(...)
	{
		// no objects found
	}

	// bakes the geometry and things
	object_manager->postLoad();
}