示例#1
0
void CSampleBankManager::init(NLGEORGES::UFormElm *mixerConfig)
{
	if (mixerConfig == 0)
		return;
	
	NLGEORGES::UFormElm	*virtualBanks;
	mixerConfig->getNodeByName(&virtualBanks, ".VirtualBanks");
	if (virtualBanks == 0)
		return;
	
	uint size;
	virtualBanks->getArraySize(size);
	
	for (uint i=0; i<size; ++i)
	{
		NLGEORGES::UFormElm	*virtualBank;
		virtualBanks->getArrayNode(&virtualBank, i);

		if (virtualBank != 0)
		{
			std::vector<TFilteredBank> vfb;
			std::string virtualName;
			virtualBank->getValueByName(virtualName, ".VirtualName");
			NLGEORGES::UFormElm	*realBanks;
			virtualBank->getNodeByName(&realBanks, ".FilteredBank");
			if (realBanks != 0)
			{
				uint size2;
				realBanks->getArraySize(size2);

				for (uint j=0; j<size2; ++j)
				{
					TFilteredBank fb;
					std::string	bankName;
					NLGEORGES::UFormElm	*realBank;
					realBank->getArrayNode(&realBank, j);

					realBank->getValueByName(bankName, ".SampleBank");
					fb.BankName = CStringMapper::map(bankName);
					realBank->getValueByName(fb.Filter, ".Filter");

					vfb.push_back(fb);
				}
			}

			if (!vfb.empty())
			{
				TStringId virtualNameId = CStringMapper::map(virtualName);
				m_VirtualBanks.insert(std::make_pair(virtualNameId, vfb));
				// create the sample bank
				CSampleBank *sampleBank = new CSampleBank(virtualNameId, this);
			}
		}
	}
}
示例#2
0
void CBackgroundSound::importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot)
{
	NLGEORGES::UFormElm *psoundType;
	std::string dfnName;

	// some basic checking.
	formRoot.getNodeByName(&psoundType, ".SoundType");
	nlassert(psoundType != NULL);
	psoundType->getDfnName(dfnName);
	nlassert(dfnName == "background_sound.dfn");

	// Call the base class
	CSound::importForm(filename, formRoot);

	// Read the array of sound with there respective filter.
	{
		_Sounds.clear();

		NLGEORGES::UFormElm *psoundList;

		formRoot.getNodeByName(&psoundList, ".SoundType.Sounds");

		if (psoundList != 0 && psoundList->isArray())
		{
			uint size;
			psoundList->getArraySize(size);

			for (uint i=0; i<size; ++i)
			{
				TSoundInfo	sound;
				NLGEORGES::UFormElm	*psoundItem;

				psoundList->getArrayNode(&psoundItem, i);

				if (psoundItem != NULL)
				{
					// Read the sound name.
					std::string soundName;
					psoundItem->getValueByName(soundName, "Sound");
					sound.SoundName = CStringMapper::map(CFile::getFilenameWithoutExtension(soundName));


					// Read the environnement flag.
					for (uint j=0; j<UAudioMixer::TBackgroundFlags::NB_BACKGROUND_FLAGS; j++)
					{
						char tmp[200];
						sprintf(tmp, "Filter%2.2u", j);
						psoundItem->getValueByName(sound.Filter.Flags[j], tmp);
					}
				}

				_Sounds.push_back(sound);
			}
		}
	}

	_DurationValid = false;
}
/** Load additionnal ig from a continent (ryzom specific)
  * \param parameter a config file that contains the name of the continent containing the zones we are processing
  * \param zone2bbox This will be filled with the name of a zone and the bbox of the village it contains
  * \param a map of shape
  * \param a vector that will be filled with a zone name and the bbox of the village it contains
  */
