From: Mikko Rasa Date: Fri, 16 Sep 2016 23:49:06 +0000 (+0300) Subject: Update camera pose as part of the render call X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=735148a3ecf7e753f520f22668b771583185f72f;p=libs%2Fvr.git Update camera pose as part of the render call --- diff --git a/source/stereoview.cpp b/source/stereoview.cpp index 7a72a45..5945016 100644 --- a/source/stereoview.cpp +++ b/source/stereoview.cpp @@ -1,4 +1,5 @@ #include +#include "headtrackingcamera.h" #include "stereocombiner.h" #include "stereoview.h" @@ -10,8 +11,23 @@ namespace VR { StereoView::StereoView(const StereoCombiner &c, const GL::Camera &a): combiner(c), base_camera(a), - content(0) + head_camera(0) { + init(); +} + +StereoView::StereoView(const StereoCombiner &c, HeadTrackingCamera &a): + combiner(c), + base_camera(a), + head_camera(&a) +{ + init(); +} + +void StereoView::init() +{ + content = 0; + unsigned w = combiner.get_target_width(); unsigned h = combiner.get_target_height(); left.create_target(w, h); @@ -38,6 +54,9 @@ void StereoView::set_strabismus(const Geometry::Angle &s) void StereoView::setup_frame() const { + if(head_camera) + head_camera->update(); + GL::Vector3 offset_axis = normalize(cross(base_camera.get_look_direction(), base_camera.get_up_direction()))*0.5f; EyeParams params; diff --git a/source/stereoview.h b/source/stereoview.h index c1421f8..ff34706 100644 --- a/source/stereoview.h +++ b/source/stereoview.h @@ -11,6 +11,7 @@ namespace Msp { namespace VR { +class HeadTrackingCamera; class StereoCombiner; class StereoView @@ -47,6 +48,7 @@ private: const StereoCombiner &combiner; const GL::Camera &base_camera; + HeadTrackingCamera *head_camera; const GL::Renderable *content; Eye left; Eye right; @@ -55,7 +57,11 @@ private: public: StereoView(const StereoCombiner &, const GL::Camera &); + StereoView(const StereoCombiner &, HeadTrackingCamera &); +private: + void init(); +public: void set_content(const GL::Renderable *); void set_eye_spacing(float); void set_strabismus(const Geometry::Angle &);