1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 23:53:56 +00:00

Fixed the custom near clip planes

This commit is contained in:
scrawl 2013-02-03 19:01:59 +01:00
parent 5334934612
commit 979a874220
4 changed files with 13 additions and 12 deletions

View file

@ -25,6 +25,7 @@ namespace MWRender
vp->setOverlaysEnabled(false); vp->setOverlaysEnabled(false);
vp->setShadowsEnabled(false); vp->setShadowsEnabled(false);
vp->setVisibilityMask(RV_Actors + RV_Misc + RV_Statics + RV_StaticsSmall + RV_Terrain); vp->setVisibilityMask(RV_Actors + RV_Misc + RV_Statics + RV_StaticsSmall + RV_Terrain);
vp->setMaterialScheme("water_reflection");
mRenderTarget->setAutoUpdated(true); mRenderTarget->setAutoUpdated(true);
mRenderTarget->addListener(this); mRenderTarget->addListener(this);
} }
@ -54,10 +55,9 @@ namespace MWRender
} }
void Refraction::setWaterPlane(Ogre::Plane plane) void Refraction::setHeight(float height)
{ {
/// \todo mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,1,0), -(height + 5));
mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,1,0), 0);
} }
} }

View file

@ -20,7 +20,7 @@ namespace MWRender
Refraction(Ogre::Camera* parentCamera); Refraction(Ogre::Camera* parentCamera);
~Refraction(); ~Refraction();
void setWaterPlane (Ogre::Plane plane); void setHeight (float height);
void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);

View file

@ -155,10 +155,10 @@ void PlaneReflection::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
mRenderActive = false; mRenderActive = false;
} }
void PlaneReflection::setWaterPlane (Plane plane) void PlaneReflection::setHeight (float height)
{ {
mWaterPlane = plane; mWaterPlane = Plane(Ogre::Vector3(0,1,0), height);
mErrorPlane = Plane(plane.normal, mWaterPlane.d - 5); mErrorPlane = Plane(Ogre::Vector3(0,1,0), height - 5);
} }
void PlaneReflection::setActive (bool active) void PlaneReflection::setActive (bool active)
@ -321,9 +321,9 @@ void Water::setHeight(const float height)
mWaterPlane = Plane(Vector3::UNIT_Y, -height); mWaterPlane = Plane(Vector3::UNIT_Y, -height);
if (mReflection) if (mReflection)
mReflection->setWaterPlane(mWaterPlane); mReflection->setHeight(height);
if (mRefraction) if (mRefraction)
mRefraction->setWaterPlane(mWaterPlane); mRefraction->setHeight(height);
mWaterNode->setPosition(0, height, 0); mWaterNode->setPosition(0, height, 0);
sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(height))); sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(height)));
@ -423,7 +423,7 @@ void Water::applyRTT()
{ {
mReflection = new PlaneReflection(mSceneMgr, mSky); mReflection = new PlaneReflection(mSceneMgr, mSky);
mReflection->setParentCamera (mCamera); mReflection->setParentCamera (mCamera);
mReflection->setWaterPlane(mWaterPlane); mReflection->setHeight(mTop);
mWater->setRenderQueueGroup(RQG_Water); mWater->setRenderQueueGroup(RQG_Water);
} }
else else
@ -434,6 +434,7 @@ void Water::applyRTT()
mRefraction = NULL; mRefraction = NULL;
mRefraction = new Refraction(mCamera); mRefraction = new Refraction(mCamera);
mRefraction->setHeight(mTop);
} }
void Water::applyVisibilityMask() void Water::applyVisibilityMask()

View file

@ -39,7 +39,7 @@ namespace MWRender {
: mSceneMgr(sceneManager) {} : mSceneMgr(sceneManager) {}
virtual ~Reflection() {} virtual ~Reflection() {}
virtual void setWaterPlane (Ogre::Plane plane) {} virtual void setHeight (float height) {}
virtual void setParentCamera (Ogre::Camera* parent) { mParentCamera = parent; } virtual void setParentCamera (Ogre::Camera* parent) { mParentCamera = parent; }
void setUnderwater(bool underwater) { mIsUnderwater = underwater; } void setUnderwater(bool underwater) { mIsUnderwater = underwater; }
virtual void setActive (bool active) {} virtual void setActive (bool active) {}
@ -72,7 +72,7 @@ namespace MWRender {
PlaneReflection(Ogre::SceneManager* sceneManager, SkyManager* sky); PlaneReflection(Ogre::SceneManager* sceneManager, SkyManager* sky);
virtual ~PlaneReflection(); virtual ~PlaneReflection();
virtual void setWaterPlane (Ogre::Plane plane); virtual void setHeight (float height);
virtual void setActive (bool active); virtual void setActive (bool active);
virtual void setVisibilityMask (int flags); virtual void setVisibilityMask (int flags);