From 8230238b5f16db76ac616625df528210cdf73b52 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 26 Jun 2013 17:24:23 +0200 Subject: [PATCH] Add eye distance in 2D interface shift, re #43 --- code/nel/include/nel/3d/stereo_ovr.h | 4 ++-- code/nel/src/3d/stereo_ovr.cpp | 6 ++++-- code/snowballs2/client/src/commands.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/3d/stereo_ovr.h b/code/nel/include/nel/3d/stereo_ovr.h index cd466a7aa..bb85438ad 100644 --- a/code/nel/include/nel/3d/stereo_ovr.h +++ b/code/nel/include/nel/3d/stereo_ovr.h @@ -121,8 +121,8 @@ public: /// Get the HMD orientation virtual NLMISC::CQuat getOrientation() const; - /// Get GUI center (1 = width, 1 = height, 0 = center) (todo: move to CStereoHMD) - void getInterface2DShift(float &x, float &y, float distance); + /// Get GUI center (1 = width, 1 = height, 0 = center) + virtual void getInterface2DShift(float &x, float &y, float distance); static void listDevices(std::vector &devicesOut); diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index 09e079f81..cba1c004f 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -390,7 +390,7 @@ NLMISC::CQuat CStereoOVR::getOrientation() const return finalquat; } -/// Get GUI shift (todo: move to CStereoHMD) +/// Get GUI shift void CStereoOVR::getInterface2DShift(float &x, float &y, float distance) { NLMISC::CVector vector = CVector(0.f, -distance, 0.f); @@ -398,8 +398,10 @@ void CStereoOVR::getInterface2DShift(float &x, float &y, float distance) rot.invert(); NLMISC::CMatrix mat; mat.rotate(rot); + if (m_Stage % 2) mat.translate(CVector(m_DevicePtr->HMDInfo.InterpupillaryDistance * -0.5f, 0.f, 0.f)); + else mat.translate(CVector(m_DevicePtr->HMDInfo.InterpupillaryDistance * 0.5f, 0.f, 0.f)); mat.translate(vector); - CVector proj = getCurrentFrustum().project(mat.getPos()); + CVector proj = CStereoOVR::getCurrentFrustum().project(mat.getPos()); x = proj.x - 0.5f; y = proj.y - 0.5f; } diff --git a/code/snowballs2/client/src/commands.cpp b/code/snowballs2/client/src/commands.cpp index 795371cb6..4a36db8bb 100644 --- a/code/snowballs2/client/src/commands.cpp +++ b/code/snowballs2/client/src/commands.cpp @@ -388,7 +388,7 @@ void updateCommands() if (StereoHMD) { float xshift, yshift; - StereoHMD->getInterface2DShift(xshift, yshift, 1.0f); + StereoHMD->getInterface2DShift(xshift, yshift, 4.0f); // snap to pixels xshift = ((float)(sint32)(xshift * width)) / width; yshift = ((float)(sint32)(yshift * height)) / height;