|
RigsofRods
Soft-body Physics Simulation
|
Go to the documentation of this file.
41 std::pair<bool, Ogre::ConfigFile> CfgFileResult;
44 if (!CfgFileResult.first)
49 Ogre::ConfigFile &CfgFile = CfgFileResult.second;
88 "#Hydrax cfg file.\n\n";
90 Data +=
"#Hydrax version field\n";
93 Data +=
"#Main options field\n";
96 Data +=
"#Shader mode: 0=HLSL, 1=CG, 2=GLSL\n";
103 Data +=
"#Components field\n";
106 Data +=
"#Rtt quality field(0x0 = Auto)\n";
124 FILE *DestinationFile = fopen((Path+
"/"+File).c_str(),
"w");
126 if (!DestinationFile)
131 fprintf(DestinationFile,
"%s", Data.c_str());
132 fclose(DestinationFile);
134 HydraxLOG(File +
" saved in " + Path +
" .");
143 Result.second.load(Ogre::ResourceGroupManager::getSingleton().openResource(File, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME));
148 HydraxLOG(
"CfgFileManager::_getCfgFile(...): " + File +
" not found in any resource group.");
149 Result.first =
false;
157 return "<int>" + Name +
"=" + Ogre::StringConverter::toString(Value) +
"\n";
162 return "<float>" + Name +
"=" + Ogre::StringConverter::toString(Value) +
"\n";
167 return "<bool>" + Name +
"=" + Ogre::StringConverter::toString(Value) +
"\n";
172 return "<vector2>" + Name +
"=" + Ogre::StringConverter::toString(Value.x) +
"x" + Ogre::StringConverter::toString(Value.y) +
"\n";
177 return "<vector3>" + Name +
"=" + Ogre::StringConverter::toString(Value.x) +
"x" + Ogre::StringConverter::toString(Value.y) +
"x" + Ogre::StringConverter::toString(Value.z) +
"\n";
182 return "<size>" + Name +
"=" + Ogre::StringConverter::toString(Value.
Width) +
"x" + Ogre::StringConverter::toString(Value.
Height) +
"\n";
187 Ogre::String Cmpnts =
"Components=";
189 std::pair<bool, Ogre::String> Cmp[8] = {
199 for (
int k = 0; k < 8; k++)
203 Cmpnts += Cmp[k].second;
207 for (
int u = k+1; u < 8; u++)
229 Cmpnts +=
"#Sun parameters\n";
238 Cmpnts +=
"#Foam parameters\n";
247 Cmpnts +=
"#Depth parameters\n";
253 Cmpnts +=
"#Smooth transitions parameters\n";
259 Cmpnts +=
"#Caustics parameters\n";
267 Cmpnts +=
"#God rays parameters\n";
281 for (
unsigned int k = 0; k < List.size(); k++)
294 Ogre::StringVector Cmpnts = Ogre::StringUtil::split(CfgFile.getSetting(
"Components"),
"|");
334 ComponentsToLoad[0] | ComponentsToLoad[1] | ComponentsToLoad[2] | ComponentsToLoad[3] |
335 ComponentsToLoad[4] | ComponentsToLoad[5] | ComponentsToLoad[6] | ComponentsToLoad[7]));
403 return "HydraxVersion=" +
416 if(CfgFile.getSetting(
"HydraxVersion") != (
424 HydraxLOG(
"Config file version doesn't correspond with Hydrax version.");
434 Ogre::String Value = CfgFile.getSetting(
"<int>" + Name);
442 return Ogre::StringConverter::parseInt(Value);
448 Ogre::String Value = CfgFile.getSetting(
"<float>" + Name);
456 return Ogre::StringConverter::parseReal(Value);
462 Ogre::String Value = CfgFile.getSetting(
"<bool>" + Name);
470 return Ogre::StringConverter::parseBool(Value);
476 Ogre::String Value = CfgFile.getSetting(
"<vector2>" + Name);
480 return Ogre::Vector2(0,0);
484 return Ogre::Vector2(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value,
"x")[0]),
485 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value,
"x")[1]));
491 Ogre::String Value = CfgFile.getSetting(
"<vector3>" + Name);
495 return Ogre::Vector3(0,0,0);
499 return Ogre::Vector3(Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value,
"x")[0]),
500 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value,
"x")[1]),
501 Ogre::StringConverter::parseReal(Ogre::StringUtil::split(Value,
"x")[2]));
507 Ogre::String Value = CfgFile.getSetting(
"<size>" + Name);
515 return Size(Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value,
"x")[0]),
516 Ogre::StringConverter::parseInt(Ogre::StringUtil::split(Value,
"x")[1]));
const Ogre::Real & getRaysSize() const
Get god rays size.
const Ogre::Real & getSimulationSpeed() const
Get god rays simulation speed.
GodRaysManager * getGodRaysManager()
Get Hydrax::GodRaysManager.
void setSunColor(const Ogre::Vector3 &SunColor)
Set sun color.
const void _loadCfgFile(const Ogre::String &File, std::pair< bool, Ogre::ConfigFile > &Result) const
Load a cfg file in an Ogre::ConfigFile.
const Ogre::Real & getSunStrength() const
Get water strength.
const bool & areObjectsIntersectionsEnabled() const
Are rays objects intersections enabled?
const Ogre::Vector3 & getWaterColor() const
Get water color.
virtual void saveCfg(Ogre::String &Data)
Save config.
void setDistLimit(const Ogre::Real &DistLimit)
Set distance limit underwater (occlusion)
@ HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS
Underwater reflections and god rays need underwater component.
const Ogre::String _getRttCfgString() const
Get rtt quality config string.
const Ogre::Vector3 & getPosition() const
Get water position.
const Ogre::Real & getPlanesError() const
Get current clip planes error.
const Ogre::Real & getFoamTransparency() const
Get foam transparency.
const bool _checkVersion(Ogre::ConfigFile &CfgFile) const
Check hydrax version cfg file.
void setFoamTransparency(const Ogre::Real &FoamTransparency)
Set foam transparency.
const Ogre::Vector3 & getSunColor() const
Get sun color.
void setSunPosition(const Ogre::Vector3 &SunPosition)
Set sun position.
Struct wich contains an especific width and height value.
const bool load(const Ogre::String &File) const
Load hydrax cfg file.
const void _loadRttSettings(Ogre::ConfigFile &CfgFile) const
Load rtt settings.
const bool save(const Ogre::String &File, const Ogre::String &Path="") const
Save current hydrax config to a file.
const Ogre::Real & getGlobalTransparency() const
Get global transparency.
const Ogre::Real & getFoamScale() const
Get foam scale.
static Size _getSizeValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get size value.
void setGodRaysExposure(const Ogre::Vector3 &GodRaysExposure)
Set god rays exposure.
virtual bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
void setObjectIntersectionsEnabled(const bool &Enable)
Set objects intersections enabled.
const Ogre::Real & getCausticsEnd() const
Get caustics end.
virtual void saveCfg(Ogre::String &Data)
Save config.
void setCausticsScale(const Ogre::Real &CausticsScale)
Set caustics scale.
void setSunStrength(const Ogre::Real &SunStrength)
Set sun strength.
void setFoamScale(const Ogre::Real &FoamScale)
Set foam scale.
static bool _getBoolValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get bool value.
Noise::Noise * getNoise()
Get the Hydrax::Noise module pointer.
const MaterialManager::ShaderMode & getShaderMode() const
Get current shader mode.
RttManager * getRttManager()
Get Hydrax::RttManager.
static Ogre::Vector3 _getVector3Value(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get vector3 value.
const Ogre::Real & getDepthLimit() const
Get depth limit.
void setSmoothPower(const Ogre::Real &SmoothPower)
Set smooth power.
const Ogre::String _getComponentsCfgString() const
Get components config string.
Hydrax * mHydrax
Hydrax parent pointer.
const Ogre::Real & getNormalDistortion() const
Get normal distortion.
void setNormalDistortion(const Ogre::Real &NormalDistortion)
Set normal distortion.
Module::Module * getModule()
Get our Hydrax::Module::Module.
CfgFileManager(Hydrax *h)
bool isComponent(const HydraxComponent &Component)
Returns if the especified component is active.
const Ogre::Real & getGodRaysIntensity() const
Get God rays intensity.
void setGlobalTransparency(const Ogre::Real &GlobalTransparencyDistance)
void setCausticsEnd(const Ogre::Real &CausticsEnd)
Set caustics end.
const Ogre::Real & getFoamStart() const
Get foam start.
const void _loadComponentsSettings(Ogre::ConfigFile &CfgFile) const
Load components settings.
void setSunArea(const Ogre::Real &SunArea)
Set sun area.
void setPosition(const Ogre::Vector3 &Position)
Set water position.
void SetSimulationSpeed(const Ogre::Real &Speed)
Set god rays simulation speed.
const Ogre::Real & getSunArea() const
Get sun area.
static Ogre::String _getCfgString(const Ogre::String &Name, const int &Value)
const bool _saveToFile(const Ogre::String &Data, const Ogre::String &File, const Ogre::String &Path) const
Save a string in file.
const int & getNumberOfRays() const
Get number of god rays.
virtual bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
const Ogre::Real & getFoamMaxDistance() const
Get foam max distance.
const Ogre::String _getVersionCfgString() const
Get hydrax version cfg string.
void setNumberOfRays(const int &NumberOfRays)
Set the number of god rays.
const Ogre::Vector3 & getSunPosition() const
Get sun position.
@ HYDRAX_COMPONENT_SMOOTH
Smooth transitions and caustics components need depth component.
const Ogre::Real & getCausticsPower() const
Get caustics power.
const Ogre::Vector3 & getGodRaysExposure() const
Get God rays exposure factors.
void setFullReflectionDistance(const Ogre::Real &FullReflectionDistance)
Set full reflection distance.
HydraxComponent
Hydrax flags to select components wich we want to use.
void setFoamMaxDistance(const Ogre::Real &FoamMaxDistance)
Set foam max distance.
@ HYDRAX_COMPONENT_UNDERWATER
void setTextureSize(const RttType &Rtt, const Size &S)
Set Rtt texture size.
@ HYDRAX_COMPONENT_CAUSTICS
@ HYDRAX_COMPONENT_UNDERWATER_GODRAYS
#define HYDRAX_VERSION_MINOR
const Ogre::Real & getFullReflectionDistance() const
Get full reflection distance.
static int _getIntValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get int value.
#define HYDRAX_VERSION_MAJOR
Include external headers.
const Ogre::Real & getSmoothPower() const
Get smooth power.
static Ogre::Vector2 _getVector2Value(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get vector2 value.
#define HYDRAX_VERSION_PATCH
void setShaderMode(const MaterialManager::ShaderMode &ShaderMode)
Set shader mode.
void setPlanesError(const Ogre::Real &PlanesError)
Set clip planes error.
void setFoamStart(const Ogre::Real &FoamStart)
Set foam start.
static Ogre::Real _getFloatValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get float value.
static bool _isStringInList(const Ogre::StringVector &List, const Ogre::String &Find)
Check is a std::vector<Ogre::String> contains a specified Ogre::String.
const Ogre::Real & getCausticsScale() const
Get caustics scale.
void setComponents(const HydraxComponent &Components)
Set Hydrax components.
const Size & getTextureSize(const RttType &Rtt) const
void setGodRaysIntensity(const Ogre::Real &GodRaysIntensity)
Set god rays intensity.
void setDepthLimit(const Ogre::Real &DepthLimit)
Set depth limit.
void setWaterColor(const Ogre::Vector3 &WaterColor)
void setRaysSize(const Ogre::Real &Size)
Set god rays size.
void setCausticsPower(const Ogre::Real &CausticsPower)
Set caustics power.