From a68f54b4e869f3cbf7e826cd59bb026ada67c7de Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 26 Jun 2013 21:35:36 +0200 Subject: [PATCH] Create a clipping frustum, ref #43 --- code/nel/include/nel/3d/stereo_ovr.h | 3 +++ code/nel/src/3d/stereo_ovr.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/code/nel/include/nel/3d/stereo_ovr.h b/code/nel/include/nel/3d/stereo_ovr.h index 552995457..ba8d6eac6 100644 --- a/code/nel/include/nel/3d/stereo_ovr.h +++ b/code/nel/include/nel/3d/stereo_ovr.h @@ -91,6 +91,8 @@ public: virtual void getScreenResolution(uint &width, uint &height); /// Set latest camera position etcetera virtual void updateCamera(uint cid, const NL3D::UCamera *camera); + /// Get the frustum to use for clipping + virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const; /// Is there a next pass virtual bool nextPass(); @@ -143,6 +145,7 @@ private: int m_Stage; CViewport m_LeftViewport; CViewport m_RightViewport; + CFrustum m_ClippingFrustum[NL_STEREO_MAX_USER_CAMERAS]; CFrustum m_LeftFrustum[NL_STEREO_MAX_USER_CAMERAS]; CFrustum m_RightFrustum[NL_STEREO_MAX_USER_CAMERAS]; CMatrix m_CameraMatrix[NL_STEREO_MAX_USER_CAMERAS]; diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index 4b2417571..f6c063de4 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -219,6 +219,17 @@ void CStereoOVR::initCamera(uint cid, const NL3D::UCamera *camera) m_LeftFrustum[cid].Right += projectionCenterOffset; m_RightFrustum[cid].Left -= projectionCenterOffset; m_RightFrustum[cid].Right -= projectionCenterOffset; + + // TODO: Clipping frustum should also take into account the IPD + m_ClippingFrustum[cid] = m_LeftFrustum[cid]; + m_ClippingFrustum[cid].Left = min(m_LeftFrustum[cid].Left, m_RightFrustum[cid].Left); + m_ClippingFrustum[cid].Right = max(m_LeftFrustum[cid].Right, m_RightFrustum[cid].Right); +} + +/// Get the frustum to use for clipping +void CStereoOVR::getClippingFrustum(uint cid, NL3D::UCamera *camera) const +{ + camera->setFrustum(m_ClippingFrustum[cid]); } void CStereoOVR::updateCamera(uint cid, const NL3D::UCamera *camera)