mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
Implement vr_swap_eyes CVAR, now that side-by-side mode is mostly working.
This commit is contained in:
parent
a1cbd39f3f
commit
2e8d2ed626
4 changed files with 18 additions and 8 deletions
|
@ -58,7 +58,6 @@ public:
|
||||||
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
||||||
virtual void SetUp() const {};
|
virtual void SetUp() const {};
|
||||||
virtual void TearDown() const {};
|
virtual void TearDown() const {};
|
||||||
// virtual void EndDrawScene(sector_t * viewsector) const {GLRenderer->EndDrawScene(viewsector);};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
// Set up 3D-specific console variables:
|
// Set up 3D-specific console variables:
|
||||||
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG)
|
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
|
// switch left and right eye views
|
||||||
|
CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode.
|
// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode.
|
||||||
// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo,
|
// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo,
|
||||||
// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo
|
// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
EXTERN_CVAR(Float, vr_screendist)
|
EXTERN_CVAR(Float, vr_screendist)
|
||||||
EXTERN_CVAR(Float, vr_hunits_per_meter)
|
EXTERN_CVAR(Float, vr_hunits_per_meter)
|
||||||
|
EXTERN_CVAR(Bool, vr_swap_eyes)
|
||||||
|
|
||||||
namespace s3d {
|
namespace s3d {
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa
|
||||||
// For stereo 3D, use asymmetric frustum shift in projection matrix
|
// For stereo 3D, use asymmetric frustum shift in projection matrix
|
||||||
// Q: shouldn't shift vary with roll angle, at least for desktop display?
|
// Q: shouldn't shift vary with roll angle, at least for desktop display?
|
||||||
// A: No. (lab) roll is not measured on desktop display (yet)
|
// A: No. (lab) roll is not measured on desktop display (yet)
|
||||||
double frustumShift = zNear * shift / vr_screendist; // meters cancel, leaving doom units
|
double frustumShift = zNear * getShift() / vr_screendist; // meters cancel, leaving doom units
|
||||||
// double frustumShift = 0; // Turning off shift for debugging
|
// double frustumShift = 0; // Turning off shift for debugging
|
||||||
double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio;
|
double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio;
|
||||||
double fW = fH * aspectRatio;
|
double fW = fH * aspectRatio;
|
||||||
|
@ -68,13 +69,17 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa
|
||||||
/* virtual */
|
/* virtual */
|
||||||
void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const
|
void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const
|
||||||
{
|
{
|
||||||
float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift;
|
float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
|
||||||
float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift;
|
float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
|
||||||
outViewShift[0] = dx;
|
outViewShift[0] = dx;
|
||||||
outViewShift[1] = dy;
|
outViewShift[1] = dy;
|
||||||
outViewShift[2] = 0;
|
outViewShift[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ShiftedEyePose::getShift() const
|
||||||
|
{
|
||||||
|
return vr_swap_eyes ? -shift : shift;
|
||||||
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
const LeftEyeView& LeftEyeView::getInstance(float ipd)
|
const LeftEyeView& LeftEyeView::getInstance(float ipd)
|
||||||
|
|
|
@ -37,11 +37,14 @@ class ShiftedEyePose : public EyePose
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShiftedEyePose(float shift) : shift(shift) {};
|
ShiftedEyePose(float shift) : shift(shift) {};
|
||||||
float getShift() const { return shift; }
|
float getShift() const;
|
||||||
void setShift(float shift) { this->shift = shift; }
|
|
||||||
virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
|
virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
|
||||||
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void setShift(float shift) { this->shift = shift; }
|
||||||
|
|
||||||
|
private:
|
||||||
float shift;
|
float shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ class LeftEyePose : public ShiftedEyePose
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {}
|
LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {}
|
||||||
float getIpd() const { return float(-2.0)*getShift(); }
|
float getIpd() const { return float(fabs(2.0f*getShift())); }
|
||||||
void setIpd(float ipd) { setShift(float(-0.5)*ipd); }
|
void setIpd(float ipd) { setShift(float(-0.5)*ipd); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +62,7 @@ class RightEyePose : public ShiftedEyePose
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {}
|
RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {}
|
||||||
float getIpd() const { return float(+2.0)*shift; }
|
float getIpd() const { return float(fabs(2.0f*getShift())); }
|
||||||
void setIpd(float ipd) { setShift(float(+0.5)*ipd); }
|
void setIpd(float ipd) { setShift(float(+0.5)*ipd); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue