From 979a874220267be05b290314846ce34bd054f4d6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 3 Feb 2013 19:01:59 +0100 Subject: [PATCH] Fixed the custom near clip planes --- apps/openmw/mwrender/refraction.cpp | 6 +++--- apps/openmw/mwrender/refraction.hpp | 2 +- apps/openmw/mwrender/water.cpp | 13 +++++++------ apps/openmw/mwrender/water.hpp | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwrender/refraction.cpp b/apps/openmw/mwrender/refraction.cpp index 88ad70b7f..85642bc08 100644 --- a/apps/openmw/mwrender/refraction.cpp +++ b/apps/openmw/mwrender/refraction.cpp @@ -25,6 +25,7 @@ namespace MWRender vp->setOverlaysEnabled(false); vp->setShadowsEnabled(false); vp->setVisibilityMask(RV_Actors + RV_Misc + RV_Statics + RV_StaticsSmall + RV_Terrain); + vp->setMaterialScheme("water_reflection"); mRenderTarget->setAutoUpdated(true); 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), 0); + mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,1,0), -(height + 5)); } } diff --git a/apps/openmw/mwrender/refraction.hpp b/apps/openmw/mwrender/refraction.hpp index 01ec86521..e3777d9cf 100644 --- a/apps/openmw/mwrender/refraction.hpp +++ b/apps/openmw/mwrender/refraction.hpp @@ -20,7 +20,7 @@ namespace MWRender Refraction(Ogre::Camera* parentCamera); ~Refraction(); - void setWaterPlane (Ogre::Plane plane); + void setHeight (float height); void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 4ef2aea66..877a9a953 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -155,10 +155,10 @@ void PlaneReflection::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) mRenderActive = false; } -void PlaneReflection::setWaterPlane (Plane plane) +void PlaneReflection::setHeight (float height) { - mWaterPlane = plane; - mErrorPlane = Plane(plane.normal, mWaterPlane.d - 5); + mWaterPlane = Plane(Ogre::Vector3(0,1,0), height); + mErrorPlane = Plane(Ogre::Vector3(0,1,0), height - 5); } void PlaneReflection::setActive (bool active) @@ -321,9 +321,9 @@ void Water::setHeight(const float height) mWaterPlane = Plane(Vector3::UNIT_Y, -height); if (mReflection) - mReflection->setWaterPlane(mWaterPlane); + mReflection->setHeight(height); if (mRefraction) - mRefraction->setWaterPlane(mWaterPlane); + mRefraction->setHeight(height); mWaterNode->setPosition(0, height, 0); sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty(new sh::FloatValue(height))); @@ -423,7 +423,7 @@ void Water::applyRTT() { mReflection = new PlaneReflection(mSceneMgr, mSky); mReflection->setParentCamera (mCamera); - mReflection->setWaterPlane(mWaterPlane); + mReflection->setHeight(mTop); mWater->setRenderQueueGroup(RQG_Water); } else @@ -434,6 +434,7 @@ void Water::applyRTT() mRefraction = NULL; mRefraction = new Refraction(mCamera); + mRefraction->setHeight(mTop); } void Water::applyVisibilityMask() diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index 67c788c81..cf181674a 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -39,7 +39,7 @@ namespace MWRender { : mSceneMgr(sceneManager) {} virtual ~Reflection() {} - virtual void setWaterPlane (Ogre::Plane plane) {} + virtual void setHeight (float height) {} virtual void setParentCamera (Ogre::Camera* parent) { mParentCamera = parent; } void setUnderwater(bool underwater) { mIsUnderwater = underwater; } virtual void setActive (bool active) {} @@ -72,7 +72,7 @@ namespace MWRender { PlaneReflection(Ogre::SceneManager* sceneManager, SkyManager* sky); virtual ~PlaneReflection(); - virtual void setWaterPlane (Ogre::Plane plane); + virtual void setHeight (float height); virtual void setActive (bool active); virtual void setVisibilityMask (int flags);