Add eye distance in 2D interface shift, re #43

--HG--
branch : multipass-stereo
This commit is contained in:
kaetemi 2013-06-26 17:24:23 +02:00
parent 5423d4d025
commit 4864ce7a5a
3 changed files with 7 additions and 5 deletions

View file

@ -121,8 +121,8 @@ public:
/// Get the HMD orientation /// Get the HMD orientation
virtual NLMISC::CQuat getOrientation() const; virtual NLMISC::CQuat getOrientation() const;
/// Get GUI center (1 = width, 1 = height, 0 = center) (todo: move to CStereoHMD) /// Get GUI center (1 = width, 1 = height, 0 = center)
void getInterface2DShift(float &x, float &y, float distance); virtual void getInterface2DShift(float &x, float &y, float distance);
static void listDevices(std::vector<CStereoDeviceInfo> &devicesOut); static void listDevices(std::vector<CStereoDeviceInfo> &devicesOut);

View file

@ -390,7 +390,7 @@ NLMISC::CQuat CStereoOVR::getOrientation() const
return finalquat; return finalquat;
} }
/// Get GUI shift (todo: move to CStereoHMD) /// Get GUI shift
void CStereoOVR::getInterface2DShift(float &x, float &y, float distance) void CStereoOVR::getInterface2DShift(float &x, float &y, float distance)
{ {
NLMISC::CVector vector = CVector(0.f, -distance, 0.f); NLMISC::CVector vector = CVector(0.f, -distance, 0.f);
@ -398,8 +398,10 @@ void CStereoOVR::getInterface2DShift(float &x, float &y, float distance)
rot.invert(); rot.invert();
NLMISC::CMatrix mat; NLMISC::CMatrix mat;
mat.rotate(rot); 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); mat.translate(vector);
CVector proj = getCurrentFrustum().project(mat.getPos()); CVector proj = CStereoOVR::getCurrentFrustum().project(mat.getPos());
x = proj.x - 0.5f; x = proj.x - 0.5f;
y = proj.y - 0.5f; y = proj.y - 0.5f;
} }

View file

@ -388,7 +388,7 @@ void updateCommands()
if (StereoHMD) if (StereoHMD)
{ {
float xshift, yshift; float xshift, yshift;
StereoHMD->getInterface2DShift(xshift, yshift, 1.0f); StereoHMD->getInterface2DShift(xshift, yshift, 4.0f);
// snap to pixels // snap to pixels
xshift = ((float)(sint32)(xshift * width)) / width; xshift = ((float)(sint32)(xshift * width)) / width;
yshift = ((float)(sint32)(yshift * height)) / height; yshift = ((float)(sint32)(yshift * height)) / height;