mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-13 14:25:24 -04:00
Add night-eye effect
This commit is contained in:
parent
712cef36b0
commit
76bdf7a5b7
@ -118,6 +118,7 @@ namespace MWRender
|
|||||||
: mViewer(viewer)
|
: mViewer(viewer)
|
||||||
, mRootNode(rootNode)
|
, mRootNode(rootNode)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
|
, mNightEyeFactor(0.f)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SceneUtil::LightManager> lightRoot = new SceneUtil::LightManager;
|
osg::ref_ptr<SceneUtil::LightManager> lightRoot = new SceneUtil::LightManager;
|
||||||
mLightRoot = lightRoot;
|
mLightRoot = lightRoot;
|
||||||
@ -203,9 +204,19 @@ namespace MWRender
|
|||||||
return mResourceSystem;
|
return mResourceSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderingManager::setNightEyeFactor(float factor)
|
||||||
|
{
|
||||||
|
if (factor != mNightEyeFactor)
|
||||||
|
{
|
||||||
|
mNightEyeFactor = factor;
|
||||||
|
updateAmbient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RenderingManager::setAmbientColour(const osg::Vec4f &colour)
|
void RenderingManager::setAmbientColour(const osg::Vec4f &colour)
|
||||||
{
|
{
|
||||||
mStateUpdater->setAmbientColor(colour);
|
mAmbientColor = colour;
|
||||||
|
updateAmbient();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingManager::configureAmbient(const ESM::Cell *cell)
|
void RenderingManager::configureAmbient(const ESM::Cell *cell)
|
||||||
@ -653,6 +664,16 @@ namespace MWRender
|
|||||||
mViewer->startThreading();
|
mViewer->startThreading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderingManager::updateAmbient()
|
||||||
|
{
|
||||||
|
osg::Vec4f color = mAmbientColor;
|
||||||
|
|
||||||
|
if (mNightEyeFactor > 0.f)
|
||||||
|
color += osg::Vec4f(0.7, 0.7, 0.7, 0.0) * mNightEyeFactor;
|
||||||
|
|
||||||
|
mStateUpdater->setAmbientColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
void RenderingManager::setFogColor(const osg::Vec4f &color)
|
void RenderingManager::setFogColor(const osg::Vec4f &color)
|
||||||
{
|
{
|
||||||
mViewer->getCamera()->setClearColor(color);
|
mViewer->getCamera()->setClearColor(color);
|
||||||
|
@ -59,6 +59,8 @@ namespace MWRender
|
|||||||
|
|
||||||
Resource::ResourceSystem* getResourceSystem();
|
Resource::ResourceSystem* getResourceSystem();
|
||||||
|
|
||||||
|
void setNightEyeFactor(float factor);
|
||||||
|
|
||||||
void setAmbientColour(const osg::Vec4f& colour);
|
void setAmbientColour(const osg::Vec4f& colour);
|
||||||
|
|
||||||
void setSunDirection(const osg::Vec3f& direction);
|
void setSunDirection(const osg::Vec3f& direction);
|
||||||
@ -152,6 +154,7 @@ namespace MWRender
|
|||||||
private:
|
private:
|
||||||
void updateProjectionMatrix();
|
void updateProjectionMatrix();
|
||||||
void updateTextureFiltering();
|
void updateTextureFiltering();
|
||||||
|
void updateAmbient();
|
||||||
void setFogColor(const osg::Vec4f& color);
|
void setFogColor(const osg::Vec4f& color);
|
||||||
|
|
||||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
||||||
@ -175,6 +178,9 @@ namespace MWRender
|
|||||||
|
|
||||||
osg::Vec4f mFogColor;
|
osg::Vec4f mFogColor;
|
||||||
|
|
||||||
|
osg::Vec4f mAmbientColor;
|
||||||
|
float mNightEyeFactor;
|
||||||
|
|
||||||
float mNearClip;
|
float mNearClip;
|
||||||
float mViewDistance;
|
float mViewDistance;
|
||||||
float mFieldOfView;
|
float mFieldOfView;
|
||||||
|
@ -1608,6 +1608,8 @@ namespace MWWorld
|
|||||||
int blind = static_cast<int>(player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude());
|
int blind = static_cast<int>(player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude());
|
||||||
MWBase::Environment::get().getWindowManager()->setBlindness(std::max(0, std::min(100, blind)));
|
MWBase::Environment::get().getWindowManager()->setBlindness(std::max(0, std::min(100, blind)));
|
||||||
|
|
||||||
|
int nightEye = static_cast<int>(player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::NightEye).getMagnitude());
|
||||||
|
mRendering->setNightEyeFactor(std::min(1.f, (nightEye/100.f)));
|
||||||
|
|
||||||
mRendering->getCamera()->setCameraDistance();
|
mRendering->getCamera()->setCameraDistance();
|
||||||
if(!mRendering->getCamera()->isFirstPerson())
|
if(!mRendering->getCamera()->isFirstPerson())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user