示例#1
0
Checksum Scenario::load(const string &path) {
    Checksum scenarioChecksum;
	try {
		scenarioChecksum.addFile(path);
		checksumValue.addFile(path);

		string name= cutLastExt(lastDir(path));
		Logger::getInstance().add("Scenario: " + formatString(name), true);

		//parse xml
		XmlTree xmlTree;
		xmlTree.load(path);
		const XmlNode *scenarioNode= xmlTree.getRootNode();
		const XmlNode *scriptsNode= scenarioNode->getChild("scripts");

		for(int i= 0; i<scriptsNode->getChildCount(); ++i){
			const XmlNode *scriptNode = scriptsNode->getChild(i);

			scripts.push_back(Script(getFunctionName(scriptNode), scriptNode->getText()));
		}
	}
	//Exception handling (conversions and so on);
	catch(const exception &e) {
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw runtime_error("Error: " + path + "\n" + e.what());
	}

	return scenarioChecksum;
}
void UnitParticleSystemType::load(const XmlNode *particleFileNode, const string &dir, const string &path,
		RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
		string parentLoader, string techtreePath) {

	try{
		XmlTree xmlTree;

		std::map<string,string> mapExtraTagReplacementValues;
		mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
		xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
		loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
		const XmlNode *particleSystemNode= xmlTree.getRootNode();
		
		if(particleFileNode){
			// immediate children in the particleFileNode will override the particleSystemNode
			particleFileNode->setSuper(particleSystemNode);
			particleSystemNode= particleFileNode;
		}
		
		UnitParticleSystemType::load(particleSystemNode, dir, renderer,
				loadedFileList, parentLoader, techtreePath);
	}
	catch(const exception &e){
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw megaglest_runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
	}
}
Object* ObjectLoader::loadObjectFromFile(const char* filename){
	Object* object = NULL;
	//Leo el archivo y lo parseo en un arbol
	XmlTree* xmlTree = XmlParser::parse(string(WindowConnector::getBaseApplicationPath() + filename).c_str());
	//***Transformo el arbol en un Object***
	XmlTreeNode* root =  xmlTree->getRootNode();
	//Primiero busco la etiqueta de Object
	XmlTreeNode* objectNode = NULL;
	for(unsigned int i=0; i < root->getChildNodes().size(); i++){
		objectNode = root->getChildNodes()[i];
		if(objectNode->getName().compare("Object")==0){	
			//Cargo el mesh y le seteo los valores del xml
			object = initObject(objectNode);
			break;
		}
	}
    if(object == NULL){
        if(xmlTree != NULL){ delete xmlTree; }
		return NULL; //Error
    }

	//Busco las etiquetas de Mesh y reemplazo los valores del xml
	Mesh* mesh = object->getMesh();
	if(mesh->getChilds()->size() > 0){		
		loadMesh(mesh, objectNode);		
	}
	//Busco las etiquetas de Light y las agrego a las luces del objeto
	loadLights(object, objectNode);

	//Guardo el path en el object
	object->setFilename(filename);

    delete xmlTree;
	return object;
}
XmlTree* ScaenaAnimationWriter::animationsToXmlTree(list<AnimationDataTransfer*>* animations){
	XmlTree* xmlTree = new XmlTree();
	XmlTreeNode* rootNode = xmlTree->getRootNode();

	// Agrego el tag inicial
	XmlTreeNode* safNode = new XmlTreeNode("ScaenaAnimationFile", rootNode);
	rootNode->addChild(safNode);

	// Agrego todas las animaciones
	list<AnimationDataTransfer*>::iterator animIt = animations->begin();
	while( animIt != animations->end() ){

		// Agrego el tag de animacion
		XmlTreeNode* animationNode = new XmlTreeNode("Animation", safNode);
		safNode->addChild(animationNode);

		// Agrego como atributo el nombre de la animacion
		AnimationDataTransfer* animationDataTransfer = *animIt;
		animationNode->addAttribute(new XmlNodeAttribute("Name", animationDataTransfer->name));

		// Agrego cada uno de los keyframes
		list<KeyFrameDataTransfer*>::iterator keyIt = animationDataTransfer->keyframes->begin();
		while(keyIt != animationDataTransfer->keyframes->end()){
			keyFrameToXmlTree(animationNode, *keyIt);
			++keyIt;
		}	
		++animIt;
	}
	return xmlTree;
}
bool GenerationProcessor::processScaenaAnimationFile(string& inAnimationFile, string& outAnimationFile, string& keyFrameFBXFile, string& animationName, float keyDuration){
	//Parseo el archivo de modelo
	FbxModelLoader* fbxLoader = new FbxModelLoader();
	ModelDataTransfer* modelDataTransfer = fbxLoader->loadModel(keyFrameFBXFile.c_str());
	KeyFrameDataTransfer* keyframe = getKeyFrameData(modelDataTransfer, 0);
	keyframe->animationTime = keyDuration;
	delete fbxLoader;

	// Si tengo SAF de entrada, lo cargo para agregarle la nueva animacion o keyframe
	if(!inAnimationFile.empty()){
		Logger::getInstance()->logInfo(new Log("Procesando el SAF de salida..."));

		//Leo el archivo y lo parseo en un arbol
		XmlTree* xmlTree = XmlParser::parse(inAnimationFile.c_str());
		XmlTreeNode* rootNode =  xmlTree->getRootNode();

		// Busco el nodo de archivo SAF
		XmlTreeNode* safNode = rootNode->searchDirectChild("ScaenaAnimationFile", 0);
		if(safNode != NULL){
			// Busco si alguna animacion tiene el mismo nombre que la indicada, si no creo una nueva
			XmlTreeNode* animationNode = searchForAnimation(safNode, animationName);
			if(animationNode == NULL){
				animationNode = new XmlTreeNode("Animation", safNode);
				animationNode->addAttribute(new XmlNodeAttribute("Name", animationName));
				safNode->addChild(animationNode);
			}
			// Agrego el keyframe
			XmlTreeNode* keyFrameNode = new XmlTreeNode("KeyFrame", animationNode);
			keyFrameNode->addAttribute(new XmlNodeAttribute("DurationInSeconds", StringUtils::toString(keyframe->animationTime)));
			ScaenaAnimationWriter::skeletonToXmlTree(keyFrameNode, keyframe->getRootSkeleton());			
			animationNode->addChild(keyFrameNode);			

			// Grabo en el archivo SAF (REVIEW: podria dejar de escribir cada cambio en disco)
			XmlParser::writeXmlToFile(outAnimationFile.c_str(), xmlTree);
		}
		else{
			throw new AnimationLoadException("No se puede procesar el SAF de entrada");
		}
	}
	// Si no tengo SAF de entrada, creo la estructura de cero
	else{
		list<AnimationDataTransfer*> animations;
		AnimationDataTransfer* animation = new AnimationDataTransfer();
		animation->name = animationName;
		animation->keyframes->push_back(keyframe);
		animations.push_back(animation);
		// Escribo el SAF e indico que ahora tengo archivo de entrada
		ScaenaAnimationWriter::writeAnimation(outAnimationFile, &animations);
		inAnimationFile = outAnimationFile;
	}	
	delete modelDataTransfer;
	delete keyframe;
	return true;
}
示例#6
0
void UnitParticleSystemType::load(const string &dir, const string &path, RendererInterface *renderer){

	try{
		XmlTree xmlTree;
		xmlTree.load(path);
		const XmlNode *particleSystemNode= xmlTree.getRootNode();
		
		UnitParticleSystemType::load(particleSystemNode, dir, renderer);
	}
	catch(const exception &e){
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
	}
}
XmlTree* ObjectLoader::objectToXlmTree(Object* object){
	XmlTree* xmlTree = new XmlTree();
	XmlTreeNode* node = xmlTree->getRootNode();
	XmlTreeNode* objectNode = new XmlTreeNode("Object", node);
	node->addChild(objectNode);
	objectNode->createAttribute("id", object->getId());
	objectNode->createAttribute("class", "Object");
	objectNode->createAttribute("meshPath", object->getMesh()->getFilePath());
	//Escribo el mesh asociado en nodos
	writeFullMeshToNodes(objectNode, object->getMesh());
	//Escribo las luces asociadas al objeto
	writeAllLightsToNodes(objectNode, object->getAttachedLights());
	return xmlTree;
}
示例#8
0
void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum,
		std::map<string,vector<pair<string, string> > > &loadedFileList) {
	if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	random.init(time(NULL));

	if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	string name= lastDir(dir);
	tileset_name = name;
	string currentPath = dir;
	endPathWithSlash(currentPath);
	string path= currentPath + name + ".xml";
	string sourceXMLFile = path;

	checksum->addFile(path);
	tilesetChecksum->addFile(path);
	checksumValue.addFile(path);

	try {
		char szBuf[8096]="";
		snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingTileset","",true).c_str(),formatString(name).c_str());
		Logger::getInstance().add(szBuf, true);

		Renderer &renderer= Renderer::getInstance();

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//printf("About to load tileset [%s]\n",path.c_str());
		//parse xml
		XmlTree xmlTree;
		xmlTree.load(path,Properties::getTagReplacementValues());
		loadedFileList[path].push_back(make_pair(currentPath,currentPath));

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		const XmlNode *tilesetNode= xmlTree.getRootNode();

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//surfaces
		const XmlNode *surfacesNode= tilesetNode->getChild("surfaces");
		int partsize= 0;
		for(int i=0; i < surfCount; ++i) {

			const XmlNode *surfaceNode;
			if(surfacesNode->hasChildAtIndex("surface",i)){
				surfaceNode= surfacesNode->getChild("surface", i);
			}
			else {
				// cliff texture does not exist, use texture 2 instead
				surfaceNode= surfacesNode->getChild("surface", 2);
			}

			if(surfaceNode->hasAttribute("partsize")){
				partsize=surfaceNode->getAttribute("partsize",true)->getIntValue();
			}
			else{
				partsize=0;
			}

			if(partsize==0){
				int childCount= surfaceNode->getChildCount();
				surfPixmaps[i].resize(childCount);
				surfProbs[i].resize(childCount);

				for(int j = 0; j < childCount; ++j) {
					surfPixmaps[i][j] = NULL;
				}

				for(int j = 0; j < childCount; ++j) {
					const XmlNode *textureNode= surfaceNode->getChild("texture", j);
					if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
						surfPixmaps[i][j] = new Pixmap2D();
						surfPixmaps[i][j]->init(3);
						surfPixmaps[i][j]->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
					}
					loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,textureNode->getAttribute("path")->getRestrictedValue()));

					surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue();
				}
			}
			else {
				// read single big texture and cut it into pieces
				const XmlNode *textureNode= surfaceNode->getChild("texture", 0);
				Pixmap2D *pixmap=new Pixmap2D();
				pixmap->init(3);
				pixmap->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
				loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,textureNode->getAttribute("path")->getRestrictedValue()));
				int width=pixmap->getW();
				int heith=pixmap->getW();
				assert(width==heith);
				assert(width%64==0);
				assert(width%partsize==0);
				int parts=width/partsize;
				int numberOfPieces=parts*parts;
				partsArray[i]=parts;
				surfPixmaps[i].resize(numberOfPieces);
				surfProbs[i].resize(numberOfPieces);
				int j=0;
				for(int x = 0; x < parts; ++x) {
					for(int y = 0; y < parts; ++y) {
						surfPixmaps[i][j] = new Pixmap2D();
						surfPixmaps[i][j]->init(partsize,partsize,3);
						surfPixmaps[i][j]->copyImagePart(x*partsize,y*partsize,pixmap);
						surfProbs[i][j]=-1;
						j++;
					}
				}
			}
		}

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//object models
		const XmlNode *objectsNode= tilesetNode->getChild("objects");
		for(int i=0; i<objCount; ++i){
			const XmlNode *objectNode= objectsNode->getChild("object", i);
			int childCount= objectNode->getChildCount();

			int objectHeight = 0;
			bool walkable = objectNode->getAttribute("walkable")->getBoolValue();
			if(walkable == false) {
				const XmlAttribute *heightAttribute = objectNode->getAttribute("height",false);
				if(heightAttribute != NULL) {
					objectHeight = heightAttribute->getIntValue();
				}
			}

			objectTypes[i].init(childCount, i, walkable,objectHeight);
			for(int j=0; j<childCount; ++j) {
				const XmlNode *modelNode= objectNode->getChild("model", j);
				const XmlAttribute *pathAttribute= modelNode->getAttribute("path");
				TilesetModelType* tmt=objectTypes[i].loadModel(pathAttribute->getRestrictedValue(currentPath),&loadedFileList, sourceXMLFile);
				loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,pathAttribute->getRestrictedValue()));

				if(modelNode->hasAttribute("anim-speed") == true) {
					int animSpeed= modelNode->getAttribute("anim-speed")->getIntValue();
					tmt->setAnimSpeed(animSpeed);
				}

				if(modelNode->hasChild("particles")){
					const XmlNode *particleNode= modelNode->getChild("particles");
					bool particleEnabled= particleNode->getAttribute("value")->getBoolValue();
					if(particleEnabled){
						for(int k=0; k<particleNode->getChildCount(); ++k){
							const XmlNode *particleFileNode= particleNode->getChild("particle-file", k);
							string path= particleFileNode->getAttribute("path")->getRestrictedValue();
							ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
							objectParticleSystemType->load(particleFileNode, dir, currentPath + path,
									&Renderer::getInstance(), loadedFileList, sourceXMLFile,"");
							loadedFileList[currentPath + path].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));

							tmt->addParticleSystem(objectParticleSystemType);
						}
					}
				}

				//rotationAllowed
				if(modelNode->hasAttribute("rotationAllowed") == true) {
					tmt->setRotationAllowed(modelNode->getAttribute("rotationAllowed")->getBoolValue());
				}
				else if(modelNode->hasChild("rotationAllowed")){
					const XmlNode *rotationAllowedNode= modelNode->getChild("rotationAllowed");
					tmt->setRotationAllowed(rotationAllowedNode->getAttribute("value")->getBoolValue());
				}
				else{
					tmt->setRotationAllowed(true);
				}

				//smoothTwoFrameAnim
				if(modelNode->hasAttribute("smoothTwoFrameAnim") == true) {
					tmt->setSmoothTwoFrameAnim(modelNode->getAttribute("smoothTwoFrameAnim")->getBoolValue());
				}
				else{
					tmt->setSmoothTwoFrameAnim(false);
				}
			}
		}

		// Now free up the pixmap memory
		for(int i=0; i<objCount; ++i){
			objectTypes[i].deletePixels();
		}

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//ambient sounds
		ambientSounds.load(dir, tilesetNode->getChild("ambient-sounds"), loadedFileList, sourceXMLFile);

		//parameters
		const XmlNode *parametersNode= tilesetNode->getChild("parameters");

		//water
		const XmlNode *waterNode= parametersNode->getChild("water");
		waterTex= renderer.newTexture3D(rsGame);
		if(waterTex) {
			waterTex->setMipmap(false);
			waterTex->setWrapMode(Texture::wmRepeat);
		}
		waterEffects= waterNode->getAttribute("effects")->getBoolValue();

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		int waterFrameCount= waterNode->getChildCount();
		if(waterTex) {
			waterTex->getPixmap()->init(waterFrameCount, 4);
		}
		for(int i=0; i<waterFrameCount; ++i){
			const XmlNode *waterFrameNode= waterNode->getChild("texture", i);
			if(waterTex) {
				waterTex->getPixmap()->loadSlice(waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath), i);
			}
			loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,waterFrameNode->getAttribute("path")->getRestrictedValue()));
		}

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//fog
		const XmlNode *fogNode= parametersNode->getChild("fog");
		fog= fogNode->getAttribute("enabled")->getBoolValue();
		if(fog){
			fogMode= fogNode->getAttribute("mode")->getIntValue(1, 2);
			fogDensity= fogNode->getAttribute("density")->getFloatValue();
			fogColor.x= fogNode->getAttribute("color-red")->getFloatValue(0.f, 1.f);
			fogColor.y= fogNode->getAttribute("color-green")->getFloatValue(0.f, 1.f);
			fogColor.z= fogNode->getAttribute("color-blue")->getFloatValue(0.f, 1.f);
		}

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//sun and moon light colors
		const XmlNode *sunLightColorNode= parametersNode->getChild("sun-light");
		sunLightColor.x= sunLightColorNode->getAttribute("red")->getFloatValue();
		sunLightColor.y= sunLightColorNode->getAttribute("green")->getFloatValue();
		sunLightColor.z= sunLightColorNode->getAttribute("blue")->getFloatValue();

		const XmlNode *moonLightColorNode= parametersNode->getChild("moon-light");
		moonLightColor.x= moonLightColorNode->getAttribute("red")->getFloatValue();
		moonLightColor.y= moonLightColorNode->getAttribute("green")->getFloatValue();
		moonLightColor.z= moonLightColorNode->getAttribute("blue")->getFloatValue();

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//weather
		const XmlNode *weatherNode= parametersNode->getChild("weather");
		float sunnyProb= weatherNode->getAttribute("sun")->getFloatValue(0.f, 1.f);
		float rainyProb= weatherNode->getAttribute("rain")->getFloatValue(0.f, 1.f) + sunnyProb;

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

