forked from teamnwah/openmw-tes3coop
Another weather cleanup
This commit is contained in:
parent
51067698a8
commit
c605f15a15
2 changed files with 35 additions and 43 deletions
|
@ -24,6 +24,7 @@ namespace
|
||||||
{
|
{
|
||||||
return x * (1-factor) + y * factor;
|
return x * (1-factor) + y * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::ColourValue lerp (const Ogre::ColourValue& x, const Ogre::ColourValue& y, float factor)
|
Ogre::ColourValue lerp (const Ogre::ColourValue& x, const Ogre::ColourValue& y, float factor)
|
||||||
{
|
{
|
||||||
return x * (1-factor) + y * factor;
|
return x * (1-factor) + y * factor;
|
||||||
|
@ -61,6 +62,33 @@ void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name
|
||||||
mWeatherSettings[name] = weather;
|
mWeatherSettings[name] = weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float WeatherManager::calculateHourFade (const std::string& moonName)
|
||||||
|
{
|
||||||
|
float fadeOutStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Out_Start");
|
||||||
|
float fadeInStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Start");
|
||||||
|
float fadeInFinish=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Finish");
|
||||||
|
|
||||||
|
if (mHour >= fadeOutStart && mHour <= fadeInStart)
|
||||||
|
return (1 - (mHour - fadeOutStart));
|
||||||
|
else if (mHour >= fadeInStart && mHour <= fadeInFinish)
|
||||||
|
return (mHour - fadeInStart);
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float WeatherManager::calculateAngleFade (const std::string& moonName, float angle)
|
||||||
|
{
|
||||||
|
float endAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_End_Angle");
|
||||||
|
float startAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Start_Angle");
|
||||||
|
if (angle >= endAngle && angle <= startAngle)
|
||||||
|
return (angle - endAngle);
|
||||||
|
else if (angle < endAngle)
|
||||||
|
return 0.f;
|
||||||
|
else
|
||||||
|
return 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fallback* fallback) :
|
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fallback* fallback) :
|
||||||
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),
|
||||||
|
@ -440,50 +468,11 @@ void WeatherManager::update(float duration)
|
||||||
mRendering->getSkyManager()->masserEnable();
|
mRendering->getSkyManager()->masserEnable();
|
||||||
mRendering->getSkyManager()->secundaEnable();
|
mRendering->getSkyManager()->secundaEnable();
|
||||||
|
|
||||||
float secundaHourFade;
|
|
||||||
float secundaFadeOutStart=mFallback->getFallbackFloat("Moons_Secunda_Fade_Out_Start");
|
|
||||||
float secundaFadeInStart=mFallback->getFallbackFloat("Moons_Secunda_Fade_In_Start");
|
|
||||||
float secundaFadeInFinish=mFallback->getFallbackFloat("Moons_Secunda_Fade_In_Finish");
|
|
||||||
|
|
||||||
if (mHour >= secundaFadeOutStart && mHour <= secundaFadeInStart)
|
|
||||||
secundaHourFade = 1 - (mHour - secundaFadeOutStart) / 3.f;
|
|
||||||
else if (mHour >= secundaFadeInStart && mHour <= secundaFadeInFinish)
|
|
||||||
secundaHourFade = mHour - secundaFadeInStart;
|
|
||||||
else
|
|
||||||
secundaHourFade = 1;
|
|
||||||
|
|
||||||
float masserHourFade;
|
|
||||||
float masserFadeOutStart=mFallback->getFallbackFloat("Moons_Masser_Fade_Out_Start");
|
|
||||||
float masserFadeInStart=mFallback->getFallbackFloat("Moons_Masser_Fade_In_Start");
|
|
||||||
float masserFadeInFinish=mFallback->getFallbackFloat("Moons_Masser_Fade_In_Finish");
|
|
||||||
if (mHour >= masserFadeOutStart && mHour <= masserFadeInStart)
|
|
||||||
masserHourFade = 1 - (mHour - masserFadeOutStart) / 3.f;
|
|
||||||
else if (mHour >= masserFadeInStart && mHour <= masserFadeInFinish)
|
|
||||||
masserHourFade = mHour - masserFadeInStart;
|
|
||||||
else
|
|
||||||
masserHourFade = 1;
|
|
||||||
|
|
||||||
float angle = moonHeight * 90.f;
|
float angle = moonHeight * 90.f;
|
||||||
|
float masserHourFade = calculateHourFade("Masser");
|
||||||
float secundaAngleFade;
|
float secundaHourFade = calculateHourFade("Secunda");
|
||||||
float secundaEndAngle=mFallback->getFallbackFloat("Moons_Secunda_Fade_End_Angle");
|
float masserAngleFade = calculateAngleFade("Masser", angle);
|
||||||
float secundaStartAngle=mFallback->getFallbackFloat("Moons_Secunda_Fade_Start_Angle");
|
float secundaAngleFade = calculateAngleFade("Secunda", angle);
|
||||||
if (angle >= secundaEndAngle && angle <= secundaStartAngle)
|
|
||||||
secundaAngleFade = (angle - secundaEndAngle) / 20.f;
|
|
||||||
else if (angle < secundaEndAngle)
|
|
||||||
secundaAngleFade = 0.f;
|
|
||||||
else
|
|
||||||
secundaAngleFade = 1.f;
|
|
||||||
|
|
||||||
float masserAngleFade;
|
|
||||||
float masserEndAngle=mFallback->getFallbackFloat("Moons_Masser_Fade_End_Angle");
|
|
||||||
float masserStartAngle=mFallback->getFallbackFloat("Moons_Masser_Fade_Start_Angle");
|
|
||||||
if (angle >= masserEndAngle && angle <= masserStartAngle)
|
|
||||||
masserAngleFade = (angle - masserEndAngle) / 10.f;
|
|
||||||
else if (angle < masserEndAngle)
|
|
||||||
masserAngleFade = 0.f;
|
|
||||||
else
|
|
||||||
masserAngleFade = 1.f;
|
|
||||||
|
|
||||||
masserAngleFade *= masserHourFade;
|
masserAngleFade *= masserHourFade;
|
||||||
secundaAngleFade *= secundaHourFade;
|
secundaAngleFade *= secundaHourFade;
|
||||||
|
|
|
@ -174,6 +174,9 @@ namespace MWWorld
|
||||||
WeatherResult transition(const float factor);
|
WeatherResult transition(const float factor);
|
||||||
WeatherResult getResult(const Ogre::String& weather);
|
WeatherResult getResult(const Ogre::String& weather);
|
||||||
|
|
||||||
|
float calculateHourFade (const std::string& moonName);
|
||||||
|
float calculateAngleFade (const std::string& moonName, float angle);
|
||||||
|
|
||||||
void setWeather(const Ogre::String& weather, bool instant=false);
|
void setWeather(const Ogre::String& weather, bool instant=false);
|
||||||
float mSunriseTime;
|
float mSunriseTime;
|
||||||
float mSunsetTime;
|
float mSunsetTime;
|
||||||
|
|
Loading…
Reference in a new issue