2012-02-21 20:22:46 +01:00
|
|
|
#ifndef GAME_MWWORLD_WEATHER_H
|
|
|
|
#define GAME_MWWORLD_WEATHER_H
|
|
|
|
|
2014-03-21 01:33:11 -05:00
|
|
|
#include <stdint.h>
|
2014-03-20 01:25:52 -05:00
|
|
|
#include <string>
|
2015-06-03 23:04:35 +02:00
|
|
|
#include <map>
|
2014-03-20 01:25:52 -05:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
#include <osg/Vec4f>
|
2013-03-15 10:26:04 +01:00
|
|
|
|
2014-12-01 20:31:33 +01:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
|
2015-08-04 21:07:42 -05:00
|
|
|
#include "../mwrender/sky.hpp"
|
|
|
|
|
2013-06-19 16:18:43 +02:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct Region;
|
2014-03-20 01:25:52 -05:00
|
|
|
class ESMWriter;
|
|
|
|
class ESMReader;
|
2013-06-19 16:18:43 +02:00
|
|
|
}
|
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
class RenderingManager;
|
|
|
|
}
|
|
|
|
|
2014-04-28 11:29:57 +02:00
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
class Listener;
|
|
|
|
}
|
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2013-03-15 10:26:04 +01:00
|
|
|
class Fallback;
|
|
|
|
|
2012-02-22 20:39:14 +01:00
|
|
|
/// Defines a single weather setting (according to INI)
|
2012-02-21 20:22:46 +01:00
|
|
|
struct Weather
|
|
|
|
{
|
2014-03-20 01:25:52 -05:00
|
|
|
std::string mCloudTexture;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
|
|
|
// Sky (atmosphere) colors
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mSkySunriseColor,
|
2012-02-22 20:39:14 +01:00
|
|
|
mSkyDayColor,
|
|
|
|
mSkySunsetColor,
|
|
|
|
mSkyNightColor;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Fog colors
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mFogSunriseColor,
|
2012-02-22 20:39:14 +01:00
|
|
|
mFogDayColor,
|
|
|
|
mFogSunsetColor,
|
|
|
|
mFogNightColor;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Ambient lighting colors
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mAmbientSunriseColor,
|
2012-02-22 20:39:14 +01:00
|
|
|
mAmbientDayColor,
|
|
|
|
mAmbientSunsetColor,
|
|
|
|
mAmbientNightColor;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Sun (directional) lighting colors
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mSunSunriseColor,
|
2012-02-22 20:39:14 +01:00
|
|
|
mSunDayColor,
|
|
|
|
mSunSunsetColor,
|
|
|
|
mSunNightColor;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Fog depth/density
|
2012-02-22 20:39:14 +01:00
|
|
|
float mLandFogDayDepth,
|
|
|
|
mLandFogNightDepth;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Color modulation for the sun itself during sunset (not completely sure)
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mSunDiscSunsetColor;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 21:06:03 +01:00
|
|
|
// Duration of weather transition (in days)
|
2012-02-21 20:22:46 +01:00
|
|
|
float mTransitionDelta;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-06-24 18:37:38 +02:00
|
|
|
// Used by scripts to animate signs, etc based on the wind (GetWindSpeed)
|
2012-02-21 20:22:46 +01:00
|
|
|
float mWindSpeed;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Cloud animation speed multiplier
|
|
|
|
float mCloudSpeed;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 21:06:03 +01:00
|
|
|
// Multiplier for clouds transparency
|
2012-02-21 20:22:46 +01:00
|
|
|
float mCloudsMaximumPercent;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Value between 0 and 1, defines the strength of the sun glare effect
|
|
|
|
float mGlareView;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
// Sound effect
|
|
|
|
// This is used for Blight, Ashstorm and Blizzard (Bloodmoon)
|
2014-03-20 01:25:52 -05:00
|
|
|
std::string mAmbientLoopSoundID;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-06-26 20:26:46 +02:00
|
|
|
// Is this an ash storm / blight storm? If so, the following will happen:
|
|
|
|
// - The particles and clouds will be oriented so they appear to come from the Red Mountain.
|
2014-06-24 18:37:38 +02:00
|
|
|
// - Characters will animate their hand to protect eyes from the storm when looking in its direction (idlestorm animation)
|
2014-06-26 20:26:46 +02:00
|
|
|
// - Slower movement when walking against the storm (fStromWalkMult)
|
2014-06-24 18:37:38 +02:00
|
|
|
bool mIsStorm;
|
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
// How fast does rain travel down?
|
|
|
|
// In Morrowind.ini this is set globally, but we may want to change it per weather later.
|
|
|
|
float mRainSpeed;
|
|
|
|
|
|
|
|
// How often does a new rain mesh spawn?
|
|
|
|
float mRainFrequency;
|
|
|
|
|
2014-06-24 15:00:15 +02:00
|
|
|
std::string mParticleEffect;
|
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
std::string mRainEffect;
|
|
|
|
|
2014-06-24 15:00:15 +02:00
|
|
|
// Note: For Weather Blight, there is a "Disease Chance" (=0.1) setting. But according to MWSFD this feature
|
|
|
|
// is broken in the vanilla game and was disabled.
|
2015-08-04 21:07:42 -05:00
|
|
|
|
|
|
|
// Some weather patterns will obstruct the moons, sun, and stars.
|
|
|
|
bool mObstructsCelestialBodies;
|
2012-02-21 20:22:46 +01:00
|
|
|
};
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2015-07-29 23:57:45 -05:00
|
|
|
class MoonModel
|
|
|
|
{
|
|
|
|
public:
|
2015-07-30 14:00:08 -05:00
|
|
|
MoonModel(const std::string& name, const MWWorld::Fallback& fallback);
|
2015-07-29 23:57:45 -05:00
|
|
|
|
2015-07-30 14:00:08 -05:00
|
|
|
MWRender::MoonState calculateState(unsigned int daysPassed, float gameHour) const;
|
2015-07-29 23:57:45 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
float mFadeInStart;
|
|
|
|
float mFadeInFinish;
|
|
|
|
float mFadeOutStart;
|
|
|
|
float mFadeOutFinish;
|
|
|
|
float mAxisOffset;
|
|
|
|
float mSpeed;
|
|
|
|
float mDailyIncrement;
|
|
|
|
float mFadeStartAngle;
|
|
|
|
float mFadeEndAngle;
|
|
|
|
float mMoonShadowEarlyFadeAngle;
|
|
|
|
|
2015-07-30 14:00:08 -05:00
|
|
|
float angle(unsigned int daysPassed, float gameHour) const;
|
|
|
|
float moonRiseHour(unsigned int daysPassed) const;
|
|
|
|
float rotation(float hours) const;
|
2015-08-04 21:07:42 -05:00
|
|
|
unsigned int phase(unsigned int daysPassed, float gameHour) const;
|
2015-07-30 14:00:08 -05:00
|
|
|
float shadowBlend(float angle) const;
|
|
|
|
float hourlyAlpha(float gameHour) const;
|
|
|
|
float earlyMoonShadowAlpha(float angle) const;
|
2015-07-29 23:57:45 -05:00
|
|
|
};
|
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
///
|
|
|
|
/// Interface for weather settings
|
|
|
|
///
|
|
|
|
class WeatherManager
|
|
|
|
{
|
|
|
|
public:
|
2015-07-10 02:34:00 +02:00
|
|
|
// Have to pass fallback and Store, can't use singleton since World isn't fully constructed yet at the time
|
|
|
|
WeatherManager(MWRender::RenderingManager*, MWWorld::Fallback* fallback, MWWorld::ESMStore* store);
|
2013-08-29 15:15:40 +02:00
|
|
|
~WeatherManager();
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
/**
|
2012-02-26 11:51:02 +01:00
|
|
|
* Change the weather in the specified region
|
|
|
|
* @param region that should be changed
|
|
|
|
* @param ID of the weather setting to shift to
|
2012-02-21 20:22:46 +01:00
|
|
|
*/
|
2013-06-20 21:44:28 +02:00
|
|
|
void changeWeather(const std::string& region, const unsigned int id);
|
2013-12-29 12:47:44 +01:00
|
|
|
void switchToNextWeather(bool instantly = true);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
/**
|
|
|
|
* Per-frame update
|
|
|
|
* @param duration
|
2014-10-10 23:29:51 +13:00
|
|
|
* @param paused
|
2012-02-21 20:22:46 +01:00
|
|
|
*/
|
2014-10-10 23:29:51 +13:00
|
|
|
void update(float duration, bool paused = false);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-12-01 20:31:33 +01:00
|
|
|
void stopSounds();
|
2013-06-19 16:18:43 +02:00
|
|
|
|
2012-02-22 20:12:08 +01:00
|
|
|
void setHour(const float hour);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-05-01 11:42:24 +02:00
|
|
|
float getWindSpeed() const;
|
|
|
|
|
2014-06-24 18:37:38 +02:00
|
|
|
/// Are we in an ash or blight storm?
|
|
|
|
bool isInStorm() const;
|
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
osg::Vec3f getStormDirection() const;
|
2014-06-24 18:37:38 +02:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
void advanceTime(double hours);
|
2012-09-25 21:28:25 +02:00
|
|
|
|
2012-02-25 21:34:38 +01:00
|
|
|
unsigned int getWeatherID() const;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-07-27 07:10:18 -07:00
|
|
|
void modRegion(const std::string ®ionid, const std::vector<char> &chances);
|
|
|
|
|
2013-12-30 17:53:02 +01:00
|
|
|
/// @see World::isDark
|
|
|
|
bool isDark() const;
|
2013-12-10 23:48:49 +01:00
|
|
|
|
2014-04-28 11:29:57 +02:00
|
|
|
void write(ESM::ESMWriter& writer, Loading::Listener& progress);
|
2014-03-20 01:25:52 -05:00
|
|
|
|
2015-01-22 19:04:59 +01:00
|
|
|
bool readRecord(ESM::ESMReader& reader, uint32_t type);
|
2014-03-20 01:25:52 -05:00
|
|
|
|
2015-01-24 16:26:43 +01:00
|
|
|
void clear();
|
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
private:
|
2012-02-22 20:12:08 +01:00
|
|
|
float mHour;
|
2013-05-01 11:42:24 +02:00
|
|
|
float mWindSpeed;
|
2014-06-25 18:20:21 +02:00
|
|
|
bool mIsStorm;
|
2015-05-12 03:02:15 +02:00
|
|
|
osg::Vec3f mStormDirection;
|
2014-06-26 19:01:49 +02:00
|
|
|
|
2014-12-01 20:31:33 +01:00
|
|
|
MWBase::SoundPtr mAmbientSound;
|
|
|
|
std::string mPlayingSoundID;
|
|
|
|
|
2013-03-15 10:17:30 +01:00
|
|
|
MWWorld::Fallback* mFallback;
|
2015-07-10 02:34:00 +02:00
|
|
|
MWWorld::ESMStore* mStore;
|
2013-06-20 21:44:28 +02:00
|
|
|
void setFallbackWeather(Weather& weather,const std::string& name);
|
2012-02-21 20:22:46 +01:00
|
|
|
MWRender::RenderingManager* mRendering;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-03-20 01:25:52 -05:00
|
|
|
std::map<std::string, Weather> mWeatherSettings;
|
2012-03-09 18:30:03 +01:00
|
|
|
|
2013-06-20 21:44:28 +02:00
|
|
|
std::map<std::string, std::string> mRegionOverrides;
|
2012-03-09 18:30:03 +01:00
|
|
|
|
2014-03-20 01:25:52 -05:00
|
|
|
std::string mCurrentWeather;
|
|
|
|
std::string mNextWeather;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 23:41:02 +01:00
|
|
|
std::string mCurrentRegion;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 23:41:02 +01:00
|
|
|
bool mFirstUpdate;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 23:41:02 +01:00
|
|
|
float mRemainingTransitionTime;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-02-25 13:46:17 +01:00
|
|
|
float mThunderFlash;
|
|
|
|
float mThunderChance;
|
|
|
|
float mThunderChanceNeeded;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-09-25 21:28:25 +02:00
|
|
|
double mTimePassed; // time passed since last update
|
|
|
|
|
2013-06-19 06:50:36 +02:00
|
|
|
void transition(const float factor);
|
2014-03-20 01:25:52 -05:00
|
|
|
void setResult(const std::string& weatherType);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-03-20 01:25:52 -05:00
|
|
|
void setWeather(const std::string& weatherType, bool instant=false);
|
|
|
|
std::string nextWeather(const ESM::Region* region) const;
|
2015-08-04 21:07:42 -05:00
|
|
|
MWRender::WeatherResult mResult;
|
2013-06-20 21:44:28 +02:00
|
|
|
|
2013-07-27 07:10:18 -07:00
|
|
|
typedef std::map<std::string,std::vector<char> > RegionModMap;
|
|
|
|
RegionModMap mRegionMods;
|
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
float mRainSpeed;
|
2013-03-10 00:24:14 +01:00
|
|
|
float mSunriseTime;
|
|
|
|
float mSunsetTime;
|
|
|
|
float mSunriseDuration;
|
|
|
|
float mSunsetDuration;
|
|
|
|
float mWeatherUpdateTime;
|
2013-03-20 01:20:56 +01:00
|
|
|
float mHoursBetweenWeatherChanges;
|
2013-03-10 00:24:14 +01:00
|
|
|
float mThunderFrequency;
|
|
|
|
float mThunderThreshold;
|
|
|
|
float mThunderSoundDelay;
|
2013-05-07 10:27:37 +02:00
|
|
|
float mNightStart;
|
|
|
|
float mNightEnd;
|
|
|
|
float mDayStart;
|
|
|
|
float mDayEnd;
|
2013-03-10 00:24:14 +01:00
|
|
|
std::string mThunderSoundID0;
|
|
|
|
std::string mThunderSoundID1;
|
|
|
|
std::string mThunderSoundID2;
|
|
|
|
std::string mThunderSoundID3;
|
2015-07-29 23:57:45 -05:00
|
|
|
MoonModel mMasser;
|
|
|
|
MoonModel mSecunda;
|
2012-02-21 20:22:46 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // GAME_MWWORLD_WEATHER_H
|