1. Hesham Wahba
  2. ibex

Commits

Hesham Wahba  committed 9ef95d8

- update to Hydrax 0.5.2 with GLSL and Ogre 1.9 compile fixes

  • Participants
  • Parent commits 169266c
  • Branches master

Comments (0)

Files changed (37)

File IbexMac.xcodeproj/project.xcworkspace/xcuserdata/hesh.xcuserdatad/UserInterfaceState.xcuserstate

  • Ignore whitespace
Binary file modified.

File IbexMac/Dependencies/Hydrax/CfgFileManager.cpp

View file
  • Ignore whitespace
-/*
---------------------------------------------------------------------------------
-This source file is part of Hydrax.
-Visit ---
-
-Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
-                                           <xavyiy@gmail.com>
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
---------------------------------------------------------------------------------
-*/
-
-#include "CfgFileManager.h"
-
-#include "Hydrax.h"
-
-namespace Hydrax
-{
-	CfgFileManager::CfgFileManager(Hydrax* h)
-		: mHydrax(h)
-	{
-	}
-
-	CfgFileManager::~CfgFileManager()
-	{
-	}
-
-	const bool CfgFileManager::load(const Ogre::String& File) const
-	{
-		std::pair<bool, Ogre::ConfigFile> CfgFileResult; 
-		_loadCfgFile(File, CfgFileResult);
-	
-		if (!CfgFileResult.first)
-		{
-			return false;
-		}
-
-		Ogre::ConfigFile &CfgFile = CfgFileResult.second;
-
-		if (!_checkVersion(CfgFile))
-		{
-			return false;
-		}
-
-		// Load main options
-		mHydrax->setPosition(_getVector3Value(CfgFile,"Position"));
-		mHydrax->setPlanesError(_getFloatValue(CfgFile,"PlanesError"));
-		mHydrax->setShaderMode(static_cast<MaterialManager::ShaderMode>(_getIntValue(CfgFile, "ShaderMode")));
-		mHydrax->setFullReflectionDistance(_getFloatValue(CfgFile,"FullReflectionDistance"));
-		mHydrax->setGlobalTransparency(_getFloatValue(CfgFile,"GlobalTransparency"));
-		mHydrax->setNormalDistortion(_getFloatValue(CfgFile,"NormalDistortion"));
-		mHydrax->setWaterColor(_getVector3Value(CfgFile,"WaterColor"));
-
-		// Load components settings
-		_loadComponentsSettings(CfgFile);
-
-		// Load rtt settings
-		_loadRttSettings(CfgFile);
-
-		// Load module and noise settings
-		if (mHydrax->getModule())
-		{
-			mHydrax->getModule()->loadCfg(CfgFile);
-
-			if (mHydrax->getModule()->getNoise())
-			{
-				mHydrax->getModule()->getNoise()->loadCfg(CfgFile);
-			}
-		}
-
-		return true;
-	}
-
-	const bool CfgFileManager::save(const Ogre::String& File, const Ogre::String& Path) const
-	{
-		Ogre::String Data = 
-			"#Hydrax cfg file.\n\n";
-
-		Data += "#Hydrax version field\n";
-		Data += _getVersionCfgString();
-
-		Data += "#Main options field\n";
-		Data += _getCfgString("Position",               mHydrax->getPosition());
-		Data += _getCfgString("PlanesError",            mHydrax->getPlanesError());
-		Data += "#Shader mode: 0=HLSL, 1=CG, 2=GLSL\n";
-		Data += _getCfgString("ShaderMode",             static_cast<int>(mHydrax->getShaderMode()));
-		Data += _getCfgString("FullReflectionDistance", mHydrax->getFullReflectionDistance());
-		Data += _getCfgString("GlobalTransparency",     mHydrax->getGlobalTransparency());
-		Data += _getCfgString("NormalDistortion",       mHydrax->getNormalDistortion()); 
-		Data += _getCfgString("WaterColor",             mHydrax->getWaterColor()); Data += "\n";
-
-		Data += "#Components field\n";
-		Data += _getComponentsCfgString();
-
-		Data += "#Rtt quality field(0x0 = Auto)\n";
-		Data += _getRttCfgString(); Data += "\n";
-
-		if (mHydrax->getModule())
-		{
-			mHydrax->getModule()->saveCfg(Data);
-
-			if (mHydrax->getModule()->getNoise())
-			{
-				mHydrax->getModule()->getNoise()->saveCfg(Data);
-			}
-		}
-
-		return _saveToFile(Data, File, Path);
-	}
-
-	const bool CfgFileManager::getSaveString(Ogre::String& Data) const
-	{
-		Data = "#Hydrax cfg file.\n\n";
-
-		Data += "#Hydrax version field\n";
-		Data += _getVersionCfgString();
-
-		Data += "#Main options field\n";
-		Data += _getCfgString("Position",               mHydrax->getPosition());
-		Data += _getCfgString("PlanesError",            mHydrax->getPlanesError());
-		Data += "#Shader mode: 0=HLSL, 1=CG, 2=GLSL\n";
-		Data += _getCfgString("ShaderMode",             static_cast<int>(mHydrax->getShaderMode()));
-		Data += _getCfgString("FullReflectionDistance", mHydrax->getFullReflectionDistance());
-		Data += _getCfgString("GlobalTransparency",     mHydrax->getGlobalTransparency());
-		Data += _getCfgString("NormalDistortion",       mHydrax->getNormalDistortion()); 
-		Data += _getCfgString("WaterColor",             mHydrax->getWaterColor()); Data += "\n";
-
-		Data += "#Components field\n";
-		Data += _getComponentsCfgString();
-
-		Data += "#Rtt quality field(0x0 = Auto)\n";
-		Data += _getRttCfgString(); Data += "\n";
-
-		if (mHydrax->getModule())
-		{
-			mHydrax->getModule()->saveCfg(Data);
-
-			if (mHydrax->getModule()->getNoise())
-			{
-				mHydrax->getModule()->getNoise()->saveCfg(Data);
-			}
-		}
-
-        return true;
-	}
-
-    const bool CfgFileManager::_saveToFile(const Ogre::String& Data, const Ogre::String& File, const Ogre::String& Path) const
-	{
-		FILE *DestinationFile = fopen((Path+"/"+File).c_str(), "w");
-
-		if (!DestinationFile)
-		{
-			return false;
-		}
-
-		fprintf(DestinationFile, "%s", Data.c_str());
-		fclose(DestinationFile);
-
-		try
-		{
-			Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(Path, HYDRAX_RESOURCE_GROUP);
-		}
-		catch(...)
-		{
-		}
-
-		Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Path, "FileSystem", HYDRAX_RESOURCE_GROUP);
-
-		HydraxLOG(File + " saved in " + Path + " .");
-		
-		return true;
-	}
-
-	const void CfgFileManager::_loadCfgFile(const Ogre::String& File, std::pair<bool,Ogre::ConfigFile> &Result) const
-	{
-		if(!Ogre::ResourceGroupManager::getSingleton().resourceExists(HYDRAX_RESOURCE_GROUP, File))
-		{
-			Result.first = false;
-			HydraxLOG("CfgFileManager::_getCfgFile(...): " + File + " doesn't found in " + HYDRAX_RESOURCE_GROUP + " resource group.");
-
-			return;
-		}
-
-		Result.first = true;
-		Result.second.load(Ogre::ResourceGroupManager::getSingleton().openResource(File, HYDRAX_RESOURCE_GROUP));
-
-		HydraxLOG(File + " loaded.");
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const int &Value)
-	{
-		return "<int>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Real &Value)
-	{
-		return "<float>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const bool &Value)
-	{
-		return "<bool>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Vector2 &Value)
-	{
-		return "<vector2>" + Name + "=" + Ogre::StringConverter::toString(Value.x) + "x" + Ogre::StringConverter::toString(Value.y) + "\n";
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Vector3 &Value)
-	{
-		return "<vector3>" + Name + "=" + Ogre::StringConverter::toString(Value.x) + "x" + Ogre::StringConverter::toString(Value.y) + "x" + Ogre::StringConverter::toString(Value.z) + "\n";
-	}
-
-	Ogre::String CfgFileManager::_getCfgString(const Ogre::String& Name, const Size& Value)
-	{
-		return "<size>" + Name + "=" + Ogre::StringConverter::toString(Value.Width) + "x" + Ogre::StringConverter::toString(Value.Height) + "\n";
-	}
-
-	const Ogre::String CfgFileManager::_getComponentsCfgString() const
-	{
-		Ogre::String Cmpnts = "Components=";
-
-		std::pair<bool, Ogre::String> Cmp[8] = {
-			std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_SUN),                    "Sun"), 
-			std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_FOAM),                   "Foam"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_DEPTH),                  "Depth"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_SMOOTH),                 "Smooth"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_CAUSTICS),               "Caustics"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER),             "Underwater"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS), "UnderwaterReflections"),
-		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS),     "UnderwaterGodRays"),};
-
-		for (int k = 0; k < 8; k++)
-		{
-			if (Cmp[k].first)
-			{
-				Cmpnts += Cmp[k].second;
-
-				bool isLast = true;
-
-			    for (int u = k+1; u < 8; u++)
-			    {
-				    if (Cmp[u].first)
-				    {
-				    	isLast = false;
-				    }
-			    }
-
-			    if (!isLast)
-			    {
-				    Cmpnts += "|";
-			    }
-			    else
-			    {
-			    	Cmpnts += "\n\n";
-			    }
-			}
-		}
-
-		// Sun parameters
-		if (Cmp[0].first)
-		{
-			Cmpnts += "#Sun parameters\n";
-			Cmpnts += _getCfgString("SunPosition", mHydrax->getSunPosition());
-			Cmpnts += _getCfgString("SunStrength", mHydrax->getSunStrength());
-			Cmpnts += _getCfgString("SunArea",     mHydrax->getSunArea());
-			Cmpnts += _getCfgString("SunColor",    mHydrax->getSunColor()); Cmpnts += "\n";
-		}
-		// Foam parameters
-		if (Cmp[1].first)
-		{
-			Cmpnts += "#Foam parameters\n";
-			Cmpnts += _getCfgString("FoamMaxDistance",  mHydrax->getFoamMaxDistance());
-			Cmpnts += _getCfgString("FoamScale",        mHydrax->getFoamScale());
-			Cmpnts += _getCfgString("FoamStart",        mHydrax->getFoamStart());
-			Cmpnts += _getCfgString("FoamTransparency", mHydrax->getFoamTransparency()); Cmpnts += "\n";
-		}
-		// Depth parameters
-		if (Cmp[2].first)
-		{
-			Cmpnts += "#Depth parameters\n";
-			Cmpnts += _getCfgString("DepthLimit", mHydrax->getDepthLimit()); Cmpnts += "\n";
-		}
-		// Smooth transitions parameters
-		if (Cmp[3].first)
-		{
-			Cmpnts += "#Smooth transitions parameters\n";
-			Cmpnts += _getCfgString("SmoothPower", mHydrax->getSmoothPower()); Cmpnts += "\n";
-		}
-		// Caustics parameters
-		if (Cmp[4].first)
-		{
-			Cmpnts += "#Caustics parameters\n";
-			Cmpnts += _getCfgString("CausticsScale", mHydrax->getCausticsScale());
-			Cmpnts += _getCfgString("CausticsPower", mHydrax->getCausticsPower());
-			Cmpnts += _getCfgString("CausticsEnd",   mHydrax->getCausticsEnd()); Cmpnts += "\n";
-		}
-		// God rays parameters
-		if (Cmp[7].first)
-		{
-			Cmpnts += "#God rays parameters\n";
-			Cmpnts += _getCfgString("GodRaysExposure",      mHydrax->getGodRaysExposure());
-			Cmpnts += _getCfgString("GodRaysIntensity",     mHydrax->getGodRaysIntensity()); 
-			Cmpnts += _getCfgString("GodRaysSpeed",         mHydrax->getGodRaysManager()->getSimulationSpeed());
-			Cmpnts += _getCfgString("GodRaysNumberOfRays",  mHydrax->getGodRaysManager()->getNumberOfRays()); 
-			Cmpnts += _getCfgString("GodRaysRaysSize",      mHydrax->getGodRaysManager()->getRaysSize()); 
-			Cmpnts += _getCfgString("GodRaysIntersections", mHydrax->getGodRaysManager()->areObjectsIntersectionsEnabled()); Cmpnts += "\n";
-		}
-
-		return Cmpnts;
-	}
-
-	bool CfgFileManager::_isStringInList(const Ogre::StringVector &List, const Ogre::String &Find)
-	{
-		for (unsigned int k = 0; k < List.size(); k++)
-		{
-			if (List[k] == Find)
-			{
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	const void CfgFileManager::_loadComponentsSettings(Ogre::ConfigFile& CfgFile) const
-	{
-		Ogre::StringVector Cmpnts = Ogre::StringUtil::split(CfgFile.getSetting("Components"), "|");
-
-		HydraxComponent ComponentsToLoad[8] = {
-			HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,
-			HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE};
-
-		if (_isStringInList(Cmpnts, "Sun"))
-		{
-			ComponentsToLoad[0] = HYDRAX_COMPONENT_SUN;
-		}
-		if (_isStringInList(Cmpnts, "Foam"))
-		{
-			ComponentsToLoad[1] = HYDRAX_COMPONENT_FOAM;
-		}
-		if (_isStringInList(Cmpnts, "Depth"))
-		{
-			ComponentsToLoad[2] = HYDRAX_COMPONENT_DEPTH;
-		}
-		if (_isStringInList(Cmpnts, "Smooth"))
-		{
-			ComponentsToLoad[3] = HYDRAX_COMPONENT_SMOOTH;
-		}
-		if (_isStringInList(Cmpnts, "Caustics"))
-		{
-			ComponentsToLoad[4] = HYDRAX_COMPONENT_CAUSTICS;
-		}
-		if (_isStringInList(Cmpnts, "Underwater"))
-		{
-			ComponentsToLoad[5] = HYDRAX_COMPONENT_UNDERWATER;
-		}
-		if (_isStringInList(Cmpnts, "UnderwaterReflections"))
-		{
-			ComponentsToLoad[6] = HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS;
-		}
-		if (_isStringInList(Cmpnts, "UnderwaterGodRays"))
-		{
-			ComponentsToLoad[7] = HYDRAX_COMPONENT_UNDERWATER_GODRAYS;
-		}
-
-		mHydrax->setComponents(static_cast<HydraxComponent>(
-			ComponentsToLoad[0] | ComponentsToLoad[1] | ComponentsToLoad[2] | ComponentsToLoad[3] |
-			ComponentsToLoad[4] | ComponentsToLoad[5] | ComponentsToLoad[6] | ComponentsToLoad[7]));
-		
-		if (_isStringInList(Cmpnts, "Sun"))
-		{
-			mHydrax->setSunPosition(_getVector3Value(CfgFile,"SunPosition"));
-			mHydrax->setSunStrength(_getFloatValue(CfgFile,"SunStrength"));
-			mHydrax->setSunArea(_getFloatValue(CfgFile,"SunArea"));
-			mHydrax->setSunColor(_getVector3Value(CfgFile,"SunColor"));
-		}
-
-		if (_isStringInList(Cmpnts, "Foam"))
-		{
-			mHydrax->setFoamMaxDistance(_getFloatValue(CfgFile,"FoamMaxDistance"));
-			mHydrax->setFoamScale(_getFloatValue(CfgFile,"FoamScale"));
-			mHydrax->setFoamStart(_getFloatValue(CfgFile,"FoamStart"));
-			mHydrax->setFoamTransparency(_getFloatValue(CfgFile,"FoamTransparency"));
-		}
-
-		if (_isStringInList(Cmpnts, "Depth"))
-		{
-			mHydrax->setDepthLimit(_getFloatValue(CfgFile,"DepthLimit"));
-		}
-
-		if (_isStringInList(Cmpnts, "Smooth"))
-		{
-			mHydrax->setSmoothPower(_getFloatValue(CfgFile,"SmoothPower"));
-		}
-
-		if (_isStringInList(Cmpnts, "Caustics"))
-		{
-			mHydrax->setCausticsScale(_getFloatValue(CfgFile,"CausticsScale"));
-			mHydrax->setCausticsPower(_getFloatValue(CfgFile,"CausticsPower"));
-			mHydrax->setCausticsEnd(_getFloatValue(CfgFile,"CausticsEnd"));
-		}
-
-		if (_isStringInList(Cmpnts, "UnderwaterGodRays"))
-		{
-			mHydrax->setGodRaysExposure(_getVector3Value(CfgFile,"GodRaysExposure"));
-			mHydrax->setGodRaysIntensity(_getFloatValue(CfgFile,"GodRaysIntensity"));
-			mHydrax->getGodRaysManager()->setSimulationSpeed(_getFloatValue(CfgFile,"GodRaysSpeed"));
-			mHydrax->getGodRaysManager()->setNumberOfRays(_getIntValue(CfgFile,"GodRaysNumberOfRays"));
-			mHydrax->getGodRaysManager()->setRaysSize(_getFloatValue(CfgFile,"GodRaysRaysSize"));
-			mHydrax->getGodRaysManager()->setObjectIntersectionsEnabled(_getBoolValue(CfgFile,"GodRaysIntersections"));
-		}
-	}
-
-	const Ogre::String CfgFileManager::_getRttCfgString() const
-	{
-		return
-			_getCfgString("Rtt_Quality_Reflection",   mHydrax->getRttManager()->getTextureSize(RttManager::RTT_REFLECTION)) +
-			_getCfgString("Rtt_Quality_Refraction",   mHydrax->getRttManager()->getTextureSize(RttManager::RTT_REFRACTION)) +
-			_getCfgString("Rtt_Quality_Depth",        mHydrax->getRttManager()->getTextureSize(RttManager::RTT_DEPTH)) +
-			_getCfgString("Rtt_Quality_URDepth",      mHydrax->getRttManager()->getTextureSize(RttManager::RTT_DEPTH_REFLECTION)) +
-			_getCfgString("Rtt_Quality_GPUNormalMap", mHydrax->getRttManager()->getTextureSize(RttManager::RTT_GPU_NORMAL_MAP));
-	}
-
-	const void CfgFileManager::_loadRttSettings(Ogre::ConfigFile& CfgFile) const
-	{
-		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_REFLECTION,_getSizeValue(CfgFile,"Rtt_Quality_Reflection"));
-		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_REFRACTION,_getSizeValue(CfgFile,"Rtt_Quality_Refraction"));
-		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_DEPTH,_getSizeValue(CfgFile,"Rtt_Quality_Depth"));
-		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_DEPTH_REFLECTION,_getSizeValue(CfgFile,"Rtt_Quality_URDepth"));
-		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_GPU_NORMAL_MAP,_getSizeValue(CfgFile,"Rtt_Quality_GPUNormalMap"));
-	}
-
-	const Ogre::String CfgFileManager::_getVersionCfgString() const
-	{
-		return "HydraxVersion=" +
-				// Major
-				Ogre::StringConverter::toString(HYDRAX_VERSION_MAJOR)+"." +
-				// Minor
-				Ogre::StringConverter::toString(HYDRAX_VERSION_MINOR)+"." +
-				// Patch
-				Ogre::StringConverter::toString(HYDRAX_VERSION_PATCH)+"\n\n";
-	}
-
-	const bool CfgFileManager::_checkVersion(Ogre::ConfigFile& CfgFile) const
-	{
-		if(CfgFile.getSetting("HydraxVersion") != (
-			    // Major
-				Ogre::StringConverter::toString(HYDRAX_VERSION_MAJOR)+"."+
-				// Minor
-				Ogre::StringConverter::toString(HYDRAX_VERSION_MINOR)+"."+
-				// Patch
-				Ogre::StringConverter::toString(HYDRAX_VERSION_PATCH)))
-		{
-			HydraxLOG("Config file version doesn't correspond with Hydrax version.");
-
-			return false;
-		}
-
-		return true;
-	}
-
-	int CfgFileManager::_getIntValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<int>" + Name);
-
-		if (Value == "")
-		{
-			return 0;
-		}
-		else
-		{
-			return Ogre::StringConverter::parseInt(Value);
-		}
-	}
-
-	Ogre::Real CfgFileManager::_getFloatValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<float>" + Name);
-
-		if (Value == "")
-		{
-			return 0;
-		}
-		else
-		{
-			return Ogre::StringConverter::parseReal(Value);
-		}
-	}
-
-	bool CfgFileManager::_getBoolValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<bool>" + Name);
-
-		if (Value == "")
-		{
-			return false;
-		}
-		else
-		{
-			return Ogre::StringConverter::parseBool(Value);
-		}
-	}
-
-	Ogre::Vector2 CfgFileManager::_getVector2Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<vector2>" + Name);
-
-		if (Value == "")
-		{
-			return Ogre::Vector2(0,0);
-		}
-		else
-		{
-			return Ogre::Vector2(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[0]),
-				                 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[1]));
-		}
-	}
-
-	Ogre::Vector3 CfgFileManager::_getVector3Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<vector3>" + Name);
-
-		if (Value == "")
-		{
-			return Ogre::Vector3(0,0,0);
-		}
-		else
-		{
-			return Ogre::Vector3(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[0]),
-				                 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[1]),
-								 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[2]));
-		}
-	}
-
-	Size CfgFileManager::_getSizeValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
-	{
-		Ogre::String Value = CfgFile.getSetting("<size>" + Name);
-
-		if (Value == "")
-		{
-			return Size(0);
-		}
-		else
-		{
-			return Size(Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value, "x")[0]),
-				        Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value, "x")[1]));
-		}
-	}
-}
+/*
+--------------------------------------------------------------------------------
+This source file is part of Hydrax.
+Visit ---
+
+Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
+                                           <xavyiy@gmail.com>
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+--------------------------------------------------------------------------------
+*/
+
+#include <CfgFileManager.h>
+
+#include <Hydrax.h>
+
+namespace Hydrax
+{
+	CfgFileManager::CfgFileManager(Hydrax* h)
+		: mHydrax(h)
+	{
+	}
+
+	CfgFileManager::~CfgFileManager()
+	{
+	}
+
+	const bool CfgFileManager::load(const Ogre::String& File) const
+	{
+		std::pair<bool, Ogre::ConfigFile> CfgFileResult; 
+		_loadCfgFile(File, CfgFileResult);
+	
+		if (!CfgFileResult.first)
+		{
+			return false;
+		}
+
+		Ogre::ConfigFile &CfgFile = CfgFileResult.second;
+
+		if (!_checkVersion(CfgFile))
+		{
+			return false;
+		}
+
+		// Load main options
+		mHydrax->setPosition(_getVector3Value(CfgFile,"Position"));
+		mHydrax->setPlanesError(_getFloatValue(CfgFile,"PlanesError"));
+		mHydrax->setShaderMode(static_cast<MaterialManager::ShaderMode>(_getIntValue(CfgFile, "ShaderMode")));
+		mHydrax->setFullReflectionDistance(_getFloatValue(CfgFile,"FullReflectionDistance"));
+		mHydrax->setGlobalTransparency(_getFloatValue(CfgFile,"GlobalTransparency"));
+		mHydrax->setNormalDistortion(_getFloatValue(CfgFile,"NormalDistortion"));
+		mHydrax->setWaterColor(_getVector3Value(CfgFile,"WaterColor"));
+
+		// Load components settings
+		_loadComponentsSettings(CfgFile);
+
+		// Load rtt settings
+		_loadRttSettings(CfgFile);
+
+		// Load module and noise settings
+		if (mHydrax->getModule())
+		{
+			mHydrax->getModule()->loadCfg(CfgFile);
+
+			if (mHydrax->getModule()->getNoise())
+			{
+				mHydrax->getModule()->getNoise()->loadCfg(CfgFile);
+			}
+		}
+
+		return true;
+	}
+
+	const bool CfgFileManager::save(const Ogre::String& File, const Ogre::String& Path) const
+	{
+		Ogre::String Data = 
+			"#Hydrax cfg file.\n\n";
+
+		Data += "#Hydrax version field\n";
+		Data += _getVersionCfgString();
+
+		Data += "#Main options field\n";
+		Data += _getCfgString("Position",               mHydrax->getPosition());
+		Data += _getCfgString("PlanesError",            mHydrax->getPlanesError());
+		Data += "#Shader mode: 0=HLSL, 1=CG, 2=GLSL\n";
+		Data += _getCfgString("ShaderMode",             static_cast<int>(mHydrax->getShaderMode()));
+		Data += _getCfgString("FullReflectionDistance", mHydrax->getFullReflectionDistance());
+		Data += _getCfgString("GlobalTransparency",     mHydrax->getGlobalTransparency());
+		Data += _getCfgString("NormalDistortion",       mHydrax->getNormalDistortion()); 
+		Data += _getCfgString("WaterColor",             mHydrax->getWaterColor()); Data += "\n";
+
+		Data += "#Components field\n";
+		Data += _getComponentsCfgString();
+
+		Data += "#Rtt quality field(0x0 = Auto)\n";
+		Data += _getRttCfgString(); Data += "\n";
+
+		if (mHydrax->getModule())
+		{
+			mHydrax->getModule()->saveCfg(Data);
+
+			if (mHydrax->getModule()->getNoise())
+			{
+				mHydrax->getModule()->getNoise()->saveCfg(Data);
+			}
+		}
+
+		return _saveToFile(Data, File, Path);
+	}
+
+	const bool CfgFileManager::_saveToFile(const Ogre::String& Data, const Ogre::String& File, const Ogre::String& Path) const
+	{
+		FILE *DestinationFile = fopen((Path+"/"+File).c_str(), "w");
+
+		if (!DestinationFile)
+		{
+			return false;
+		}
+
+		fprintf(DestinationFile, "%s", Data.c_str());
+		fclose(DestinationFile);
+
+		try
+		{
+			Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(Path, HYDRAX_RESOURCE_GROUP);
+		}
+		catch(...)
+		{
+		}
+
+		Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Path, "FileSystem", HYDRAX_RESOURCE_GROUP);
+
+		HydraxLOG(File + " saved in " + Path + " .");
+		
+		return true;
+	}
+
+	const void CfgFileManager::_loadCfgFile(const Ogre::String& File, std::pair<bool,Ogre::ConfigFile> &Result) const
+	{
+		if(!Ogre::ResourceGroupManager::getSingleton().resourceExists(HYDRAX_RESOURCE_GROUP, File))
+		{
+			Result.first = false;
+			HydraxLOG("CfgFileManager::_getCfgFile(...): " + File + " doesn't found in " + HYDRAX_RESOURCE_GROUP + " resource group.");
+
+			return;
+		}
+
+		Result.first = true;
+		Result.second.load(Ogre::ResourceGroupManager::getSingleton().openResource(File, HYDRAX_RESOURCE_GROUP));
+
+		HydraxLOG(File + " loaded.");
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const int &Value)
+	{
+		return "<int>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Real &Value)
+	{
+		return "<float>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const bool &Value)
+	{
+		return "<bool>" + Name + "=" + Ogre::StringConverter::toString(Value) + "\n";
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Vector2 &Value)
+	{
+		return "<vector2>" + Name + "=" + Ogre::StringConverter::toString(Value.x) + "x" + Ogre::StringConverter::toString(Value.y) + "\n";
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String &Name, const Ogre::Vector3 &Value)
+	{
+		return "<vector3>" + Name + "=" + Ogre::StringConverter::toString(Value.x) + "x" + Ogre::StringConverter::toString(Value.y) + "x" + Ogre::StringConverter::toString(Value.z) + "\n";
+	}
+
+	Ogre::String CfgFileManager::_getCfgString(const Ogre::String& Name, const Size& Value)
+	{
+		return "<size>" + Name + "=" + Ogre::StringConverter::toString(Value.Width) + "x" + Ogre::StringConverter::toString(Value.Height) + "\n";
+	}
+
+	const Ogre::String CfgFileManager::_getComponentsCfgString() const
+	{
+		Ogre::String Cmpnts = "Components=";
+
+		std::pair<bool, Ogre::String> Cmp[8] = {
+			std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_SUN),                    "Sun"), 
+			std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_FOAM),                   "Foam"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_DEPTH),                  "Depth"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_SMOOTH),                 "Smooth"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_CAUSTICS),               "Caustics"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER),             "Underwater"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS), "UnderwaterReflections"),
+		    std::pair<bool, Ogre::String>(mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS),     "UnderwaterGodRays"),};
+
+		for (int k = 0; k < 8; k++)
+		{
+			if (Cmp[k].first)
+			{
+				Cmpnts += Cmp[k].second;
+
+				bool isLast = true;
+
+			    for (int u = k+1; u < 8; u++)
+			    {
+				    if (Cmp[u].first)
+				    {
+				    	isLast = false;
+				    }
+			    }
+
+			    if (!isLast)
+			    {
+				    Cmpnts += "|";
+			    }
+			    else
+			    {
+			    	Cmpnts += "\n\n";
+			    }
+			}
+		}
+
+		// Sun parameters
+		if (Cmp[0].first)
+		{
+			Cmpnts += "#Sun parameters\n";
+			Cmpnts += _getCfgString("SunPosition", mHydrax->getSunPosition());
+			Cmpnts += _getCfgString("SunStrength", mHydrax->getSunStrength());
+			Cmpnts += _getCfgString("SunArea",     mHydrax->getSunArea());
+			Cmpnts += _getCfgString("SunColor",    mHydrax->getSunColor()); Cmpnts += "\n";
+		}
+		// Foam parameters
+		if (Cmp[1].first)
+		{
+			Cmpnts += "#Foam parameters\n";
+			Cmpnts += _getCfgString("FoamMaxDistance",  mHydrax->getFoamMaxDistance());
+			Cmpnts += _getCfgString("FoamScale",        mHydrax->getFoamScale());
+			Cmpnts += _getCfgString("FoamStart",        mHydrax->getFoamStart());
+			Cmpnts += _getCfgString("FoamTransparency", mHydrax->getFoamTransparency()); Cmpnts += "\n";
+		}
+		// Depth parameters
+		if (Cmp[2].first)
+		{
+			Cmpnts += "#Depth parameters\n";
+			Cmpnts += _getCfgString("DepthLimit", mHydrax->getDepthLimit()); Cmpnts += "\n";
+		}
+		// Smooth transitions parameters
+		if (Cmp[3].first)
+		{
+			Cmpnts += "#Smooth transitions parameters\n";
+			Cmpnts += _getCfgString("SmoothPower", mHydrax->getSmoothPower()); Cmpnts += "\n";
+		}
+		// Caustics parameters
+		if (Cmp[4].first)
+		{
+			Cmpnts += "#Caustics parameters\n";
+			Cmpnts += _getCfgString("CausticsScale", mHydrax->getCausticsScale());
+			Cmpnts += _getCfgString("CausticsPower", mHydrax->getCausticsPower());
+			Cmpnts += _getCfgString("CausticsEnd",   mHydrax->getCausticsEnd()); Cmpnts += "\n";
+		}
+		// God rays parameters
+		if (Cmp[7].first)
+		{
+			Cmpnts += "#God rays parameters\n";
+			Cmpnts += _getCfgString("GodRaysExposure",      mHydrax->getGodRaysExposure());
+			Cmpnts += _getCfgString("GodRaysIntensity",     mHydrax->getGodRaysIntensity()); 
+			Cmpnts += _getCfgString("GodRaysSpeed",         mHydrax->getGodRaysManager()->getSimulationSpeed());
+			Cmpnts += _getCfgString("GodRaysNumberOfRays",  mHydrax->getGodRaysManager()->getNumberOfRays()); 
+			Cmpnts += _getCfgString("GodRaysRaysSize",      mHydrax->getGodRaysManager()->getRaysSize()); 
+			Cmpnts += _getCfgString("GodRaysIntersections", mHydrax->getGodRaysManager()->areObjectsIntersectionsEnabled()); Cmpnts += "\n";
+		}
+
+		return Cmpnts;
+	}
+
+	bool CfgFileManager::_isStringInList(const Ogre::StringVector &List, const Ogre::String &Find)
+	{
+		for (unsigned int k = 0; k < List.size(); k++)
+		{
+			if (List[k] == Find)
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	const void CfgFileManager::_loadComponentsSettings(Ogre::ConfigFile& CfgFile) const
+	{
+		Ogre::StringVector Cmpnts = Ogre::StringUtil::split(CfgFile.getSetting("Components"), "|");
+
+		HydraxComponent ComponentsToLoad[8] = {
+			HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,
+			HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE,HYDRAX_COMPONENTS_NONE};
+
+		if (_isStringInList(Cmpnts, "Sun"))
+		{
+			ComponentsToLoad[0] = HYDRAX_COMPONENT_SUN;
+		}
+		if (_isStringInList(Cmpnts, "Foam"))
+		{
+			ComponentsToLoad[1] = HYDRAX_COMPONENT_FOAM;
+		}
+		if (_isStringInList(Cmpnts, "Depth"))
+		{
+			ComponentsToLoad[2] = HYDRAX_COMPONENT_DEPTH;
+		}
+		if (_isStringInList(Cmpnts, "Smooth"))
+		{
+			ComponentsToLoad[3] = HYDRAX_COMPONENT_SMOOTH;
+		}
+		if (_isStringInList(Cmpnts, "Caustics"))
+		{
+			ComponentsToLoad[4] = HYDRAX_COMPONENT_CAUSTICS;
+		}
+		if (_isStringInList(Cmpnts, "Underwater"))
+		{
+			ComponentsToLoad[5] = HYDRAX_COMPONENT_UNDERWATER;
+		}
+		if (_isStringInList(Cmpnts, "UnderwaterReflections"))
+		{
+			ComponentsToLoad[6] = HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS;
+		}
+		if (_isStringInList(Cmpnts, "UnderwaterGodRays"))
+		{
+			ComponentsToLoad[7] = HYDRAX_COMPONENT_UNDERWATER_GODRAYS;
+		}
+
+		mHydrax->setComponents(static_cast<HydraxComponent>(
+			ComponentsToLoad[0] | ComponentsToLoad[1] | ComponentsToLoad[2] | ComponentsToLoad[3] |
+			ComponentsToLoad[4] | ComponentsToLoad[5] | ComponentsToLoad[6] | ComponentsToLoad[7]));
+		
+		if (_isStringInList(Cmpnts, "Sun"))
+		{
+			mHydrax->setSunPosition(_getVector3Value(CfgFile,"SunPosition"));
+			mHydrax->setSunStrength(_getFloatValue(CfgFile,"SunStrength"));
+			mHydrax->setSunArea(_getFloatValue(CfgFile,"SunArea"));
+			mHydrax->setSunColor(_getVector3Value(CfgFile,"SunColor"));
+		}
+
+		if (_isStringInList(Cmpnts, "Foam"))
+		{
+			mHydrax->setFoamMaxDistance(_getFloatValue(CfgFile,"FoamMaxDistance"));
+			mHydrax->setFoamScale(_getFloatValue(CfgFile,"FoamScale"));
+			mHydrax->setFoamStart(_getFloatValue(CfgFile,"FoamStart"));
+			mHydrax->setFoamTransparency(_getFloatValue(CfgFile,"FoamTransparency"));
+		}
+
+		if (_isStringInList(Cmpnts, "Depth"))
+		{
+			mHydrax->setDepthLimit(_getFloatValue(CfgFile,"DepthLimit"));
+		}
+
+		if (_isStringInList(Cmpnts, "Smooth"))
+		{
+			mHydrax->setSmoothPower(_getFloatValue(CfgFile,"SmoothPower"));
+		}
+
+		if (_isStringInList(Cmpnts, "Caustics"))
+		{
+			mHydrax->setCausticsScale(_getFloatValue(CfgFile,"CausticsScale"));
+			mHydrax->setCausticsPower(_getFloatValue(CfgFile,"CausticsPower"));
+			mHydrax->setCausticsEnd(_getFloatValue(CfgFile,"CausticsEnd"));
+		}
+
+		if (_isStringInList(Cmpnts, "UnderwaterGodRays"))
+		{
+			mHydrax->setGodRaysExposure(_getVector3Value(CfgFile,"GodRaysExposure"));
+			mHydrax->setGodRaysIntensity(_getFloatValue(CfgFile,"GodRaysIntensity"));
+			mHydrax->getGodRaysManager()->setSimulationSpeed(_getFloatValue(CfgFile,"GodRaysSpeed"));
+			mHydrax->getGodRaysManager()->setNumberOfRays(_getIntValue(CfgFile,"GodRaysNumberOfRays"));
+			mHydrax->getGodRaysManager()->setRaysSize(_getFloatValue(CfgFile,"GodRaysRaysSize"));
+			mHydrax->getGodRaysManager()->setObjectIntersectionsEnabled(_getBoolValue(CfgFile,"GodRaysIntersections"));
+		}
+	}
+
+	const Ogre::String CfgFileManager::_getRttCfgString() const
+	{
+		return
+			_getCfgString("Rtt_Quality_Reflection",   mHydrax->getRttManager()->getTextureSize(RttManager::RTT_REFLECTION)) +
+			_getCfgString("Rtt_Quality_Refraction",   mHydrax->getRttManager()->getTextureSize(RttManager::RTT_REFRACTION)) +
+			_getCfgString("Rtt_Quality_Depth",        mHydrax->getRttManager()->getTextureSize(RttManager::RTT_DEPTH)) +
+			_getCfgString("Rtt_Quality_URDepth",      mHydrax->getRttManager()->getTextureSize(RttManager::RTT_DEPTH_REFLECTION)) +
+			_getCfgString("Rtt_Quality_GPUNormalMap", mHydrax->getRttManager()->getTextureSize(RttManager::RTT_GPU_NORMAL_MAP));
+	}
+
+	const void CfgFileManager::_loadRttSettings(Ogre::ConfigFile& CfgFile) const
+	{
+		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_REFLECTION,_getSizeValue(CfgFile,"Rtt_Quality_Reflection"));
+		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_REFRACTION,_getSizeValue(CfgFile,"Rtt_Quality_Refraction"));
+		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_DEPTH,_getSizeValue(CfgFile,"Rtt_Quality_Depth"));
+		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_DEPTH_REFLECTION,_getSizeValue(CfgFile,"Rtt_Quality_URDepth"));
+		mHydrax->getRttManager()->setTextureSize(RttManager::RTT_GPU_NORMAL_MAP,_getSizeValue(CfgFile,"Rtt_Quality_GPUNormalMap"));
+	}
+
+	const Ogre::String CfgFileManager::_getVersionCfgString() const
+	{
+		return "HydraxVersion=" +
+				// Major
+				Ogre::StringConverter::toString(HYDRAX_VERSION_MAJOR)+"." +
+				// Minor
+				Ogre::StringConverter::toString(HYDRAX_VERSION_MINOR)+"." +
+				// Patch
+				Ogre::StringConverter::toString(HYDRAX_VERSION_PATCH)+"\n\n";
+	}
+
+	const bool CfgFileManager::_checkVersion(Ogre::ConfigFile& CfgFile) const
+	{
+		if(CfgFile.getSetting("HydraxVersion") != (
+			    // Major
+				Ogre::StringConverter::toString(HYDRAX_VERSION_MAJOR)+"."+
+				// Minor
+				Ogre::StringConverter::toString(HYDRAX_VERSION_MINOR)+"."+
+				// Patch
+				Ogre::StringConverter::toString(HYDRAX_VERSION_PATCH)))
+		{
+			HydraxLOG("Config file version doesn't correspond with Hydrax version.");
+
+			return false;
+		}
+
+		return true;
+	}
+
+	int CfgFileManager::_getIntValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<int>" + Name);
+
+		if (Value == "")
+		{
+			return 0;
+		}
+		else
+		{
+			return Ogre::StringConverter::parseInt(Value);
+		}
+	}
+
+	Ogre::Real CfgFileManager::_getFloatValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<float>" + Name);
+
+		if (Value == "")
+		{
+			return 0;
+		}
+		else
+		{
+			return Ogre::StringConverter::parseReal(Value);
+		}
+	}
+
+	bool CfgFileManager::_getBoolValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<bool>" + Name);
+
+		if (Value == "")
+		{
+			return false;
+		}
+		else
+		{
+			return Ogre::StringConverter::parseBool(Value);
+		}
+	}
+
+	Ogre::Vector2 CfgFileManager::_getVector2Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<vector2>" + Name);
+
+		if (Value == "")
+		{
+			return Ogre::Vector2(0,0);
+		}
+		else
+		{
+			return Ogre::Vector2(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[0]),
+				                 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[1]));
+		}
+	}
+
+	Ogre::Vector3 CfgFileManager::_getVector3Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<vector3>" + Name);
+
+		if (Value == "")
+		{
+			return Ogre::Vector3(0,0,0);
+		}
+		else
+		{
+			return Ogre::Vector3(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[0]),
+				                 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[1]),
+								 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value, "x")[2]));
+		}
+	}
+
+	Size CfgFileManager::_getSizeValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name)
+	{
+		Ogre::String Value = CfgFile.getSetting("<size>" + Name);
+
+		if (Value == "")
+		{
+			return Size(0);
+		}
+		else
+		{
+			return Size(Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value, "x")[0]),
+				        Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value, "x")[1]));
+		}
+	}
+}

