- 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);
}
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

View file

@ -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();

View file

@ -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);
}

View file

@ -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)

View file

@ -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<Ogre::String, Weather> mWeatherSettings;

View file

@ -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();

View file

@ -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);