Small weather cleanup

actorid
Glorf 12 years ago
parent 007a3cf9bd
commit 68f249e8f4

@ -65,9 +65,8 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0),
mRemainingTransitionTime(0), mMonth(0), mDay(0),
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f)
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering)
{
mRendering = rendering;
//Globals
mThunderSoundID0 = mFallback->getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_0");
mThunderSoundID1 = mFallback->getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_1");
@ -82,6 +81,18 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
mThunderFrequency = mFallback->getFallbackFloat("Weather_Thunderstorm_Thunder_Frequency");
mThunderThreshold = mFallback->getFallbackFloat("Weather_Thunderstorm_Thunder_Threshold");
mThunderSoundDelay = 0.25;
//Some useful values
/* TODO: Use pre-sunrise_time, pre-sunset_time,
* post-sunrise_time, and post-sunset_time to better
* describe sunrise/sunset time.
* These values are fallbacks attached to weather.
*/
mNightStart = mSunsetTime + mSunsetDuration;
mNightEnd = mSunriseTime - 0.5;
mDayStart = mSunriseTime + mSunriseDuration;
mDayEnd = mSunsetTime;
//Weather
Weather clear;
clear.mCloudTexture = "tx_sky_clear.dds";
@ -171,12 +182,12 @@ WeatherResult WeatherManager::getResult(const String& weather)
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
result.mSunColor = current.mSunDiscSunsetColor;
result.mNight = (mHour < 6 || mHour > 19);
result.mNight = (mHour < mSunriseTime || mHour > mNightStart - 1);
result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
// night
if (mHour <= 5.5f || mHour >= 21)
if (mHour <= mNightEnd || mHour >= mNightStart + 1)
{
result.mFogColor = current.mFogNightColor;
result.mAmbientColor = current.mAmbientNightColor;
@ -186,12 +197,12 @@ WeatherResult WeatherManager::getResult(const String& weather)
}
// sunrise
else if (mHour >= 5.5f && mHour <= 9)
else if (mHour >= mNightEnd && mHour <= mDayStart + 1)
{
if (mHour <= 6)
if (mHour <= mSunriseTime)
{
// fade in
float advance = 6-mHour;
float advance = mSunriseTime - mHour;
float factor = advance / 0.5f;
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor, factor);
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor, factor);
@ -202,7 +213,7 @@ WeatherResult WeatherManager::getResult(const String& weather)
else //if (mHour >= 6)
{
// fade out
float advance = mHour-6;
float advance = mHour - mSunriseTime;
float factor = advance / 3.f;
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor, factor);
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor, factor);
@ -212,7 +223,7 @@ WeatherResult WeatherManager::getResult(const String& weather)
}
// day
else if (mHour >= 9 && mHour <= 17)
else if (mHour >= mDayStart + 1 && mHour <= mDayEnd - 1)
{
result.mFogColor = current.mFogDayColor;
result.mAmbientColor = current.mAmbientDayColor;
@ -221,12 +232,12 @@ WeatherResult WeatherManager::getResult(const String& weather)
}
// sunset
else if (mHour >= 17 && mHour <= 21)
else if (mHour >= mDayEnd - 1 && mHour <= mNightStart + 1)
{
if (mHour <= 19)
if (mHour <= mDayEnd + 1)
{
// fade in
float advance = 19-mHour;
float advance = (mDayEnd + 1) - mHour;
float factor = (advance / 2);
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor, factor);
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor, factor);
@ -236,7 +247,7 @@ WeatherResult WeatherManager::getResult(const String& weather)
else //if (mHour >= 19)
{
// fade out
float advance = mHour-19;
float advance = mHour - (mDayEnd + 1);
float factor = advance / 2.f;
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor, factor);
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor, factor);
@ -372,7 +383,7 @@ void WeatherManager::update(float duration)
mRendering->configureFog(result.mFogDepth, result.mFogColor);
// disable sun during night
if (mHour >= 20 || mHour <= 6.f)
if (mHour >= mNightStart || mHour <= mSunriseTime)
mRendering->getSkyManager()->sunDisable();
else
mRendering->getSkyManager()->sunEnable();
@ -380,15 +391,18 @@ void WeatherManager::update(float duration)
// sun angle
float height;
//Day duration
float dayDuration = (mNightStart - 1) - mSunriseTime;
// rise at 6, set at 20
if (mHour >= 6 && mHour <= 20)
height = 1-std::abs(((mHour-13)/7.f));
else if (mHour > 20)
height = (mHour-20.f)/4.f;
if (mHour >= mSunriseTime && mHour <= mNightStart)
height = 1 - std::abs(((mHour - dayDuration) / 7.f));
else if (mHour > mNightStart)
height = (mHour - mNightStart) / 4.f;
else //if (mHour > 0 && mHour < 6)
height = 1-(mHour/6.f);
height = 1 - (mHour / mSunriseTime);
int facing = (mHour > 13.f) ? 1 : -1;
int facing = (mHour > dayDuration) ? 1 : -1;
Vector3 final(
-(1 - height) * facing,
@ -426,56 +440,56 @@ void WeatherManager::update(float duration)
mRendering->getSkyManager()->masserEnable();
mRendering->getSkyManager()->secundaEnable();
float secunda_hour_fade;
float secunda_fadeout_start=mFallback->getFallbackFloat("Moons_Secunda_Fade_Out_Start");
float secunda_fadein_start=mFallback->getFallbackFloat("Moons_Secunda_Fade_In_Start");
float secunda_fadein_finish=mFallback->getFallbackFloat("Moons_Secunda_Fade_In_Finish");
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 >= secunda_fadeout_start && mHour <= secunda_fadein_start)
secunda_hour_fade = 1-(mHour-secunda_fadeout_start)/3.f;
else if (mHour >= secunda_fadein_start && mHour <= secunda_fadein_finish)
secunda_hour_fade = mHour-secunda_fadein_start;
if (mHour >= secundaFadeOutStart && mHour <= secundaFadeInStart)
secundaHourFade = 1 - (mHour - secundaFadeOutStart) / 3.f;
else if (mHour >= secundaFadeInStart && mHour <= secundaFadeInFinish)
secundaHourFade = mHour - secundaFadeInStart;
else
secunda_hour_fade = 1;
float masser_hour_fade;
float masser_fadeout_start=mFallback->getFallbackFloat("Moons_Masser_Fade_Out_Start");
float masser_fadein_start=mFallback->getFallbackFloat("Moons_Masser_Fade_In_Start");
float masser_fadein_finish=mFallback->getFallbackFloat("Moons_Masser_Fade_In_Finish");
if (mHour >= masser_fadeout_start && mHour <= masser_fadein_start)
masser_hour_fade = 1-(mHour-masser_fadeout_start)/3.f;
else if (mHour >= masser_fadein_start && mHour <= masser_fadein_finish)
masser_hour_fade = mHour-masser_fadein_start;
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
masser_hour_fade = 1;
masserHourFade = 1;
float angle = moonHeight * 90.f;
float secunda_angle_fade;
float secunda_end_angle=mFallback->getFallbackFloat("Moons_Secunda_Fade_End_Angle");
float secunda_start_angle=mFallback->getFallbackFloat("Moons_Secunda_Fade_Start_Angle");
if (angle >= secunda_end_angle && angle <= secunda_start_angle)
secunda_angle_fade = (angle-secunda_end_angle)/20.f;
else if (angle < secunda_end_angle)
secunda_angle_fade = 0.f;
float secundaAngleFade;
float secundaEndAngle=mFallback->getFallbackFloat("Moons_Secunda_Fade_End_Angle");
float secundaStartAngle=mFallback->getFallbackFloat("Moons_Secunda_Fade_Start_Angle");
if (angle >= secundaEndAngle && angle <= secundaStartAngle)
secundaAngleFade = (angle - secundaEndAngle) / 20.f;
else if (angle < secundaEndAngle)
secundaAngleFade = 0.f;
else
secunda_angle_fade = 1.f;
float masser_angle_fade;
float masser_end_angle=mFallback->getFallbackFloat("Moons_Masser_Fade_End_Angle");
float masser_start_angle=mFallback->getFallbackFloat("Moons_Masser_Fade_Start_Angle");
if (angle >= masser_end_angle && angle <= masser_start_angle)
masser_angle_fade = (angle-masser_end_angle)/10.f;
else if (angle < masser_end_angle)
masser_angle_fade = 0.f;
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
masser_angle_fade = 1.f;
masserAngleFade = 1.f;
masser_angle_fade *= masser_hour_fade;
secunda_angle_fade *= secunda_hour_fade;
masserAngleFade *= masserHourFade;
secundaAngleFade *= secundaHourFade;
mRendering->getSkyManager()->setMasserFade(masser_angle_fade);
mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade);
mRendering->getSkyManager()->setMasserFade(masserAngleFade);
mRendering->getSkyManager()->setSecundaFade(secundaAngleFade);
}
else
{

@ -184,6 +184,10 @@ namespace MWWorld
float mThunderFrequency;
float mThunderThreshold;
float mThunderSoundDelay;
float mNightStart;
float mNightEnd;
float mDayStart;
float mDayEnd;
std::string mThunderSoundID0;
std::string mThunderSoundID1;
std::string mThunderSoundID2;

Loading…
Cancel
Save