forked from teamnwah/openmw-tes3coop
transition tweaks
This commit is contained in:
parent
a67cc8e73b
commit
460b584934
2 changed files with 77 additions and 87 deletions
|
@ -22,6 +22,14 @@ const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1";
|
||||||
const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2";
|
const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2";
|
||||||
const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3";
|
const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3";
|
||||||
|
|
||||||
|
const float WeatherGlobals::mWeatherUpdateTime = 20.f;
|
||||||
|
|
||||||
|
// morrowind sets these per-weather, but since they are only used by 'thunderstorm'
|
||||||
|
// weather setting anyway, we can just as well set them globally
|
||||||
|
const float WeatherGlobals::mThunderFrequency = .4;
|
||||||
|
const float WeatherGlobals::mThunderThreshold = 0.6;
|
||||||
|
const float WeatherGlobals::mThunderSoundDelay = 0.25;
|
||||||
|
|
||||||
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) :
|
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) :
|
||||||
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
|
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
|
||||||
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0)
|
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0)
|
||||||
|
@ -354,15 +362,12 @@ WeatherResult WeatherManager::getResult(const String& weather)
|
||||||
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
|
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
|
||||||
result.mSunColor = current.mSunDiscSunsetColor;
|
result.mSunColor = current.mSunDiscSunsetColor;
|
||||||
|
|
||||||
const float fade_duration = current.mTransitionDelta * 24.f;
|
result.mNight = (mHour < 6 || mHour > 19);
|
||||||
|
|
||||||
result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration);
|
|
||||||
|
|
||||||
result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
|
result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
|
||||||
|
|
||||||
// night
|
// night
|
||||||
if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
|
if (mHour <= 5.5f || mHour >= 21)
|
||||||
|| mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration))
|
|
||||||
{
|
{
|
||||||
result.mFogColor = current.mFogNightColor;
|
result.mFogColor = current.mFogNightColor;
|
||||||
result.mAmbientColor = current.mAmbientNightColor;
|
result.mAmbientColor = current.mAmbientNightColor;
|
||||||
|
@ -372,40 +377,33 @@ WeatherResult WeatherManager::getResult(const String& weather)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sunrise
|
// sunrise
|
||||||
else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime)
|
else if (mHour >= 5.5f && mHour <= 8)
|
||||||
{
|
{
|
||||||
if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration))
|
if (mHour <= 6)
|
||||||
{
|
{
|
||||||
// fade in
|
// fade in
|
||||||
float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour;
|
float advance = 6-mHour;
|
||||||
float factor = (advance / fade_duration);
|
float factor = advance / 0.5f;
|
||||||
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor);
|
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor);
|
||||||
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor);
|
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor);
|
||||||
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor);
|
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor);
|
||||||
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor);
|
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor);
|
||||||
result.mNightFade = factor;
|
result.mNightFade = factor;
|
||||||
}
|
}
|
||||||
else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration))
|
else //if (mHour >= 6)
|
||||||
{
|
{
|
||||||
// fade out
|
// fade out
|
||||||
float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration);
|
float advance = mHour-9;
|
||||||
float factor = advance / fade_duration;
|
float factor = advance / 3.f;
|
||||||
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor);
|
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor);
|
||||||
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor);
|
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor);
|
||||||
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor);
|
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor);
|
||||||
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor);
|
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
result.mFogColor = current.mFogSunriseColor;
|
|
||||||
result.mAmbientColor = current.mAmbientSunriseColor;
|
|
||||||
result.mSunColor = current.mSunSunriseColor;
|
|
||||||
result.mSkyColor = current.mSkySunriseColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// day
|
// day
|
||||||
else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime))
|
else if (mHour >= 8 && mHour <= 17)
|
||||||
{
|
{
|
||||||
result.mFogColor = current.mFogDayColor;
|
result.mFogColor = current.mFogDayColor;
|
||||||
result.mAmbientColor = current.mAmbientDayColor;
|
result.mAmbientColor = current.mAmbientDayColor;
|
||||||
|
@ -414,36 +412,29 @@ WeatherResult WeatherManager::getResult(const String& weather)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sunset
|
// sunset
|
||||||
else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration))
|
else if (mHour >= 17 && mHour <= 21)
|
||||||
{
|
{
|
||||||
if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration))
|
if (mHour <= 19)
|
||||||
{
|
{
|
||||||
// fade in
|
// fade in
|
||||||
float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour;
|
float advance = 19-mHour;
|
||||||
float factor = (advance / fade_duration);
|
float factor = (advance / 2);
|
||||||
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor);
|
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor);
|
||||||
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor);
|
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor);
|
||||||
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor);
|
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor);
|
||||||
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor);
|
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor);
|
||||||
}
|
}
|
||||||
else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration))
|
else //if (mHour >= 19)
|
||||||
{
|
{
|
||||||
// fade out
|
// fade out
|
||||||
float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration);
|
float advance = mHour-19;
|
||||||
float factor = advance / fade_duration;
|
float factor = advance / 2.f;
|
||||||
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor);
|
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor);
|
||||||
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor);
|
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor);
|
||||||
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor);
|
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor);
|
||||||
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor);
|
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor);
|
||||||
result.mNightFade = factor;
|
result.mNightFade = factor;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
result.mFogColor = current.mFogSunsetColor;
|
|
||||||
result.mAmbientColor = current.mAmbientSunsetColor;
|
|
||||||
result.mSunColor = current.mSunSunsetColor;
|
|
||||||
result.mSkyColor = current.mSkySunsetColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -581,8 +572,7 @@ void WeatherManager::update(float duration)
|
||||||
mRendering->configureFog(result.mFogDepth, result.mFogColor);
|
mRendering->configureFog(result.mFogDepth, result.mFogColor);
|
||||||
|
|
||||||
// disable sun during night
|
// disable sun during night
|
||||||
if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration
|
if (mHour >= 21 || mHour <= 5.5f)
|
||||||
|| mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
|
|
||||||
mRendering->getSkyManager()->sunDisable();
|
mRendering->getSkyManager()->sunDisable();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,18 +95,18 @@ namespace MWWorld
|
||||||
Script Color=255,20,20
|
Script Color=255,20,20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const float mSunriseTime = 8;
|
static const float mSunriseTime;
|
||||||
static const float mSunsetTime = 18;
|
static const float mSunsetTime;
|
||||||
static const float mSunriseDuration = 2;
|
static const float mSunriseDuration;
|
||||||
static const float mSunsetDuration = 2;
|
static const float mSunsetDuration;
|
||||||
|
|
||||||
static const float mWeatherUpdateTime = 20.f;
|
static const float mWeatherUpdateTime;
|
||||||
|
|
||||||
// morrowind sets these per-weather, but since they are only used by 'thunderstorm'
|
// morrowind sets these per-weather, but since they are only used by 'thunderstorm'
|
||||||
// weather setting anyway, we can just as well set them globally
|
// weather setting anyway, we can just as well set them globally
|
||||||
static const float mThunderFrequency = .4;
|
static const float mThunderFrequency;
|
||||||
static const float mThunderThreshold = 0.6;
|
static const float mThunderThreshold;
|
||||||
static const float mThunderSoundDelay = 0.25;
|
static const float mThunderSoundDelay;
|
||||||
static const std::string mThunderSoundID0;
|
static const std::string mThunderSoundID0;
|
||||||
static const std::string mThunderSoundID1;
|
static const std::string mThunderSoundID1;
|
||||||
static const std::string mThunderSoundID2;
|
static const std::string mThunderSoundID2;
|
||||||
|
|
Loading…
Reference in a new issue