1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 01:45:34 +00:00

- added isCellExterior / isCellQuasiExterior methods to World

- interior now have the sun disabled properly (and ambient managed by cell, not sky)
This commit is contained in:
scrawl 2012-02-23 21:12:06 +01:00
parent 90af78e3b8
commit d9c02ca526
7 changed files with 62 additions and 15 deletions

View file

@ -284,18 +284,25 @@ void RenderingManager::setSunColour(const Ogre::ColourValue& colour)
{ {
mSun->setDiffuseColour(colour); mSun->setDiffuseColour(colour);
} }
void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour)
{
mRendering.getScene()->setAmbientLight(colour);
}
void RenderingManager::sunEnable() void RenderingManager::sunEnable()
{ {
/// \todo if (mSun) mSun->setVisible(true);
} }
void RenderingManager::sunDisable() void RenderingManager::sunDisable()
{ {
/// \todo if (mSun) mSun->setVisible(false);
} }
void RenderingManager::setSunDirection(const Ogre::Vector3& direction) void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
{ {
/// \todo if (mSun) mSun->setPosition(direction);
} }
} // namespace } // namespace

View file

@ -87,6 +87,7 @@ class RenderingManager: private RenderingInterface {
void update (float duration); void update (float duration);
void setAmbientColour(const Ogre::ColourValue& colour);
void setSunColour(const Ogre::ColourValue& colour); void setSunColour(const Ogre::ColourValue& colour);
void setSunDirection(const Ogre::Vector3& direction); void setSunDirection(const Ogre::Vector3& direction);
void sunEnable(); void sunEnable();

View file

@ -481,7 +481,8 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
if (mCloudColour != weather.mSunColor) 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; mCloudColour = weather.mSunColor;
} }
@ -498,9 +499,4 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
} }
mViewport->setBackgroundColour(weather.mFogColor); 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);
} }

View file

@ -1,4 +1,5 @@
#include "weather.hpp" #include "weather.hpp"
#include "world.hpp"
#include "../mwrender/renderingmanager.hpp" #include "../mwrender/renderingmanager.hpp"
@ -7,10 +8,11 @@ using namespace MWWorld;
#define TRANSITION_TIME 10 #define TRANSITION_TIME 10
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) : WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, World* world) :
mHour(0), mCurrentWeather("clear") mHour(0), mCurrentWeather("clear")
{ {
mRendering = rendering; mRendering = rendering;
mWorld = world;
#define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f)
@ -211,8 +213,17 @@ void WeatherManager::update(float duration)
mRendering->getSkyManager()->setWeather(result); mRendering->getSkyManager()->setWeather(result);
if (mWorld->isCellExterior() || mWorld->isCellQuasiExterior())
{
mRendering->setAmbientColour(result.mAmbientColor);
mRendering->sunEnable();
mRendering->setSunColour(result.mSunColor); mRendering->setSunColour(result.mSunColor);
} }
else
{
mRendering->sunDisable();
}
}
void WeatherManager::setHour(const float hour) void WeatherManager::setHour(const float hour)
{ {

View file

@ -11,6 +11,8 @@ namespace MWRender
namespace MWWorld namespace MWWorld
{ {
class World;
/// Global weather manager properties (according to INI) /// Global weather manager properties (according to INI)
struct WeatherGlobals struct WeatherGlobals
{ {
@ -177,7 +179,7 @@ namespace MWWorld
class WeatherManager class WeatherManager
{ {
public: public:
WeatherManager(MWRender::RenderingManager*); WeatherManager(MWRender::RenderingManager*, MWWorld::World*);
/** /**
* Change the weather setting * Change the weather setting
@ -203,6 +205,7 @@ namespace MWWorld
int mDay, mMonth; int mDay, mMonth;
MWRender::RenderingManager* mRendering; MWRender::RenderingManager* mRendering;
MWWorld::World* mWorld;
std::map<Ogre::String, Weather> mWeatherSettings; std::map<Ogre::String, Weather> mWeatherSettings;

View file

@ -157,7 +157,7 @@ namespace MWWorld
mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); 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)); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master));
@ -701,6 +701,32 @@ namespace MWWorld
mWeatherManager->update (duration); 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() OEngine::Render::Fader* World::getFader()
{ {
return mRendering->getFader(); return mRendering->getFader();

View file

@ -126,6 +126,9 @@ namespace MWWorld
bool hasCellChanged() const; bool hasCellChanged() const;
///< Has the player moved to a different cell, since the last frame? ///< 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); Globals::Data& getGlobalVariable (const std::string& name);
Globals::Data getGlobalVariable (const std::string& name) const; Globals::Data getGlobalVariable (const std::string& name) const;