]> git.tdb.fi Git - libs/vr.git/commitdiff
Update camera pose as part of the render call
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:49:06 +0000 (02:49 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:49:06 +0000 (02:49 +0300)
source/stereoview.cpp
source/stereoview.h

index 7a72a452c279a31b1e64b663441a8621aefc04a3..5945016da1ac8d1e20d01c0a4e25f0ceb0300954 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/gl/renderer.h>
+#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<float> &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;
index c1421f81422fc9d2034da8ebf0832cf6c0c8dfd7..ff34706cc4b450d1daff8d7844b5147c282ffc5d 100644 (file)
@@ -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<float> &);