diff options
Diffstat (limited to 'tracker-tobii/ftnoir_tracker_tobii.cpp')
-rw-r--r-- | tracker-tobii/ftnoir_tracker_tobii.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tracker-tobii/ftnoir_tracker_tobii.cpp b/tracker-tobii/ftnoir_tracker_tobii.cpp new file mode 100644 index 00000000..f0d66ae4 --- /dev/null +++ b/tracker-tobii/ftnoir_tracker_tobii.cpp @@ -0,0 +1,60 @@ +#include "ftnoir_tracker_tobii.h" +#include "api/plugin-api.hpp" +#include "compat/math.hpp" + +module_status tobii::start_tracker(QFrame*) +{ + t.start(); + return status_ok(); +} + +void tobii::data(double *data) +{ + if (t.head_pose) { + tobii_head_pose_t p = *t.head_pose; + if (p.position_validity == TOBII_VALIDITY_VALID) { + if (center_pose.position_validity == TOBII_VALIDITY_VALID) { + p.position_xyz[0] = p.position_xyz[0] - center_pose.position_xyz[0]; + p.position_xyz[1] = p.position_xyz[1] - center_pose.position_xyz[1]; + p.position_xyz[2] = p.position_xyz[2] - center_pose.position_xyz[2]; + } + data[0] = clamp(p.position_xyz[0] * 30.0 / 300.0, -30.0, 30.0); + data[1] = clamp(p.position_xyz[1] * 30.0 / 300.0, -30.0, 30.0); + data[2] = clamp(p.position_xyz[2] * 30.0 / 300.0, -30.0, 30.0); + } + + double max_yaw = 90.0; + if (p.rotation_validity_xyz[1] == TOBII_VALIDITY_VALID) { + if (center_pose.rotation_validity_xyz[1] == TOBII_VALIDITY_VALID) { + p.rotation_xyz[1] = p.rotation_xyz[1] - center_pose.rotation_xyz[1]; + } + data[3] = clamp(p.rotation_xyz[1] * 100.0 * max_yaw / 90.0, -max_yaw, max_yaw); + } + + double max_pitch = 90.0; + if (p.rotation_validity_xyz[0] == TOBII_VALIDITY_VALID) { + if (center_pose.rotation_validity_xyz[0] == TOBII_VALIDITY_VALID) { + p.rotation_xyz[0] = p.rotation_xyz[0] - center_pose.rotation_xyz[0]; + } + data[4] = clamp(p.rotation_xyz[0] * 100.0 * max_pitch / 90.0, -max_pitch, max_pitch); + } + + double max_roll = 90.0; + if (p.rotation_validity_xyz[2] == TOBII_VALIDITY_VALID) { + if (center_pose.rotation_validity_xyz[2] == TOBII_VALIDITY_VALID) { + p.rotation_xyz[2] = p.rotation_xyz[2] - center_pose.rotation_xyz[2]; + } + data[5] = clamp(p.rotation_xyz[2] * 100.0 * max_roll / 90.0, -max_roll, max_roll); + } + } +} + +bool tobii::center () +{ + if (t.head_pose) { + center_pose = *t.head_pose; + } + return false; +} + +OPENTRACK_DECLARE_TRACKER(tobii, dialog_tobii, tobiiDll) |