Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. extern "C"
  2. {
  3.   #include "../include/ovr_freepie.h"
  4. }
  5. #include <OVR.h>
  6.  
  7. using namespace OVR;
  8.  
  9. ovrHmd  HMD;
  10. double  HmdFrameTiming;
  11.  
  12. int ovr_freepie_init()
  13. {
  14.     ovrResult result = ovr_Initialize(nullptr);
  15.     if (!OVR_SUCCESS(result)) return 1;
  16.  
  17.     ovrGraphicsLuid luid;
  18.     result = ovr_Create(&HMD, &luid);
  19.  
  20.     if (!HMD) {
  21.         return 1;
  22.     }
  23.  
  24.     ovr_ConfigureTracking(HMD, ovrTrackingCap_Orientation |
  25.         ovrTrackingCap_MagYawCorrection |
  26.         ovrTrackingCap_Position, 0);
  27.  
  28.     return 0;
  29. }
  30.  
  31. int ovr_freepie_reset_orientation()
  32. {
  33.     ovr_RecenterPose(HMD);
  34.     return 0;
  35. }
  36.  
  37. int ovr_freepie_read(ovr_freepie_6dof *output)
  38. {
  39.     HmdFrameTiming = ovr_GetPredictedDisplayTime(HMD, 0);
  40.     ovrTrackingState ts = ovr_GetTrackingState(HMD, ovr_GetTimeInSeconds(), HmdFrameTiming);
  41.     Posef pose = ts.HeadPose.ThePose;
  42.    
  43.     pose.Rotation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&output->yaw, &output->pitch, &output->roll);
  44.     output->x = pose.Translation.x;
  45.     output->y = pose.Translation.y;
  46.     output->z = pose.Translation.z;
  47.  
  48.     return 0;
  49. }
  50.  
  51. int ovr_freepie_destroy()
  52. {
  53.     ovr_Destroy(HMD);
  54.     ovr_Shutdown();
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement