Convert Oculus code to use SDK 0.4.4
[libs/vr.git] / source / oculusriftcamera.cpp
index 2a8af2b020c345a0e8b4f9b172edfc13a457c4b6..8b98adb25fcd520b06450c2cfba3e806f8d3abd2 100644 (file)
@@ -1,5 +1,4 @@
 #include "oculusriftcamera.h"
-#include "oculusriftcamera_private.h"
 #include "oculusriftdevice.h"
 #include "oculusriftdevice_private.h"
 
@@ -8,23 +7,23 @@ namespace VR {
 
 OculusRiftCamera::OculusRiftCamera(const OculusRiftDevice &d, const GL::Camera &c):
        device(d),
-       base_camera(c),
-       priv(new Private)
+       base_camera(c)
 {
        const OculusRiftDevice::Private &dev_priv = device.get_private();
-       priv->ovr_sensor = dev_priv.ovr_hmd->GetSensor();
-       priv->fusion.AttachToSensor(priv->ovr_sensor);
+       unsigned supported = ovrTrackingCap_Orientation|ovrTrackingCap_MagYawCorrection;
+       ovrHmd_ConfigureTracking(dev_priv.ovr_hmd, supported, 0);
 }
 
 OculusRiftCamera::~OculusRiftCamera()
 {
-       delete priv;
 }
 
 void OculusRiftCamera::update()
 {
-       OVR::Matrix4f sensor_matrix = priv->fusion.GetOrientation();
-       const float *m = &sensor_matrix.M[0][0];
+       ovrTrackingState state = ovrHmd_GetTrackingState(device.get_private().ovr_hmd, ovr_GetTimeInSeconds());
+       OVR::Posef head_pose = state.HeadPose.ThePose;
+       OVR::Matrix4f tracking_matrix(head_pose.Rotation);
+       const float *m = &tracking_matrix.M[0][0];
 
        const GL::Vector3 &base_look = base_camera.get_look_direction();
        GL::Vector3 base_right = normalize(cross(base_look, base_camera.get_up_direction()));