summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_rift
diff options
context:
space:
mode:
authormm0zct <the_cartographer@hotmail.com>2013-10-05 11:14:46 +0100
committermm0zct <the_cartographer@hotmail.com>2013-10-05 11:14:46 +0100
commite5f1e165616bd1dfcfbdf8fd19228fee2a657bc9 (patch)
tree1f792b8b9b2480a0ef0b4444c75a7b3b57b0cfdc /ftnoir_tracker_rift
parentee843add4063931d8a0331eba3d60c8a579d0661 (diff)
added a re-centre spring effect, optional compiler preprocessor, enabled by default
Diffstat (limited to 'ftnoir_tracker_rift')
-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;