File IbexMac/Dependencies/Hydrax/CfgFileManager.h

View file
  • Ignore whitespace
-/*
---------------------------------------------------------------------------------
-This source file is part of Hydrax.
-Visit ---
-
-Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
-                                           <xavyiy@gmail.com>
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
---------------------------------------------------------------------------------
-*/
-
-#ifndef _Hydrax_CfgFileManager_H_
-#define _Hydrax_CfgFileManager_H_
-
-#include "Prerequisites.h"
-
-#include "Help.h"
-
-namespace Hydrax
-{
-	class Hydrax;
-
-	/** Config file manager.
-	    Class to load/save all Hydrax options from/to a config file
-	 */
-	class DllExport CfgFileManager
-	{
-	public:
-		/** Constructor
-		    @param h Hydrax parent pointer
-		 */
-		CfgFileManager(Hydrax *h);
-
-		/** Destructor
-		 */
-        ~CfgFileManager();
-
-		/** Load hydrax cfg file
-		    @param File File name
-			@return false if an error has been ocurred(Check the log file in this case).
-		 */
-		const bool load(const Ogre::String& File) const;
-
-		/** Save current hydrax config to a file
-		    @param File Destination file name
-			@param Path File path
-			@return false if an error has been ocurred(Check the log file in this case).
-		 */
-		const bool save(const Ogre::String& File, const Ogre::String& Path = "") const;
-
-		/** Return current hydrax config as string 
-		    @param Data Destination string to save config in
-			@return false if an error has been ocurred(Check the log file in this case).
-		 */
-        const bool getSaveString(Ogre::String& Data) const;
-
-		/** <int> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return int cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const int& Value);
-
-		/** <float> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return Ogre::Real cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Real& Value);
-
-		/** <bool> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return bool cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const bool& Value);
-
-		/** <vector2> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return Ogre::Vector2 cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Vector2& Value);
-
-		/** <vector3> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return Ogre::Vector3 cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Vector3& Value);
-
-		/** <size> Get the cfg string
-		    @param Name Parameter name
-		    @param Value Parameter value
-			@return Hydrax::Size cfg string
-		 */
-		static Ogre::String _getCfgString(const Ogre::String& Name, const Size& Value);
-
-		/** Get int value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return int value
-			@remarks if the parameter isn't found or the data type is not an int value, return 0 as default
-		 */
-		static int _getIntValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Get float value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return float value
-			@remarks if the parameter isn't found or the data type is not a float value, return 0 as default
-		 */
-		static Ogre::Real _getFloatValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Get bool value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return bool value
-			@remarks if the parameter isn't found or the data type is not a bool value, return false as default
-		 */
-		static bool _getBoolValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Get vector2 value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return vector2 value
-			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0) as default
-		 */
-		static Ogre::Vector2 _getVector2Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Get vector3 value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return vector3 value
-			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0,0) as default
-		 */
-		static Ogre::Vector3 _getVector3Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Get size value
-		    @param CfgFile Config file
-		    @param Name Parameter name
-			@return size value
-			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0) as default
-		 */
-		static Size _getSizeValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
-
-		/** Check is a std::vector<Ogre::String> contains a specified Ogre::String
-		    @param List String list
-			@param Find String to find
-			@return true if it's contained, false if not
-		 */
-		static bool _isStringInList(const Ogre::StringVector &List, const Ogre::String &Find);
-
-	private:
-		/** Save a string in file
-		    @param Data Data
-			@param File Destination file
-			@param Path File path
-			@return false if an error has ocurred
-		 */
-		const bool _saveToFile(const Ogre::String& Data, const Ogre::String& File, const Ogre::String& Path) const;
-
-		/** Load a cfg file in an Ogre::ConfigFile
-		    @param File File name
-			@param Result, std::pair<bool, Ogre::ConfigFile&> First: False if the file isn't in the Hydrax resource group, Second: Ogre::ConfigFile
-		 */
-		const void _loadCfgFile(const Ogre::String& File, std::pair<bool,Ogre::ConfigFile> &Result) const;
-
-		/** Get components config string
-		    @return Components cfg string
-		 */
-		const Ogre::String _getComponentsCfgString() const;
-
-		/** Load components settings
-		    @param CfgFile Config file
-		 */
-		const void _loadComponentsSettings(Ogre::ConfigFile& CfgFile) const;
-
-		/** Get rtt quality config string
-		    @return Rtt quality cfg string
-		 */
-		const Ogre::String _getRttCfgString() const;
-
-		/** Load rtt settings
-		    @param CfgFile Config file
-		 */
-		const void _loadRttSettings(Ogre::ConfigFile& CfgFile) const;
-
-		/** Get hydrax version cfg string
-		    @return Hydrax version cfg string
-		 */
-		const Ogre::String _getVersionCfgString() const;
-
-		/** Check hydrax version cfg file
-		    @param CfgFile Config file
-		    @return true if it's the same version, false if not.
-		 */
-		const bool _checkVersion(Ogre::ConfigFile& CfgFile) const;
-		    
-		/// Hydrax parent pointer
-		Hydrax* mHydrax;
-	};
-};
-
+/*
+--------------------------------------------------------------------------------
+This source file is part of Hydrax.
+Visit ---
+
+Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
+                                           <xavyiy@gmail.com>
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+--------------------------------------------------------------------------------
+*/
+
+#ifndef _Hydrax_CfgFileManager_H_
+#define _Hydrax_CfgFileManager_H_
+
+#include "Prerequisites.h"
+
+#include "Help.h"
+
+namespace Hydrax
+{
+	class Hydrax;
+
+	/** Config file manager.
+	    Class to load/save all Hydrax options from/to a config file
+	 */
+	class DllExport CfgFileManager
+	{
+	public:
+		/** Constructor
+		    @param h Hydrax parent pointer
+		 */
+		CfgFileManager(Hydrax *h);
+
+		/** Destructor
+		 */
+        ~CfgFileManager();
+
+		/** Load hydrax cfg file
+		    @param File File name
+			@return false if an error has been ocurred(Check the log file in this case).
+		 */
+		const bool load(const Ogre::String& File) const;
+
+		/** Save current hydrax config to a file
+		    @param File Destination file name
+			@param Path File path
+			@return false if an error has been ocurred(Check the log file in this case).
+		 */
+		const bool save(const Ogre::String& File, const Ogre::String& Path = "") const;
+
+		/** <int> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return int cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const int& Value);
+
+		/** <float> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return Ogre::Real cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Real& Value);
+
+		/** <bool> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return bool cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const bool& Value);
+
+		/** <vector2> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return Ogre::Vector2 cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Vector2& Value);
+
+		/** <vector3> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return Ogre::Vector3 cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const Ogre::Vector3& Value);
+
+		/** <size> Get the cfg string
+		    @param Name Parameter name
+		    @param Value Parameter value
+			@return Hydrax::Size cfg string
+		 */
+		static Ogre::String _getCfgString(const Ogre::String& Name, const Size& Value);
+
+		/** Get int value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return int value
+			@remarks if the parameter isn't found or the data type is not an int value, return 0 as default
+		 */
+		static int _getIntValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Get float value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return float value
+			@remarks if the parameter isn't found or the data type is not a float value, return 0 as default
+		 */
+		static Ogre::Real _getFloatValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Get bool value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return bool value
+			@remarks if the parameter isn't found or the data type is not a bool value, return false as default
+		 */
+		static bool _getBoolValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Get vector2 value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return vector2 value
+			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0) as default
+		 */
+		static Ogre::Vector2 _getVector2Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Get vector3 value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return vector3 value
+			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0,0) as default
+		 */
+		static Ogre::Vector3 _getVector3Value(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Get size value
+		    @param CfgFile Config file
+		    @param Name Parameter name
+			@return size value
+			@remarks if the parameter isn't found or the data type is not an int value, returns (0,0) as default
+		 */
+		static Size _getSizeValue(Ogre::ConfigFile& CfgFile, const Ogre::String Name);
+
+		/** Check is a std::vector<Ogre::String> contains a specified Ogre::String
+		    @param List String list
+			@param Find String to find
+			@return true if it's contained, false if not
+		 */
+		static bool _isStringInList(const Ogre::StringVector &List, const Ogre::String &Find);
+
+	private:
+		/** Save a string in file
+		    @param Data Data
+			@param File Destination file
+			@param Path File path
+			@return false if an error has ocurred
+		 */
+		const bool _saveToFile(const Ogre::String& Data, const Ogre::String& File, const Ogre::String& Path) const;
+
+		/** Load a cfg file in an Ogre::ConfigFile
+		    @param File File name
+			@param Result, std::pair<bool, Ogre::ConfigFile&> First: False if the file isn't in the Hydrax resource group, Second: Ogre::ConfigFile
+		 */
+		const void _loadCfgFile(const Ogre::String& File, std::pair<bool,Ogre::ConfigFile> &Result) const;
+
+		/** Get components config string
+		    @return Components cfg string
+		 */
+		const Ogre::String _getComponentsCfgString() const;
+
+		/** Load components settings
+		    @param CfgFile Config file
+		 */
+		const void _loadComponentsSettings(Ogre::ConfigFile& CfgFile) const;
+
+		/** Get rtt quality config string
+		    @return Rtt quality cfg string
+		 */
+		const Ogre::String _getRttCfgString() const;
+
+		/** Load rtt settings
+		    @param CfgFile Config file
+		 */
+		const void _loadRttSettings(Ogre::ConfigFile& CfgFile) const;
+
+		/** Get hydrax version cfg string
+		    @return Hydrax version cfg string
+		 */
+		const Ogre::String _getVersionCfgString() const;
+
+		/** Check hydrax version cfg file
+		    @param CfgFile Config file
+		    @return true if it's the same version, false if not.
+		 */
+		const bool _checkVersion(Ogre::ConfigFile& CfgFile) const;
+		    
+		/// Hydrax parent pointer
+		Hydrax* mHydrax;
+	};
+};
+
 #endif