#ifdef USE_STREFLOP
		float rnd= streflop::fabs(static_cast<streflop::Simple>(random.randRange(-1.f, 1.f)));
#else
		float rnd= fabs(random.randRange(-1.f, 1.f));
#endif

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		if(rnd < sunnyProb) {
			weather= wSunny;
		}
		else if(rnd < rainyProb) {
			weather= wRainy;
		}
		else {
			weather= wSnowy;
		}

		//printf("==> Weather is: %d rnd = %f [sun: %f rainyProb: %f]",weather,rnd,sunnyProb,rainyProb);

		if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	}
	//Exception handling (conversions and so on);
	catch(const exception &e) {
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw megaglest_runtime_error("Error: " + path + "\n" + e.what());
	}

    Lang &lang = Lang::getInstance();
    lang.loadTilesetStrings(name);
}
MenuBackground::MenuBackground() : rps(NULL) {
	Renderer &renderer= Renderer::getInstance();

	//load data
	string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);

	XmlTree xmlTree;
	xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues());
	const XmlNode *menuNode= xmlTree.getRootNode();

	//water
	const XmlNode *waterNode= menuNode->getChild("water");
	water= waterNode->getAttribute("value")->getBoolValue();
	if(water){
		waterHeight= waterNode->getAttribute("height")->getFloatValue();

		//water texture
		waterTexture= renderer.newTexture2D(rsMenu);
		if(waterTexture) {
			waterTexture->getPixmap()->init(4);
			waterTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/water.tga"));
		}
	}

	//fog
	const XmlNode *fogNode= menuNode->getChild("fog");
	fog= fogNode->getAttribute("value")->getBoolValue();
	if(fog){
		fogDensity= fogNode->getAttribute("density")->getFloatValue();
	}

	//rain
	bool withRainEffect = Config::getInstance().getBool("RainEffectMenu","true");
	if(withRainEffect == true) {
		rain= menuNode->getChild("rain")->getAttribute("value")->getBoolValue();
		if(rain) {
			createRainParticleSystem();
		}
	}
	else {
		rain = false;
	}

	//camera
	const XmlNode *cameraNode= menuNode->getChild("camera");

	//position
	const XmlNode *positionNode= cameraNode->getChild("start-position");
	Vec3f startPosition;
    startPosition.x= positionNode->getAttribute("x")->getFloatValue();
	startPosition.y= positionNode->getAttribute("y")->getFloatValue();
	startPosition.z= positionNode->getAttribute("z")->getFloatValue();
	camera.setPosition(startPosition);

	//rotation
	const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
	Vec3f startRotation;
    startRotation.x= rotationNode->getAttribute("x")->getFloatValue();
	startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
	startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
	camera.setOrientation(Quaternion(EulerAngles(
		degToRad(startRotation.x),
		degToRad(startRotation.y),
		degToRad(startRotation.z))));

	//load main model
	mainModel= renderer.newModel(rsMenu);
	if(mainModel) {
		string mainModelFile = "data/core/menu/main_model/menu_main.g3d";
		if(menuNode->hasChild("menu-background-model") == true) {
			//mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
			const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model");
			mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue();
		}
		mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile));
	}

	//models
	for(int i=0; i<5; ++i){
		characterModels[i]= renderer.newModel(rsMenu);
		if(characterModels[i]) {
			characterModels[i]->load(getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d"));
		}
	}

	//about position
	positionNode= cameraNode->getChild("about-position");
	aboutPosition.x= positionNode->getAttribute("x")->getFloatValue();
	aboutPosition.y= positionNode->getAttribute("y")->getFloatValue();
	aboutPosition.z= positionNode->getAttribute("z")->getFloatValue();
	rotationNode= cameraNode->getChild("about-rotation");

	targetCamera= NULL;
	t= 0.f;
	fade= 0.f;
	anim= 0.f;
}
示例#10
0
MenuBackground::MenuBackground(){

	Renderer &renderer= Renderer::getInstance();

	//load data

	XmlTree xmlTree;
	xmlTree.load("data/core/menu/menu.xml");
	const XmlNode *menuNode= xmlTree.getRootNode();

	//water
	const XmlNode *waterNode= menuNode->getChild("water");
	water= waterNode->getAttribute("value")->getBoolValue();
	if(water){
		waterHeight= waterNode->getAttribute("height")->getFloatValue();

		//water texture
		waterTexture= renderer.newTexture2D(ResourceScope::MENU);
		waterTexture->getPixmap()->init(4);
		waterTexture->getPixmap()->load("data/core/menu/textures/water.tga");
	}

	//fog
	const XmlNode *fogNode= menuNode->getChild("fog");
	fog= fogNode->getAttribute("value")->getBoolValue();
	if(fog){
		fogDensity= fogNode->getAttribute("density")->getFloatValue();
	}

	// rain
	rain = menuNode->getChild("rain")->getAttribute("value")->getBoolValue();
	if(rain){
		RainParticleSystem *rps= new RainParticleSystem();
		rps->setSpeed(12.f / WORLD_FPS);
		rps->setEmissionRate(25.f);
		rps->setWindSpeed2(-90.f, 4.f / WORLD_FPS);
		rps->setPos(Vec3f(0.f, 25.f, 0.f));
		rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f));
		rps->setRadius(30.f);
		renderer.manageParticleSystem(rps, ResourceScope::MENU);

		for(int i=0; i<raindropCount; ++i){
			raindropStates[i]= random.randRange(0.f, 1.f);
			raindropPos[i]= computeRaindropPos();
		}
	} else if (menuNode->getOptionalBoolValue("snow")) {
		SnowParticleSystem *sps = new SnowParticleSystem(1200);
		sps->setSpeed(1.5f / WORLD_FPS);
		sps->setEmissionRate(2.f);
		sps->setWindSpeed2(-90.f, 0.5f / WORLD_FPS);
		sps->setPos(Vec3f(0.f, 25.f, 0.f));
		sps->setRadius(30.f);
		sps->setTexture(g_coreData.getSnowTexture());
		renderer.manageParticleSystem(sps, ResourceScope::MENU);
	}

	//camera
	const XmlNode *cameraNode= menuNode->getChild("camera");

	//position
	const XmlNode *positionNode= cameraNode->getChild("start-position");
	Vec3f startPosition;
    startPosition.x= positionNode->getAttribute("x")->getFloatValue();
	startPosition.y= positionNode->getAttribute("y")->getFloatValue();
	startPosition.z= positionNode->getAttribute("z")->getFloatValue();
	camera.setPosition(startPosition);

	//rotation
	const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
	Vec3f startRotation;
    startRotation.x= rotationNode->getAttribute("x")->getFloatValue();
	startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
	startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
	camera.setOrientation(Quaternion(EulerAngles(
		degToRad(startRotation.x),
		degToRad(startRotation.y),
		degToRad(startRotation.z))));

	// load main model
	mainModel= renderer.newModel(ResourceScope::MENU);
	mainModel->load("data/core/menu/main_model/menu_main.g3d", 2, 2);

	// models
	for(int i=0; i<5; ++i){
		characterModels[i]= renderer.newModel(ResourceScope::MENU);
		try {
			characterModels[i]->load("data/core/menu/about_models/character"+intToStr(i)+".g3d", 2, 2);
		} catch (runtime_error &e) {
			g_logger.logError(e.what());
		}
	}

	// about position
	positionNode= cameraNode->getChild("about-position");
	aboutPosition.x= positionNode->getAttribute("x")->getFloatValue();
	aboutPosition.y= positionNode->getAttribute("y")->getFloatValue();
	aboutPosition.z= positionNode->getAttribute("z")->getFloatValue();
	rotationNode= cameraNode->getChild("about-rotation");

	targetCamera = 0;
	t = 0.f;
	fade = 0.f;
	anim = 0.f;
}
示例#11
0
void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum){
    
	this->id= id;
    string path;

	try{

		Logger::getInstance().add("Unit type: " + formatString(name), true);

		//file load
		path= dir+"/"+name+".xml";

		checksum->addFile(path);

		XmlTree xmlTree;
		xmlTree.load(path);
		const XmlNode *unitNode= xmlTree.getRootNode();

		const XmlNode *parametersNode= unitNode->getChild("parameters");

		//size
		size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
		
		//height
		height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
		
		//maxHp
		maxHp= parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue();
		
		//hpRegeneration
		hpRegeneration= parametersNode->getChild("max-hp")->getAttribute("regeneration")->getIntValue();
		
		//maxEp
		maxEp= parametersNode->getChild("max-ep")->getAttribute("value")->getIntValue();
		
		if(maxEp!=0){
			//wpRegeneration
			epRegeneration= parametersNode->getChild("max-ep")->getAttribute("regeneration")->getIntValue();
		}

		//armor
		armor= parametersNode->getChild("armor")->getAttribute("value")->getIntValue();
		
		//armor type string
		string armorTypeName= parametersNode->getChild("armor-type")->getAttribute("value")->getRestrictedValue();
		armorType= techTree->getArmorType(armorTypeName);

		//sight
		sight= parametersNode->getChild("sight")->getAttribute("value")->getIntValue();
		
		//prod time
		productionTime= parametersNode->getChild("time")->getAttribute("value")->getIntValue();

		//multi selection
		multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();

		//cellmap
		const XmlNode *cellMapNode= parametersNode->getChild("cellmap");
		bool hasCellMap= cellMapNode->getAttribute("value")->getBoolValue();
		if(hasCellMap){
			cellMap= new bool[size*size];
			for(int i=0; i<size; ++i){
				const XmlNode *rowNode= cellMapNode->getChild("row", i);
				string row= rowNode->getAttribute("value")->getRestrictedValue();
				if(row.size()!=size){
					throw runtime_error("Cellmap row has not the same length as unit size");
				}
				for(int j=0; j<row.size(); ++j){
					cellMap[i*size+j]= row[j]=='0'? false: true;
				}
			}
		}

		//levels
		const XmlNode *levelsNode= parametersNode->getChild("levels");
		levels.resize(levelsNode->getChildCount());
		for(int i=0; i<levels.size(); ++i){
			const XmlNode *levelNode= levelsNode->getChild("level", i);
			levels[i].init(
				levelNode->getAttribute("name")->getRestrictedValue(),
				levelNode->getAttribute("kills")->getIntValue());
		}

		//fields
		const XmlNode *fieldsNode= parametersNode->getChild("fields");
		for(int i=0; i<fieldsNode->getChildCount(); ++i){
			const XmlNode *fieldNode= fieldsNode->getChild("field", i);
			string fieldName= fieldNode->getAttribute("value")->getRestrictedValue();
			if(fieldName=="land"){
				fields[fLand]= true;
			}
			else if(fieldName=="air"){
				fields[fAir]= true;
			}
			else{
				throw runtime_error("Not a valid field: "+fieldName+": "+ path);
			}
		}

		//properties
		const XmlNode *propertiesNode= parametersNode->getChild("properties");
		for(int i=0; i<propertiesNode->getChildCount(); ++i){
			const XmlNode *propertyNode= propertiesNode->getChild("property", i);
			string propertyName= propertyNode->getAttribute("value")->getRestrictedValue();
			bool found= false;
			for(int i=0; i<pCount; ++i){
				if(propertyName==propertyNames[i]){
					properties[i]= true;
					found= true;
					break;
				}
			}
			if(!found){
				throw runtime_error("Unknown property: " + propertyName);
			}
		}

		//light
		const XmlNode *lightNode= parametersNode->getChild("light");
		light= lightNode->getAttribute("enabled")->getBoolValue();
		if(light){
			lightColor.x= lightNode->getAttribute("red")->getFloatValue(0.f, 1.f);
			lightColor.y= lightNode->getAttribute("green")->getFloatValue(0.f, 1.f);
			lightColor.z= lightNode->getAttribute("blue")->getFloatValue(0.f, 1.f);	
		}

		//unit requirements
		const XmlNode *unitRequirementsNode= parametersNode->getChild("unit-requirements");
		for(int i=0; i<unitRequirementsNode->getChildCount(); ++i){
			const XmlNode *unitNode= 	unitRequirementsNode->getChild("unit", i);
			string name= unitNode->getAttribute("name")->getRestrictedValue();
			unitReqs.push_back(factionType->getUnitType(name));
		}

		//upgrade requirements
		const XmlNode *upgradeRequirementsNode= parametersNode->getChild("upgrade-requirements");
		for(int i=0; i<upgradeRequirementsNode->getChildCount(); ++i){
			const XmlNode *upgradeReqNode= upgradeRequirementsNode->getChild("upgrade", i);
			string name= upgradeReqNode->getAttribute("name")->getRestrictedValue();
			upgradeReqs.push_back(factionType->getUpgradeType(name));
		}

		//resource requirements
		const XmlNode *resourceRequirementsNode= parametersNode->getChild("resource-requirements");
		costs.resize(resourceRequirementsNode->getChildCount());
		for(int i=0; i<costs.size(); ++i){
			const XmlNode *resourceNode= resourceRequirementsNode->getChild("resource", i);
			string name= resourceNode->getAttribute("name")->getRestrictedValue();
			int amount= resourceNode->getAttribute("amount")->getIntValue();
			costs[i].init(techTree->getResourceType(name), amount);
		}

		//resources stored
		const XmlNode *resourcesStoredNode= parametersNode->getChild("resources-stored");
		storedResources.resize(resourcesStoredNode->getChildCount());
		for(int i=0; i<storedResources.size(); ++i){
			const XmlNode *resourceNode= resourcesStoredNode->getChild("resource", i);
			string name= resourceNode->getAttribute("name")->getRestrictedValue();
			int amount= resourceNode->getAttribute("amount")->getIntValue();
			storedResources[i].init(techTree->getResourceType(name), amount);
		}

		//image
		const XmlNode *imageNode= parametersNode->getChild("image");
		image= Renderer::getInstance().newTexture2D(rsGame);
		image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());

		//image cancel
		const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel");
		cancelImage= Renderer::getInstance().newTexture2D(rsGame);
		cancelImage->load(dir+"/"+imageCancelNode->getAttribute("path")->getRestrictedValue());

		//meeting point
		const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point");
		meetingPoint= meetingPointNode->getAttribute("value")->getBoolValue();
		if(meetingPoint){
			meetingPointImage= Renderer::getInstance().newTexture2D(rsGame);
			meetingPointImage->load(dir+"/"+meetingPointNode->getAttribute("image-path")->getRestrictedValue());
		}

		//selection sounds
		const XmlNode *selectionSoundNode= parametersNode->getChild("selection-sounds");
		if(selectionSoundNode->getAttribute("enabled")->getBoolValue()){
			selectionSounds.resize(selectionSoundNode->getChildCount());
			for(int i=0; i<selectionSounds.getSounds().size(); ++i){
				const XmlNode *soundNode= selectionSoundNode->getChild("sound", i);
				string path= soundNode->getAttribute("path")->getRestrictedValue();
				StaticSound *sound= new StaticSound();
				sound->load(dir + "/" + path);
				selectionSounds[i]= sound;
			}
		}

		//command sounds
		const XmlNode *commandSoundNode= parametersNode->getChild("command-sounds");
		if(commandSoundNode->getAttribute("enabled")->getBoolValue()){
			commandSounds.resize(commandSoundNode->getChildCount());
			for(int i=0; i<commandSoundNode->getChildCount(); ++i){
				const XmlNode *soundNode= commandSoundNode->getChild("sound", i);
				string path= soundNode->getAttribute("path")->getRestrictedValue();
				StaticSound *sound= new StaticSound();
				sound->load(dir + "/" + path);
				commandSounds[i]= sound;
			}
		}

		//skills
		const XmlNode *skillsNode= unitNode->getChild("skills");
		skillTypes.resize(skillsNode->getChildCount());
		for(int i=0; i<skillTypes.size(); ++i){
			const XmlNode *sn= skillsNode->getChild("skill", i);
			const XmlNode *typeNode= sn->getChild("type");
			string classId= typeNode->getAttribute("value")->getRestrictedValue();
			SkillType *skillType= SkillTypeFactory::getInstance().newInstance(classId);
			skillType->load(sn, dir, techTree, factionType);
			skillTypes[i]= skillType;
		}

		//commands
		const XmlNode *commandsNode= unitNode->getChild("commands");
		commandTypes.resize(commandsNode->getChildCount()); 
		for(int i=0; i<commandTypes.size(); ++i){
			const XmlNode *commandNode= commandsNode->getChild("command", i);
			const XmlNode *typeNode= commandNode->getChild("type");
			string classId= typeNode->getAttribute("value")->getRestrictedValue();
			CommandType *commandType= CommandTypeFactory::getInstance().newInstance(classId);
			commandType->load(i, commandNode, dir, techTree, factionType, *this);
			commandTypes[i]= commandType;
		}
				
		computeFirstStOfClass();
		computeFirstCtOfClass();

		if(getFirstStOfClass(scStop)==NULL){
			throw runtime_error("Every unit must have at least one stop skill: "+ path);
		}
		if(getFirstStOfClass(scDie)==NULL){
			throw runtime_error("Every unit must have at least one die skill: "+ path);
		}
	
	}
	//Exception handling (conversions and so on);
	catch(const exception &e){
		throw runtime_error("Error loading UnitType: " + path + "\n" + e.what());
	}
}
示例#12
0
bool Modification::load(const string &dir) {
	g_logger.logProgramEvent("Modification: " + dir, true);
	bool loadOk = true;

	string path = dir + "/" + m_name + ".xml";

	name = m_name;

	XmlTree xmlTree;
	try { xmlTree.load(path); }
	catch (runtime_error e) {
		g_logger.logXmlError(path, e.what());
		g_logger.logError("Fatal Error: could not load " + path);
		return false;
	}
	const XmlNode *modificationNode;
	try { modificationNode = xmlTree.getRootNode(); }
	catch (runtime_error e) {
		g_logger.logXmlError(path, e.what());
		return false;
	}
	const XmlNode *parametersNode;
	try { parametersNode = modificationNode->getChild("parameters"); }
	catch (runtime_error e) {
		g_logger.logXmlError(path, e.what());
		return false;
	}
	if (!RequirableType::load(parametersNode, dir)) {
		loadOk = false;
	}
	try {
	    const XmlNode *serviceNode = parametersNode->getChild("service");
	    service = serviceNode->getAttribute("scope")->getRestrictedValue();
	} catch (runtime_error e) {
		g_logger.logXmlError(dir, e.what());
		loadOk = false;
	}
	try {
	    const XmlNode *equipmentNode = parametersNode->getChild("equipment-types", 0, false);
		if(equipmentNode) {
			for(int i = 0; i < equipmentNode->getChildCount(); ++i) {
                try {
                    const XmlNode *typeNode = equipmentNode->getChild("equipment-type", i);
                    string ename = typeNode->getAttribute("name")->getRestrictedValue();
                    equipment.push_back(ename);
                } catch (runtime_error e) {
                    g_logger.logXmlError(dir, e.what());
                    loadOk = false;
                }
			}
		}

	} catch (runtime_error e) {
		g_logger.logXmlError(dir, e.what());
		loadOk = false;
	}
	try {
		const XmlNode *resourceRequirementsNode = parametersNode->getChild("resource-requirements", 0, false);
		if(resourceRequirementsNode) {
			costs.resize(resourceRequirementsNode->getChildCount());
			for(int i = 0; i < costs.size(); ++i) {
				try {
					const XmlNode *resourceNode = resourceRequirementsNode->getChild("resource", i);
					string rname = resourceNode->getAttribute("name")->getRestrictedValue();
					int amount = resourceNode->getAttribute("amount")->getIntValue();
                    int amount_plus = resourceNode->getAttribute("plus")->getIntValue();
                    fixed amount_multiply = resourceNode->getAttribute("multiply")->getFixedValue();
                    costs[i].init(g_world.getTechTree()->getResourceType(rname), amount, amount_plus, amount_multiply);
				} catch (runtime_error e) {
					g_logger.logXmlError(dir, e.what());
					loadOk = false;
				}
			}
		}
	} catch (runtime_error e) {
		g_logger.logXmlError(dir, e.what());
		loadOk = false;
	}
	try {
        const XmlNode *statisticsNode = parametersNode->getChild("statistics", 0, false);
	    if (statisticsNode) {
            if (!statistics.load(statisticsNode, dir)) {
                loadOk = false;
            }
	    }
    }
    catch (runtime_error e) {
		g_logger.logXmlError(dir, e.what());
		loadOk = false;
	}
	const XmlNode *effectsNode = parametersNode->getChild("effects", 0, false);
	if (effectsNode) {
		effectTypes.resize(effectsNode->getChildCount());
		for(int i=0; i < effectsNode->getChildCount(); ++i) {
			const XmlNode *effectNode = effectsNode->getChild("effect", i);
			EffectType *effectType = new EffectType();
			effectType->load(effectNode, dir);
			effectTypes[i] = effectType;
		}
	}
    return loadOk;
}
示例#13
0
void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum) {
	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	random.init(time(NULL));

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	string name= lastDir(dir);
	string path= dir + "/" + name + ".xml";

	checksum->addFile(path);
	tilesetChecksum->addFile(path);
	checksumValue.addFile(path);

	try {
		Logger::getInstance().add("Tileset: "+formatString(name), true);
		Renderer &renderer= Renderer::getInstance();

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//parse xml
		XmlTree xmlTree;
		xmlTree.load(path);

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		const XmlNode *tilesetNode= xmlTree.getRootNode();

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//surfaces
		const XmlNode *surfacesNode= tilesetNode->getChild("surfaces");
		for(int i=0; i<surfCount; ++i){
			const XmlNode *surfaceNode= surfacesNode->getChild("surface", i);

			int childCount= surfaceNode->getChildCount();
			surfPixmaps[i].resize(childCount);
			surfProbs[i].resize(childCount);
			for(int j=0; j<childCount; ++j){
				const XmlNode *textureNode= surfaceNode->getChild("texture", j);
				surfPixmaps[i][j].init(3);
				surfPixmaps[i][j].load(dir +"/"+textureNode->getAttribute("path")->getRestrictedValue());
				surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue();
			}
		}

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//object models
		const XmlNode *objectsNode= tilesetNode->getChild("objects");
		for(int i=0; i<objCount; ++i){
			const XmlNode *objectNode= objectsNode->getChild("object", i);
			int childCount= objectNode->getChildCount();

			int objectHeight = 0;
			bool walkable = objectNode->getAttribute("walkable")->getBoolValue();
			if(walkable == false) {
				const XmlAttribute *heightAttribute = objectNode->getAttribute("height",false);
				if(heightAttribute != NULL) {
					objectHeight = heightAttribute->getIntValue();
				}
			}

			objectTypes[i].init(childCount, i, walkable,objectHeight);
			for(int j=0; j<childCount; ++j) {
				const XmlNode *modelNode= objectNode->getChild("model", j);
				const XmlAttribute *pathAttribute= modelNode->getAttribute("path");
				objectTypes[i].loadModel(dir +"/"+ pathAttribute->getRestrictedValue());
			}
		}

		// Now free up the pixmap memory
		for(int i=0; i<objCount; ++i){
			objectTypes[i].deletePixels();
		}

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//ambient sounds
		ambientSounds.load(dir, tilesetNode->getChild("ambient-sounds"));

		//parameters
		const XmlNode *parametersNode= tilesetNode->getChild("parameters");

		//water
		const XmlNode *waterNode= parametersNode->getChild("water");
		waterTex= renderer.newTexture3D(rsGame);
		waterTex->setMipmap(false);
		waterTex->setWrapMode(Texture::wmRepeat);
		waterEffects= waterNode->getAttribute("effects")->getBoolValue();

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		int waterFrameCount= waterNode->getChildCount();
		waterTex->getPixmap()->init(waterFrameCount, 4);
		for(int i=0; i<waterFrameCount; ++i){
			const XmlNode *waterFrameNode= waterNode->getChild("texture", i);
			waterTex->getPixmap()->loadSlice(dir +"/"+ waterFrameNode->getAttribute("path")->getRestrictedValue(), i);
		}

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//fog
		const XmlNode *fogNode= parametersNode->getChild("fog");
		fog= fogNode->getAttribute("enabled")->getBoolValue();
		if(fog){
			fogMode= fogNode->getAttribute("mode")->getIntValue(1, 2);
			fogDensity= fogNode->getAttribute("density")->getFloatValue();
			fogColor.x= fogNode->getAttribute("color-red")->getFloatValue(0.f, 1.f);
			fogColor.y= fogNode->getAttribute("color-green")->getFloatValue(0.f, 1.f);
			fogColor.z= fogNode->getAttribute("color-blue")->getFloatValue(0.f, 1.f);
		}

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//sun and moon light colors
		const XmlNode *sunLightColorNode= parametersNode->getChild("sun-light");
		sunLightColor.x= sunLightColorNode->getAttribute("red")->getFloatValue();
		sunLightColor.y= sunLightColorNode->getAttribute("green")->getFloatValue();
		sunLightColor.z= sunLightColorNode->getAttribute("blue")->getFloatValue();

		const XmlNode *moonLightColorNode= parametersNode->getChild("moon-light");
		moonLightColor.x= moonLightColorNode->getAttribute("red")->getFloatValue();
		moonLightColor.y= moonLightColorNode->getAttribute("green")->getFloatValue();
		moonLightColor.z= moonLightColorNode->getAttribute("blue")->getFloatValue();

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		//weather
		const XmlNode *weatherNode= parametersNode->getChild("weather");
		float sunnyProb= weatherNode->getAttribute("sun")->getFloatValue(0.f, 1.f);
		float rainyProb= weatherNode->getAttribute("rain")->getFloatValue(0.f, 1.f) + sunnyProb;

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

#ifdef USE_STREFLOP
		float rnd= streflop::fabs(random.randRange(-1.f, 1.f));
#else
		float rnd= fabs(random.randRange(-1.f, 1.f));
#endif

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

		if(rnd < sunnyProb) {
			weather= wSunny;
		}
		else if(rnd < rainyProb) {
			weather= wRainy;
		}
		else {
			weather= wSnowy;
		}

		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

	}
	//Exception handling (conversions and so on);
	catch(const exception &e) {
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw runtime_error("Error: " + path + "\n" + e.what());
	}
}
void ScaenaAnimationFileWriter::writeKeyFrameToFileSystem(string filename, SkinnedAnimationKeyFrame* keyframe){
	XmlTree* xmlTree = new XmlTree();
	XmlTreeNode* node = xmlTree->getRootNode();
	this->keyFrameToXmlTree(node, keyframe);
	XmlParser::writeXmlToFile((WindowConnector::getBaseApplicationPath() + string(filename)).c_str(), xmlTree);
}