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

This commit is contained in:
kaetemi 2013-06-26 17:24:23 +02:00
parent 1b8ddaa87b
commit 8230238b5f
3 changed files with 7 additions and 5 deletions

View file

@ -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<CStereoDeviceInfo> &devicesOut);

View file

@ -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;
}

View file

@ -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;