static void computeIGBBoxFromContinent(NLMISC::CConfigFile &parameter,									   
									   TShapeMap &shapeMap,
									   TString2LightingBBox &zone2BBox									   
							          )
{
		
	try
	{
		CConfigFile::CVar &continent_name_var = parameter.getVar ("continent_name");
		CConfigFile::CVar &level_design_directory = parameter.getVar ("level_design_directory");
		CConfigFile::CVar &level_design_world_directory = parameter.getVar ("level_design_world_directory");						
		CConfigFile::CVar &level_design_dfn_directory = parameter.getVar ("level_design_dfn_directory");
		CPath::addSearchPath(level_design_dfn_directory.asString(), true, false);
		CPath::addSearchPath(level_design_world_directory.asString(), true, false);

		std::string continentName = continent_name_var.asString();
		if (CFile::getExtension(continentName).empty())
			continentName += ".continent";
		// Load the form
		NLGEORGES::UFormLoader *loader = NLGEORGES::UFormLoader::createLoader();
		//
		std::string pathName = level_design_world_directory.asString() + "/" + continentName;
		if (pathName.empty())
		{		
			nlwarning("Can't find continent form : %s", continentName.c_str());
			return;
		}		
		NLGEORGES::UForm *villageForm;
		villageForm = loader->loadForm(pathName.c_str());
		if(villageForm != NULL)
		{
			NLGEORGES::UFormElm &rootItem = villageForm->getRootNode();
			// try to get the village list
			// Load the village list
			NLGEORGES::UFormElm *villagesItem;
			if(!(rootItem.getNodeByName (&villagesItem, "Villages") && villagesItem))
			{
				nlwarning("No villages where found in %s", continentName.c_str());
				return;
			}

			// Get number of village
			uint numVillage;
			nlverify (villagesItem->getArraySize (numVillage));

			// For each village
			for(uint k = 0; k < numVillage; ++k)
			{				
				NLGEORGES::UFormElm *currVillage;
				if (!(villagesItem->getArrayNode (&currVillage, k) && currVillage))
				{
					nlwarning("Couldn't get village %d in continent %s", continentName.c_str(), k);
					continue;
				}
				// check that this village is in the dependency zones
				NLGEORGES::UFormElm *zoneNameItem;
				if (!currVillage->getNodeByName (&zoneNameItem, "Zone") && zoneNameItem)
				{
					nlwarning("Couldn't get zone item of village %d in continent %s", continentName.c_str(), k);
					continue;
				}
				std::string zoneName;
				if (!zoneNameItem->getValue(zoneName))
				{
					nlwarning("Couldn't get zone name of village %d in continent %s", continentName.c_str(), k);
					continue;
				}
				zoneName = NLMISC::toLower(CFile::getFilenameWithoutExtension(zoneName));				
				CLightingBBox result;				
				// ok, it is in the dependant zones
				computeBBoxFromVillage(currVillage, continentName, k, shapeMap, result);
				if (!result.OccludingBox.IsVoid || result.ReceivingBox.IsVoid)
				{
					zone2BBox[zoneName] = result;					
				}										
			}				
		}
		else 
		{
			nlwarning("Can't load continent form : %s", continentName.c_str());
		}				
	}	
	catch (NLMISC::EUnknownVar &e)
	{
		nlinfo(e.what());
	}
}
示例#4
0
//**********************************************************************************************
void CVillageGrid::addVillagesFromContinent(const std::string &continentSheetName)
{
	// Load the form
	NLGEORGES::UFormLoader *loader = NLGEORGES::UFormLoader::createLoader();
	//
	std::string path  = CPath::lookup(continentSheetName, false, false);
	if (path.empty())
	{
		nlwarning("Path not found for %s.", continentSheetName.c_str());
		return;
	}
	NLGEORGES::UForm *villageForm;
	villageForm = loader->loadForm(path.c_str());
	if(villageForm != NULL)
	{
		NLGEORGES::UFormElm &rootItem = villageForm->getRootNode();
		// try to get the village list
		// Load the village list
		NLGEORGES::UFormElm *villagesItem;
		if(!(rootItem.getNodeByName (&villagesItem, "Villages") && villagesItem))
		{
			nlwarning("No villages where found in %s", continentSheetName.c_str());
			return;
		}

		// Get number of village
		uint numVillage;
		nlverify (villagesItem->getArraySize (numVillage));

		// For each village
		for(uint k = 0; k < numVillage; ++k)
		{
			NLGEORGES::UFormElm *currVillage;
			if (!(villagesItem->getArrayNode (&currVillage, k) && currVillage))
			{
				nlwarning("Couldn't get village %d in continent %s", continentSheetName.c_str(), k);
				continue;
			}
			// check that this village is in the dependency zones
			NLGEORGES::UFormElm *zoneNameItem;
			if (!currVillage->getNodeByName (&zoneNameItem, "Zone") && zoneNameItem)
			{
				nlwarning("Couldn't get zone item of village %d in continent %s", continentSheetName.c_str(), k);
				continue;
			}
			std::string zoneName;
			if (!zoneNameItem->getValue(zoneName))
			{
				nlwarning("Couldn't get zone name of village %d in continent %s", continentSheetName.c_str(), k);
				continue;
			}			
			sint zoneX, zoneY;
			if (!getZonePos(zoneName, zoneX, zoneY))
			{
				nlwarning("Zone name of village %d in continent %s is invalid", continentSheetName.c_str(), k);
				continue;
			}			
			sint villageMinX, villageMinY;
			sint villageMaxX, villageMaxY;

			
			// retrieve width & height of covered region
			uint32 regionWidth;
			uint32 regionHeight;
			float  centerX, centerY;
			if (!currVillage->getValueByName(regionWidth,  "Width")   ||
				!currVillage->getValueByName(regionHeight, "Height")  || 
				!currVillage->getValueByName(centerX,	   "CenterX") ||
				!currVillage->getValueByName(centerY,	   "CenterY"))
			{
				nlwarning("Can't retrieve region covered by village %d in continent %s", continentSheetName.c_str(), k);
				continue;
			}
			//
			villageMinX = villageMaxX = zoneX;
			villageMinY = villageMaxY = zoneY;
			// extends with bbox from center to min corner if leveldesigner forgot to enter good width & height			
			villageMaxX = std::max(villageMaxX, (sint) ((zoneX * 160.f + 2.f * centerX) / 160.f));
			villageMaxY = std::max(villageMaxY, (sint) ((zoneY * 160.f + 2.f * centerY) / 160.f));			
			//
			villageMinX -= _ZoneMinX;
			villageMaxX -= _ZoneMinX;
			villageMinY -= _ZoneMinY;
			villageMaxY -= _ZoneMinY;
			//
			CVillage village;
			if (loadVillageSheet(currVillage, continentSheetName, k, village))
			{
				//
				village.FileModificationDate = std::max(village.FileModificationDate, CFile::getFileModificationDate(path));
				//
				Villages.push_back(CVillage());
				Villages.back().swap(village);
				//
				for (sint y = villageMinY; y <= (sint) villageMaxY; ++y)
				{
					if (y < 0) continue;
					if (y >= (sint) VillageGrid.getHeight()) continue;
					for (sint x = villageMinX; x <= (sint) villageMaxX; ++x)
					{
						if (x < 0) continue;
						if (x >= (sint) VillageGrid.getWidth()) continue;
						VillageGrid(x, y).push_back(Villages.size() - 1);
					}
				}
			}
		}				
	}
	else 
	{
		nlwarning("Can't load continent form : %s", continentSheetName.c_str());
	}
}