diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index da50af3e4..513f009ef 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -284,18 +284,25 @@ void RenderingManager::setSunColour(const Ogre::ColourValue& colour) { mSun->setDiffuseColour(colour); } + +void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour) +{ + mRendering.getScene()->setAmbientLight(colour); +} + void RenderingManager::sunEnable() { - /// \todo + if (mSun) mSun->setVisible(true); } + void RenderingManager::sunDisable() { - /// \todo + if (mSun) mSun->setVisible(false); } void RenderingManager::setSunDirection(const Ogre::Vector3& direction) { - /// \todo + if (mSun) mSun->setPosition(direction); } } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 1b5e23964..a4449145c 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -87,6 +87,7 @@ class RenderingManager: private RenderingInterface { void update (float duration); + void setAmbientColour(const Ogre::ColourValue& colour); void setSunColour(const Ogre::ColourValue& colour); void setSunDirection(const Ogre::Vector3& direction); void sunEnable(); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 5f24cc584..16a2a5646 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -480,8 +480,9 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) } if (mCloudColour != weather.mSunColor) - { - mCloudMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mAmbientColor); + { + /// \todo the cloud color looks a bit out of place sometimes (especially in Sunset) - maybe there's a multiplier or setting that i've missed? + mCloudMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSunColor); mCloudColour = weather.mSunColor; } @@ -498,9 +499,4 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) } mViewport->setBackgroundColour(weather.mFogColor); - - /// \todo - // only set ambient light if we're in an exterior cell - // (interior cell lights are not managed by SkyManager) - mSceneMgr->setAmbientLight(weather.mAmbientColor); } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 57b12c0c5..ea4f54055 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -1,4 +1,5 @@ #include "weather.hpp" +#include "world.hpp" #include "../mwrender/renderingmanager.hpp" @@ -7,10 +8,11 @@ using namespace MWWorld; #define TRANSITION_TIME 10 -WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) : +WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, World* world) : mHour(0), mCurrentWeather("clear") { mRendering = rendering; + mWorld = world; #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) @@ -211,7 +213,16 @@ void WeatherManager::update(float duration) mRendering->getSkyManager()->setWeather(result); - mRendering->setSunColour(result.mSunColor); + if (mWorld->isCellExterior() || mWorld->isCellQuasiExterior()) + { + mRendering->setAmbientColour(result.mAmbientColor); + mRendering->sunEnable(); + mRendering->setSunColour(result.mSunColor); + } + else + { + mRendering->sunDisable(); + } } void WeatherManager::setHour(const float hour) diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index d6302bccc..5502eb333 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -11,6 +11,8 @@ namespace MWRender namespace MWWorld { + class World; + /// Global weather manager properties (according to INI) struct WeatherGlobals { @@ -177,7 +179,7 @@ namespace MWWorld class WeatherManager { public: - WeatherManager(MWRender::RenderingManager*); + WeatherManager(MWRender::RenderingManager*, MWWorld::World*); /** * Change the weather setting @@ -203,6 +205,7 @@ namespace MWWorld int mDay, mMonth; MWRender::RenderingManager* mRendering; + MWWorld::World* mWorld; std::map mWeatherSettings; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 909989ad1..3b6782347 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -157,7 +157,7 @@ namespace MWWorld mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); - mWeatherManager = new MWWorld::WeatherManager(mRendering); + mWeatherManager = new MWWorld::WeatherManager(mRendering, this); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); @@ -701,6 +701,32 @@ namespace MWWorld mWeatherManager->update (duration); } + bool World::isCellExterior() const + { + Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); + if (currentCell) + { + if (!(currentCell->cell->data.flags & ESM::Cell::Interior)) + return true; + else + return false; + } + return false; + } + + bool World::isCellQuasiExterior() const + { + Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); + if (currentCell) + { + if (!(currentCell->cell->data.flags & ESM::Cell::QuasiEx)) + return false; + else + return true; + } + return false; + } + OEngine::Render::Fader* World::getFader() { return mRendering->getFader(); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 1df191853..304d105fc 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -112,7 +112,7 @@ namespace MWWorld Ptr::CellStore *getExterior (int x, int y); Ptr::CellStore *getInterior (const std::string& name); - + void adjustSky(); MWWorld::Player& getPlayer(); @@ -125,6 +125,9 @@ namespace MWWorld bool hasCellChanged() const; ///< Has the player moved to a different cell, since the last frame? + + bool isCellExterior() const; + bool isCellQuasiExterior() const; Globals::Data& getGlobalVariable (const std::string& name);