namespace VR {
HeadTrackingCamera::HeadTrackingCamera(const GL::Camera &c):
- base_camera(c)
+ base_camera(c),
+ elevation_offset(0)
{ }
+void HeadTrackingCamera::set_elevation_offset(float o)
+{
+ elevation_offset = o;
+}
+
void HeadTrackingCamera::update_from_matrix(const GL::Matrix &hmd_matrix)
{
GL::Matrix matrix = base_camera.get_object_matrix()*hmd_matrix;
- set_position(matrix*GL::Vector3());
+ set_position(matrix*GL::Vector3()+base_camera.get_up_direction()*elevation_offset);
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));
{
protected:
const GL::Camera &base_camera;
+ float elevation_offset;
HeadTrackingCamera(const GL::Camera &);
public:
virtual ~HeadTrackingCamera() { }
+ void set_elevation_offset(float);
virtual void reset_tracking() { }
virtual void update() = 0;
protected:
view.set_eye_matrices(GL::Matrix::translation(GL::Vector3(l.x, l.y, l.z)), GL::Matrix::translation(GL::Vector3(r.x, r.y, r.z)));
}
+void LibOVRSystem::set_absolute_tracking(bool a)
+{
+ if(a)
+ throw invalid_argument("absolute tracking not supported");
+}
+
LibOVRCamera *LibOVRSystem::create_camera(const GL::Camera &bc)
{
return new LibOVRCamera(*this, bc);
virtual void configure_window(Graphics::Window &) const;
virtual void configure_view(StereoView &) const;
+ virtual void set_absolute_tracking(bool);
virtual LibOVRCamera *create_camera(const GL::Camera &);
virtual LibOVRCombiner *create_combiner(GL::View &);
view.set_eye_matrices(convert_matrix(left), convert_matrix(right));
}
+void OpenVRSystem::set_absolute_tracking(bool a)
+{
+ vr::VRCompositor()->SetTrackingSpace(a ? vr::TrackingUniverseStanding : vr::TrackingUniverseSeated);
+}
+
OpenVRCamera *OpenVRSystem::create_camera(const GL::Camera &bc)
{
return new OpenVRCamera(*this, bc);
virtual void configure_window(Graphics::Window &) const { }
virtual void configure_view(StereoView &) const;
+ virtual void set_absolute_tracking(bool);
virtual OpenVRCamera *create_camera(const GL::Camera &);
virtual OpenVRCombiner *create_combiner(GL::View &);
virtual void configure_window(Graphics::Window &) const = 0;
virtual void configure_view(StereoView &) const = 0;
+ virtual void set_absolute_tracking(bool) = 0;
virtual HeadTrackingCamera *create_camera(const GL::Camera &) = 0;
virtual StereoCombiner *create_combiner(GL::View &) = 0;
};