1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 21:45:33 +00:00

Added Blind and Night Eye effects

This commit is contained in:
scrawl 2013-04-25 02:31:51 +02:00
parent 38c371a6ef
commit 933f894148
3 changed files with 30 additions and 13 deletions

View file

@ -30,6 +30,8 @@
#include "../mwbase/inputmanager.hpp" // FIXME #include "../mwbase/inputmanager.hpp" // FIXME
#include "../mwbase/windowmanager.hpp" // FIXME #include "../mwbase/windowmanager.hpp" // FIXME
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
@ -315,13 +317,15 @@ void RenderingManager::update (float duration, bool paused)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
setAmbientMode();
// player position // player position
MWWorld::RefData &data = MWWorld::RefData &data = player.getRefData();
MWBase::Environment::get()
.getWorld()
->getPlayer()
.getPlayer()
.getRefData();
float *_playerPos = data.getPosition().pos; float *_playerPos = data.getPosition().pos;
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]); Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
@ -597,8 +601,15 @@ void RenderingManager::setSunColour(const Ogre::ColourValue& colour)
void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour) void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour)
{ {
mRendering.getScene()->setAmbientLight(colour); mAmbientColor = colour;
mTerrainManager->setAmbient(colour);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
int nightEye = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::NightEye)).mMagnitude;
Ogre::ColourValue final = colour;
final += Ogre::ColourValue(0.7,0.7,0.7,0) * std::min(1.f, (nightEye/100.f));
mRendering.getScene()->setAmbientLight(final);
mTerrainManager->setAmbient(final);
} }
void RenderingManager::sunEnable(bool real) void RenderingManager::sunEnable(bool real)

View file

@ -19,6 +19,7 @@ Fader::Fader(Ogre::SceneManager* sceneMgr)
, mTargetAlpha(0.f) , mTargetAlpha(0.f)
, mCurrentAlpha(0.f) , mCurrentAlpha(0.f)
, mStartAlpha(0.f) , mStartAlpha(0.f)
, mFactor(1.f)
{ {
// Create the fading material // Create the fading material
MaterialPtr material = MaterialManager::getSingleton().create("FadeInOutMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME ); MaterialPtr material = MaterialManager::getSingleton().create("FadeInOutMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
@ -63,18 +64,19 @@ void Fader::update(float dt)
if (mCurrentAlpha > mTargetAlpha) mCurrentAlpha = mTargetAlpha; if (mCurrentAlpha > mTargetAlpha) mCurrentAlpha = mTargetAlpha;
} }
applyAlpha();
mRemainingTime -= dt; mRemainingTime -= dt;
} }
if (mCurrentAlpha == 0.f) mRectangle->setVisible(false); if (1.f-((1.f-mCurrentAlpha) * mFactor) == 0.f)
mRectangle->setVisible(false);
else
applyAlpha();
} }
void Fader::applyAlpha() void Fader::applyAlpha()
{ {
mRectangle->setVisible(true); mRectangle->setVisible(true);
mFadeTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, mCurrentAlpha); mFadeTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 1.f-((1.f-mCurrentAlpha) * mFactor));
} }
void Fader::fadeIn(float time) void Fader::fadeIn(float time)

View file

@ -29,6 +29,8 @@ namespace Render
void fadeOut(const float time); void fadeOut(const float time);
void fadeTo(const int percent, const float time); void fadeTo(const int percent, const float time);
void setFactor (float factor) { mFactor = factor; }
private: private:
enum FadingMode enum FadingMode
{ {
@ -49,6 +51,8 @@ namespace Render
float mCurrentAlpha; float mCurrentAlpha;
float mStartAlpha; float mStartAlpha;
float mFactor;
Ogre::SceneManager* mSceneMgr; Ogre::SceneManager* mSceneMgr;
}; };
}} }}