1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:53:52 +00:00

Merge remote-tracking branch 'glorf/weather'

This commit is contained in:
Marc Zinnschlag 2013-05-14 22:56:26 +02:00
commit 56b2b05f9a
2 changed files with 32 additions and 25 deletions

View file

@ -57,7 +57,7 @@ BillboardObject::BillboardObject( const String& textureName,
mNode = rootNode->createChildSceneNode(); mNode = rootNode->createChildSceneNode();
mNode->setPosition(finalPosition); mNode->setPosition(finalPosition);
mNode->attachObject(mEntity); mNode->attachObject(mEntity);
mNode->setScale(Ogre::Vector3(550.f*initialSize)); mNode->setScale(Ogre::Vector3(450.f*initialSize));
mNode->setOrientation(Ogre::Vector3::UNIT_Z.getRotationTo(-position.normalisedCopy())); mNode->setOrientation(Ogre::Vector3::UNIT_Z.getRotationTo(-position.normalisedCopy()));
sh::Factory::getInstance().getMaterialInstance ("BillboardMaterial"+StringConverter::toString(bodyCount))->setListener(this); sh::Factory::getInstance().getMaterialInstance ("BillboardMaterial"+StringConverter::toString(bodyCount))->setListener(this);
@ -86,7 +86,7 @@ void BillboardObject::setVisible(const bool visible)
void BillboardObject::setSize(const float size) void BillboardObject::setSize(const float size)
{ {
mNode->setScale(550.f*size, 550.f*size, 550.f*size); mNode->setScale(450.f*size, 450.f*size, 450.f*size);
} }
void BillboardObject::setVisibility(const float visibility) void BillboardObject::setVisibility(const float visibility)
@ -267,11 +267,11 @@ void SkyManager::create()
mLightning->setDiffuseColour (ColourValue(3,3,3)); mLightning->setDiffuseColour (ColourValue(3,3,3));
const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback(); const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback();
mSecunda = new Moon("secunda_texture", /*0.5*/fallback->getFallbackFloat("Moons_Secunda_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon"); mSecunda = new Moon("secunda_texture", fallback->getFallbackFloat("Moons_Secunda_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon");
mSecunda->setType(Moon::Type_Secunda); mSecunda->setType(Moon::Type_Secunda);
mSecunda->setRenderQueue(RQG_SkiesEarly+4); mSecunda->setRenderQueue(RQG_SkiesEarly+4);
mMasser = new Moon("masser_texture", /*0.75*/fallback->getFallbackFloat("Moons_Masser_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon"); mMasser = new Moon("masser_texture", fallback->getFallbackFloat("Moons_Masser_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon");
mMasser->setRenderQueue(RQG_SkiesEarly+3); mMasser->setRenderQueue(RQG_SkiesEarly+3);
mMasser->setType(Moon::Type_Masser); mMasser->setType(Moon::Type_Masser);

View file

@ -66,14 +66,14 @@ void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name
float WeatherManager::calculateHourFade (const std::string& moonName) const float WeatherManager::calculateHourFade (const std::string& moonName) const
{ {
float fadeOutStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Out_Start"); float fadeOutStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Out_Start");
float fadeOutFinish=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Out_Finish");
float fadeInStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Start"); float fadeInStart=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Start");
float fadeInFinish=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Finish"); float fadeInFinish=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_In_Finish");
float fadeOutFinish=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Out_Finish");
if (mHour >= fadeOutStart && mHour <= fadeOutFinish) if (mHour >= fadeOutStart && mHour <= fadeOutFinish)
return (1 / (mHour - fadeOutStart)); return (1 - ((mHour - fadeOutStart) / (fadeOutFinish - fadeOutStart)));
else if (mHour >= fadeInStart && mHour <= fadeInFinish) if (mHour >= fadeInStart && mHour <= fadeInFinish)
return (1 / (mHour - fadeInStart)); return (1 - ((mHour - fadeInStart) / (fadeInFinish - fadeInStart)));
else else
return 1; return 1;
} }
@ -82,9 +82,9 @@ float WeatherManager::calculateAngleFade (const std::string& moonName, float ang
{ {
float endAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_End_Angle"); float endAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_End_Angle");
float startAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Start_Angle"); float startAngle=mFallback->getFallbackFloat("Moons_"+moonName+"_Fade_Start_Angle");
if (angle >= endAngle && angle <= startAngle) if (angle <= startAngle && angle >= endAngle)
return ((angle - endAngle)/(startAngle-endAngle)); return (1 - ((angle - endAngle)/(startAngle-endAngle)));
else if (angle < endAngle) else if (angle > startAngle)
return 0.f; return 0.f;
else else
return 1.f; return 1.f;
@ -439,29 +439,36 @@ void WeatherManager::update(float duration)
height); height);
mRendering->setSunDirection(final); mRendering->setSunDirection(final);
// moon calculations /*
float night; * TODO: import separated fadeInStart/Finish, fadeOutStart/Finish
if (mHour >= 14) * for masser and secunda
night = mHour - 14; */
else if (mHour <= 10)
night = mHour + 10; float fadeOutFinish=mFallback->getFallbackFloat("Moons_Masser_Fade_Out_Finish");
float fadeInStart=mFallback->getFallbackFloat("Moons_Masser_Fade_In_Start");
//moon calculations
float moonHeight;
if (mHour >= fadeInStart)
moonHeight = mHour - fadeInStart;
else if (mHour <= fadeOutFinish)
moonHeight = mHour + fadeOutFinish;
else else
night = 0; moonHeight = 0;
night /= 20.f; moonHeight /= (24.f - (fadeInStart - fadeOutFinish));
if (night != 0) if (moonHeight != 0)
{ {
float moonHeight = 1 - std::abs((night - 0.5) * 2); int facing = (moonHeight <= 1) ? 1 : -1;
int facing = (mHour > 0.f && mHour< 12.f) ? 1 : -1;
Vector3 masser( Vector3 masser(
(1 - moonHeight) * facing, (moonHeight - 1) * facing,
(1 - moonHeight) * facing, (1 - moonHeight) * facing,
moonHeight); moonHeight);
Vector3 secunda( Vector3 secunda(
(moonHeight - 1) * facing * 1.25,
(1 - moonHeight) * facing * 0.8, (1 - moonHeight) * facing * 0.8,
(1 - moonHeight) * facing * 1.25,
moonHeight); moonHeight);
mRendering->getSkyManager()->setMasserDirection(masser); mRendering->getSkyManager()->setMasserDirection(masser);
@ -469,7 +476,7 @@ void WeatherManager::update(float duration)
mRendering->getSkyManager()->masserEnable(); mRendering->getSkyManager()->masserEnable();
mRendering->getSkyManager()->secundaEnable(); mRendering->getSkyManager()->secundaEnable();
float angle = moonHeight * 90.f; float angle = (1-moonHeight) * 90.f * facing;
float masserHourFade = calculateHourFade("Masser"); float masserHourFade = calculateHourFade("Masser");
float secundaHourFade = calculateHourFade("Secunda"); float secundaHourFade = calculateHourFade("Secunda");
float masserAngleFade = calculateAngleFade("Masser", angle); float masserAngleFade = calculateAngleFade("Masser", angle);