File IbexMac/Dependencies/Hydrax/DecalsManager.cpp

View file
  • Ignore whitespace
-/*
---------------------------------------------------------------------------------
-This source file is part of Hydrax.
-Visit ---
-
-Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
-                                           <xavyiy@gmail.com>
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
---------------------------------------------------------------------------------
-*/
-
-#include "DecalsManager.h"
-
-#include "Hydrax.h"
-
-namespace Hydrax
-{
-	Decal::Decal(Hydrax *h, const Ogre::String &TextureName, const int& Id)
-		: mHydrax(h)
-		, mTextureName(TextureName)
-		, mId(Id)
-		, mRegisteredPass(0)
-		, mPosition(Ogre::Vector2(0,0))
-		, mSize(Ogre::Vector2(1,1))
-		, mOrientation(Ogre::Radian(0))
-		, mTransparency(1)
-		, mVisible(true)
-	{
-		mProjector = new Ogre::Frustum();
-		mProjector->setProjectionType(Ogre::PT_ORTHOGRAPHIC); 
-		
-		mSceneNode = mHydrax->getSceneManager()->getRootSceneNode()->createChildSceneNode();
-        mSceneNode->attachObject(mProjector);
-		mSceneNode->setPosition(Ogre::Vector3(0,0,0));
-        mSceneNode->setOrientation(Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3::NEGATIVE_UNIT_X)); 
-
-		setPosition(mPosition);
-		setSize(mSize);
-		setOrientation(mOrientation);
-	}
-
-	Decal::~Decal()
-	{
-		unregister();
-	
-		mSceneNode->getParentSceneNode()->removeAndDestroyChild(mSceneNode->getName());
-
-		delete mProjector;
-	}
-
-	void Decal::registerPass(Ogre::Pass* _Pass)
-	{
-		unregister();
-
-		_Pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
-		_Pass->setCullingMode(Ogre::CULL_NONE);
-        _Pass->setDepthBias(1,1);
-        _Pass->setLightingEnabled(false);
-		_Pass->setDepthWriteEnabled(false);
-
-		Ogre::TextureUnitState *DecalTexture = _Pass->createTextureUnitState(mTextureName);
-        DecalTexture->setProjectiveTexturing(true, mProjector);
-		DecalTexture->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
-		DecalTexture->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
-		DecalTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, mTransparency); 
-
-		mRegisteredPass = _Pass;
-	}
-
-	void Decal::unregister()
-	{
-		if (mRegisteredPass)
-		{
-			mRegisteredPass->getParent()->removePass(mRegisteredPass->getIndex());
-			mRegisteredPass = static_cast<Ogre::Pass*>(NULL);
-		}
-	}
-
-	void Decal::setPosition(const Ogre::Vector2& Position)
-	{
-		mPosition = Position;
-
-		mSceneNode->setPosition(Position.x, 0, Position.y);
-	}
-
-	void Decal::setSize(const Ogre::Vector2& Size)
-	{
-		mSize = Size;
-
-		// This method is only available in the CVS HEAD,
-		// if you have problems compiling, just comment the
-		// following line:
-		mProjector->setOrthoWindow(Size.x, Size.y);
-	}
-
-	void Decal::setOrientation(const Ogre::Radian& Orientation)
-	{
-		mSceneNode->rotate(Ogre::Vector3::UNIT_Z, -mOrientation + Orientation);
-
-		mOrientation = Orientation;
-	}
-
-	void Decal::setTransparency(const Ogre::Real& Transparency)
-	{
-		mTransparency = Transparency;
-
-		if (mRegisteredPass)
-		{
-			mRegisteredPass->getTextureUnitState(0)
-				->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, mTransparency);
-		}
-	}
-
-	void Decal::setVisible(const bool& Visible)
-	{
-		mVisible = Visible;
-
-		unregister();
-
-		mHydrax->getDecalsManager()->_forceToUpdate();
-	}
-
-	// --------------------------------------------------------------------
-
-	DecalsManager::DecalsManager(Hydrax *h)
-		: mHydrax(h)
-		, mNextId(0)
-		, mLastUnderwater(false)
-		, mWaterStrength(5)
-		, mForceToUpdate(false)
-	{
-	}
-
-	DecalsManager::~DecalsManager()
-	{
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-			delete (*DecalIt);
-		}
-
-		mDecals.clear();
-	}
-
-	void DecalsManager::update()
-	{
-		if (mHydrax->getCamera()->getDerivedPosition()    == mLastPosition &&
-			mHydrax->getCamera()->getDerivedOrientation() == mLastOrientation && 
-			!mForceToUpdate)
-		{
-			return;
-		}
-
-		if (mForceToUpdate)
-		{
-			mForceToUpdate = false;
-		}
-
-		Ogre::Vector2 DPos;
-		Ogre::Real    HHeight = mHydrax->getPosition().y;
-		Ogre::Vector2 DSize;
-		Ogre::AxisAlignedBox DecalBox;
-
-		if (mLastUnderwater != mHydrax->_isCurrentFrameUnderwater())
-		{
-			for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-            {
-				if (!(*DecalIt)->isVisible())
-				{
-					continue;
-				}
-
-				if ((*DecalIt)->getRegisteredPass())
-				{
-					(*DecalIt)->unregister();
-
-					if (!mHydrax->_isCurrentFrameUnderwater())
-					{
-					    (*DecalIt)->registerPass(
-				             mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_WATER)->
-				                 getTechnique(0)->createPass());
-					}
-					else
-					{
-						(*DecalIt)->registerPass(
-				             mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_UNDERWATER)->
-				                 getTechnique(0)->createPass());
-					}
-				}
-
-			}
-		}
-
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-			if (!(*DecalIt)->isVisible())
-			{
-				continue;
-			}
-
-			DPos = (*DecalIt)->getPosition();
-			DSize = (*DecalIt)->getSize()/2;
-
-			DecalBox = Ogre::AxisAlignedBox(DPos.x - DSize.x,  HHeight - mWaterStrength, DPos.y - DSize.y,
-				                            DPos.x + DSize.x,  HHeight + mWaterStrength, DPos.y + DSize.y);
-
-			if (mHydrax->getCamera()->isVisible(DecalBox))
-			{
-				if (!(*DecalIt)->getRegisteredPass())
-				{
-					if (!mHydrax->_isCurrentFrameUnderwater())
-					{
-					    (*DecalIt)->registerPass(
-				             mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_WATER)->
-				                 getTechnique(0)->createPass());
-					}
-					else
-					{
-						(*DecalIt)->registerPass(
-				             mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_UNDERWATER)->
-				                 getTechnique(0)->createPass());
-					}
-				}
-			}
-			else
-			{
-				(*DecalIt)->unregister();
-			}
-		}
-		
-		mLastPosition    = mHydrax->getCamera()->getDerivedPosition();
-		mLastOrientation = mHydrax->getCamera()->getDerivedOrientation();
-		mLastUnderwater  = mHydrax->_isCurrentFrameUnderwater();
-	}
-
-	Decal* DecalsManager::add(const Ogre::String& TextureName)
-	{
-		Decal* NewDecal = new Decal(mHydrax, TextureName, mNextId);
-
-		mDecals.push_back(NewDecal);
-
-		if (mHydrax->getMaterialManager()->isCreated())
-		{
-			NewDecal->registerPass(
-				mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_WATER)->
-				     getTechnique(0)->createPass());
-		}
-
-		mNextId++;
-
-		return NewDecal;
-	}
-
-	Decal* DecalsManager::get(const int& Id)
-	{
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-            if((*DecalIt)->getId() == Id)
-            {
-				return (*DecalIt);
-            }
-		}
-
-		return static_cast<Decal*>(NULL);
-	}
-
-	void DecalsManager::remove(const int& Id)
-	{
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-            if((*DecalIt)->getId() == Id)
-            {
-				delete (*DecalIt);
-				mDecals.erase(DecalIt);
-
-				return;
-            }
-		}
-	}
-
-	void DecalsManager::removeAll()
-	{
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-			delete (*DecalIt);
-		}
-
-		mDecals.clear();
-
-		mNextId = 0;
-	}
-
-	void DecalsManager::registerAll()
-	{
-		for(DecalIt = mDecals.begin(); DecalIt != mDecals.end(); DecalIt++)
-        {
-			(*DecalIt)->unregister();
-
-			if (!mHydrax->_isCurrentFrameUnderwater())
-			{
-				(*DecalIt)->registerPass(
-					mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_WATER)->
-					   getTechnique(0)->createPass());
-			}
-			else
-			{
-				(*DecalIt)->registerPass(
-					mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_UNDERWATER)->
-					   getTechnique(0)->createPass());
-			}
-		}
-	}
-}
+/*
+--------------------------------------------------------------------------------
+This source file is part of Hydrax.
+Visit ---
+
+Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
+                                           <xavyiy@gmail.com>
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+--------------------------------------------------------------------------------
+*/
+
+#include <DecalsManager.h>
+
+#include <Hydrax.h>
+
+namespace Hydrax
+{
+	Decal::Decal(Hydrax *h, const Ogre::String &TextureName, const int& Id)
+		: mHydrax(h)
+		, mTextureName(TextureName)
+		, mId(Id)
+		, mRegisteredPass(0)
+		, mPosition(Ogre::Vector2(0,0))
+		, mSize(Ogre::Vector2(1,1))
+		, mOrientation(Ogre::Radian(0))
+		, mTransparency(1)
+		, mVisible(true)
+	{
+		mProjector = new Ogre::Frustum();
+		mProjector->setProjectionType(Ogre::PT_ORTHOGRAPHIC); 
+		
+		mSceneNode = mHydrax->getSceneManager()->getRootSceneNode()->createChildSceneNode();
+        mSceneNode->attachObject(mProjector);
+		mSceneNode->setPosition(Ogre::Vector3(0,0,0));
+        mSceneNode->setOrientation(Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3::NEGATIVE_UNIT_X)); 
+
+		setPosition(mPosition);
+		setSize(mSize);
+		setOrientation(mOrientation);