summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.cpp13
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
index 0c3984ac..e58dbf1b 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
@@ -6,6 +6,9 @@
using namespace OVR;
+//used to turn on the re-centre spring effect
+#define RECENTRE_SPRING
+
Rift_Tracker::Rift_Tracker()
{
pSensor.Clear();
@@ -14,6 +17,7 @@ Rift_Tracker::Rift_Tracker()
bEnableRoll = true;
bEnablePitch = true;
bEnableYaw = true;
+ old_yaw = 0.0;
#if 0
bEnableX = true;
bEnableY = true;
@@ -100,7 +104,14 @@ bool Rift_Tracker::GiveHeadPoseData(double *data)
float pitch = 0.0f;
float roll = 0.0f;
hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch , &roll);
- newHeadPose[Yaw] = yaw;
+#ifdef RECENTRE_SPRING
+ newHeadPose[Yaw] = newHeadPose[Yaw]*0.99999 + (yaw-old_yaw);
+ if(newHeadPose[Yaw]>0.02)newHeadPose[Yaw]-= 0.000005;
+ if(newHeadPose[Yaw]<-0.02)newHeadPose[Yaw]+= 0.000005;
+ old_yaw=yaw;
+#else
+ newHeadPose[Yaw] = yaw;
+#endif
newHeadPose[Pitch] =pitch;
newHeadPose[Roll] = roll;
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
index 7bacb91c..579d7d34 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
@@ -30,7 +30,7 @@ private:
// Magnetometer calibration and yaw correction
OVR::Util::MagCalibration MagCal;
bool isCalibrated;
-
+ double old_yaw;
double newHeadPose[6]; // Structure with new headpose
bool bEnableRoll;
bool bEnablePitch;