diff options
-rw-r--r-- | tracker-hydra/ftnoir_tracker_hydra.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/tracker-hydra/ftnoir_tracker_hydra.cpp b/tracker-hydra/ftnoir_tracker_hydra.cpp index 8d0e6832..1e3c1189 100644 --- a/tracker-hydra/ftnoir_tracker_hydra.cpp +++ b/tracker-hydra/ftnoir_tracker_hydra.cpp @@ -2,45 +2,50 @@ #include "ftnoir_tracker_hydra.h" #include "opentrack/plugin-api.hpp" #include <cstdio> +#include <cmath> #ifdef _WIN32 # define SIXENSE_STATIC_LIB # define SIXENSE_UTILS_STATIC_LIB #endif #include <sixense.h> +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + Hydra_Tracker::Hydra_Tracker() : should_quit(false) {} #include <sixense_math.hpp> Hydra_Tracker::~Hydra_Tracker() { - - sixenseExit(); + + sixenseExit(); } void Hydra_Tracker::start_tracker(QFrame*) { - sixenseInit(); + sixenseInit(); } void Hydra_Tracker::data(double *data) { - - sixenseSetActiveBase(0); - sixenseAllControllerData acd; - sixenseGetAllNewestData( &acd ); + + sixenseSetActiveBase(0); + sixenseAllControllerData acd; + sixenseGetAllNewestData( &acd ); sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat); - float ypr[3]; - - mat.getEulerAngles().fill(ypr); - data[TX] = acd.controllers[0].pos[0]/50.0; - data[TY] = acd.controllers[0].pos[1]/50.0; - data[TZ] = acd.controllers[0].pos[2]/50.0; - static constexpr double r2d = 57.295781; - data[Yaw] = ypr[0] * r2d; - data[Pitch] = ypr[1] * r2d; - data[Roll] = ypr[2] * r2d; + float ypr[3]; + + mat.getEulerAngles().fill(ypr); + data[TX] = double(acd.controllers[0].pos[0])/50; + data[TY] = double(acd.controllers[0].pos[1])/50; + data[TZ] = double(acd.controllers[0].pos[2])/50; + static constexpr double r2d = 180/M_PI; + data[Yaw] = double(ypr[0]) * r2d; + data[Pitch] = double(ypr[1]) * r2d; + data[Roll] = double(ypr[2]) * r2d; } OPENTRACK_DECLARE_TRACKER(Hydra_Tracker, TrackerControls, FTNoIR_TrackerDll) |