From c1fb5ce769513db57f726e3b66441703fc00b47f Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 21 Feb 2012 20:22:46 +0100 Subject: [PATCH] added (incomplete) WeatherManager, created by World --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwworld/weather.hpp | 99 +++++++++++++++++++++++++++++++++ apps/openmw/mwworld/world.cpp | 5 ++ apps/openmw/mwworld/world.hpp | 3 + 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwworld/weather.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 57fc27e96..bf4d618f1 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -44,7 +44,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata world physicssystem scene environment globals class action nullaction actionteleport containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors - cells localscripts customdata + cells localscripts customdata weather ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp new file mode 100644 index 000000000..a91ed8b8e --- /dev/null +++ b/apps/openmw/mwworld/weather.hpp @@ -0,0 +1,99 @@ +#ifndef GAME_MWWORLD_WEATHER_H +#define GAME_MWWORLD_WEATHER_H + +#include +#include + +namespace MWRender +{ + class RenderingManager; +} + +namespace MWWorld +{ + /// Defines a single weather setting + struct Weather + { + Ogre::String mCloudTexture; + + // Sky (atmosphere) colors + Ogre::ColourValue mSkySunriseColor; + Ogre::ColourValue mSkyDayColor; + Ogre::ColourValue mSkySunsetColor; + Ogre::ColourValue mSkyNightColor; + + // Fog colors + Ogre::ColourValue mFogSunriseColor; + Ogre::ColourValue mFogDayColor; + Ogre::ColourValue mFogSunsetColor; + Ogre::ColourValue mFogNightColor; + + // Ambient lighting colors + Ogre::ColourValue mAmbientSunriseColor; + Ogre::ColourValue mAmbientDayColor; + Ogre::ColourValue mAmbientSunsetColor; + Ogre::ColourValue mAmbientNightColor; + + // Sun (directional) lighting colors + Ogre::ColourValue mSunSunriseColor; + Ogre::ColourValue mSunDayColor; + Ogre::ColourValue mSunSunsetColor; + Ogre::ColourValue mSunNightColor; + + // Fog depth/density + float mLandFogDayDepth; + float mLandFogNightDepth; + + // Color modulation for the sun itself during sunset (not completely sure) + Ogre::ColourValue mSunDiscSunsetColour; + + // Duration of weather transition + // the INI value is 0.015, so I suppose this is measured in Morrowind-days? (0.015 days = 36 minutes in Morrowind) + float mTransitionDelta; + + // No idea what this one is used for? + float mWindSpeed; + + // Cloud animation speed multiplier + float mCloudSpeed; + + // Multiplier for clouds transparency? + float mCloudsMaximumPercent; + + // Value between 0 and 1, defines the strength of the sun glare effect + float mGlareView; + + // Sound effect + // This is used for Blight, Ashstorm and Blizzard (Bloodmoon) + Ogre::String mAmbientLoopSoundID; + }; + + /// + /// Interface for weather settings + /// + class WeatherManager + { + public: + WeatherManager(MWRender::RenderingManager*); + + /** + * Change the weather setting + * @param weather + * new weather setting to use + * @param instant + * if true, the weather changes instantly. if false, it slowly starts transitioning. + */ + void setWeather(const Weather& weather, bool instant=false); + + /** + * Per-frame update + * @param duration + */ + void update(float duration); + + private: + MWRender::RenderingManager* mRendering; + }; +} + +#endif // GAME_MWWORLD_WEATHER_H diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index f9e108f4c..9725b0324 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -13,10 +13,12 @@ #include "../mwsound/soundmanager.hpp" + #include "ptr.hpp" #include "environment.hpp" #include "class.hpp" #include "player.hpp" +#include "weather.hpp" #include "refdata.hpp" #include "globals.hpp" @@ -154,6 +156,8 @@ namespace MWWorld mPhysEngine = mPhysics->getEngine(); mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); + + mWeatherManager = new MWWorld::WeatherManager(); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); @@ -184,6 +188,7 @@ namespace MWWorld World::~World() { + delete mWeatherManager; delete mWorldScene; delete mGlobalVariables; delete mRendering; diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index a6e917961..1df191853 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -50,6 +50,7 @@ namespace MWRender namespace MWWorld { + class WeatherManager; class Environment; class Player; @@ -68,6 +69,8 @@ namespace MWWorld private: MWRender::RenderingManager* mRendering; + + MWWorld::WeatherManager* mWeatherManager; MWWorld::Scene *mWorldScene; MWWorld::Player *mPlayer;