From 932308a72ce197108007681dcc94dd8015a683f5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 23 Dec 2014 01:18:53 +0200 Subject: [PATCH] Add strabismus correction This used to be sort of possible in the previous implementation of OculusRiftCombiner, but this way works for all combiners. --- source/stereoview.cpp | 8 ++++++++ source/stereoview.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/source/stereoview.cpp b/source/stereoview.cpp index 4586f29..95eb847 100644 --- a/source/stereoview.cpp +++ b/source/stereoview.cpp @@ -16,6 +16,7 @@ StereoView::StereoView(unsigned w, unsigned h, const GL::Camera &c, const GL::Re { set_combiner(m); set_eye_spacing(0.064); + set_strabismus(Geometry::Angle::zero()); } void StereoView::set_combiner(const StereoCombiner &c) @@ -33,6 +34,11 @@ void StereoView::set_eye_spacing(float s) eye_spacing = s; } +void StereoView::set_strabismus(const Geometry::Angle &s) +{ + strabismus = s; +} + void StereoView::setup_frame() const { offset_axis = normalize(cross(base_camera.get_look_direction(), base_camera.get_up_direction()))*0.5f; @@ -47,6 +53,8 @@ void StereoView::setup_frame() const params.far_clip = base_camera.get_far_clip(); float frustum_skew = combiner->get_frustum_skew(); + float halfw = tan(params.fov/2.0f)*params.aspect; + frustum_skew = tan(Geometry::atan(frustum_skew*halfw)+strabismus)/halfw; left.setup_frame(base_camera, offset_axis*-eye_spacing, frustum_skew, params); right.setup_frame(base_camera, offset_axis*eye_spacing, -frustum_skew, params); diff --git a/source/stereoview.h b/source/stereoview.h index 5516823..b1e0473 100644 --- a/source/stereoview.h +++ b/source/stereoview.h @@ -53,6 +53,7 @@ private: Eye left; Eye right; float eye_spacing; + Geometry::Angle strabismus; mutable GL::Vector3 offset_axis; public: @@ -60,6 +61,7 @@ public: void set_combiner(const StereoCombiner &); void set_eye_spacing(float); + void set_strabismus(const Geometry::Angle &); virtual void setup_frame() const; virtual void finish_frame() const; -- 2.45.2