]> git.tdb.fi Git - libs/vr.git/commitdiff
Store the base matrix of HeadTrackingCamera and provice access to it
authorMikko Rasa <tdb@tdb.fi>
Wed, 5 Oct 2016 23:32:53 +0000 (02:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 5 Oct 2016 23:32:53 +0000 (02:32 +0300)
It will be useful for positioning other tracked devices.

source/headtrackingcamera.cpp
source/headtrackingcamera.h

index 86d6e24427d1ad2d1b08f9974be5a9b54ac16af8..9f4dd5c16768471c33e1a926f205021df50a3224 100644 (file)
@@ -21,10 +21,12 @@ void HeadTrackingCamera::update_from_matrix(const GL::Matrix &hmd_matrix)
        columns[0] = compose(right, 0.0f);
        columns[1] = compose(up, 0.0f);
        columns[2] = compose(cross(right, up), 0.0f);
-       columns[3] = compose(base_camera.get_position(), 1.0f);
-       GL::Matrix matrix = GL::Matrix::from_columns(columns)*hmd_matrix;
+       columns[3] = compose(base_camera.get_position()+base_camera.get_up_direction()*elevation_offset, 1.0f);
+       base_matrix = GL::Matrix::from_columns(columns);
 
-       set_position(matrix*GL::Vector3()+base_camera.get_up_direction()*elevation_offset);
+       GL::Matrix matrix = base_matrix*hmd_matrix;
+
+       set_position(matrix*GL::Vector3());
        set_look_direction((matrix*GL::Vector4(0, 0, -1, 0)).slice<3>(0));
        set_up_direction((matrix*GL::Vector4(0, 1, 0, 0)).slice<3>(0));
 
index c2001365f4eaa249d6bb46b77643a8e231647274..a10c1e1e65099335590ab839eb81d14406b842f2 100644 (file)
@@ -10,12 +10,15 @@ class HeadTrackingCamera: public Msp::GL::Camera
 {
 protected:
        const GL::Camera &base_camera;
+       GL::Matrix base_matrix;
        float elevation_offset;
 
        HeadTrackingCamera(const GL::Camera &);
 public:
        virtual ~HeadTrackingCamera() { }
 
+       const GL::Matrix &get_base_matrix() const { return base_matrix; }
+
        void set_elevation_offset(float);
        virtual void reset_tracking() { }
        virtual void update() = 0;