From 851116d818ddd01d5935c1bba10fe4900771d980 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 2 Oct 2015 15:29:03 +0200 Subject: main: add relative and absolute center options Closes #237 --- facetracknoir/options-dialog.cpp | 2 ++ facetracknoir/settings.ui | 40 ++++++++++++++++++++++++++++++++++++++++ opentrack/main-settings.hpp | 4 +++- opentrack/tracker.cpp | 39 +++++++++++++++++++-------------------- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/facetracknoir/options-dialog.cpp b/facetracknoir/options-dialog.cpp index 1ec26d5e..fef2b0ca 100644 --- a/facetracknoir/options-dialog.cpp +++ b/facetracknoir/options-dialog.cpp @@ -50,6 +50,8 @@ OptionsDialog::OptionsDialog() tie_setting(s.s_main.camera_pitch, ui.camera_pitch); tie_setting(s.s_main.camera_roll, ui.camera_roll); + tie_setting(s.s_main.center_method, ui.center_method); + connect(ui.bind_center, &QPushButton::pressed, [&]() -> void { bind_key(s.center.keycode, ui.center_text); }); connect(ui.bind_zero, &QPushButton::pressed, [&]() -> void { bind_key(s.zero.keycode, ui.zero_text); }); connect(ui.bind_toggle, &QPushButton::pressed, [&]() -> void { bind_key(s.toggle.keycode, ui.toggle_text); }); diff --git a/facetracknoir/settings.ui b/facetracknoir/settings.ui index 5eea9e57..d87b68bf 100644 --- a/facetracknoir/settings.ui +++ b/facetracknoir/settings.ui @@ -140,6 +140,46 @@ + + + + Centering method + + + + + + Method + + + + + + + + Relative + + + + + Absolute + + + + + + + + Try changing this if centering doesn't perform correctly for your input device. + + + true + + + + + + diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index b973e7af..d1fe574d 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -39,6 +39,7 @@ struct main_settings : opts { value tray_enabled; value camera_yaw, camera_pitch, camera_roll; value center_at_startup; + value center_method; main_settings() : opts("opentrack-ui"), tracker_dll(b, "tracker-dll", ""), @@ -56,6 +57,7 @@ struct main_settings : opts { camera_yaw(b, "camera-yaw", 0), camera_pitch(b, "camera-pitch", 0), camera_roll(b, "camera-roll", 0), - center_at_startup(b, "center-at-startup", true) + center_at_startup(b, "center-at-startup", true), + center_method(b, "centering-method", false) {} }; diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index 3d88a962..8fd054b4 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -78,26 +78,15 @@ void Tracker::logic() Pose value, raw; - if (!zero_) - for (int i = 0; i < 6; i++) - { - auto& axis = m(i); - int k = axis.opts.src; - if (k < 0 || k >= 6) - value(i) = 0; - else - value(i) = newpose[k]; - raw(i) = newpose[i]; - } - else + for (int i = 0; i < 6; i++) { - auto mat = rmat::rmat_to_euler(r_b); - - for (int i = 0; i < 3; i++) - { - raw(i+3) = value(i+3) = mat(i) * r2d; - raw(i) = value(i) = t_b[i]; - } + auto& axis = m(i); + int k = axis.opts.src; + if (k < 0 || k >= 6) + value(i) = 0; + else + value(i) = newpose[k]; + raw(i) = newpose[i]; } const double off[] = { @@ -134,7 +123,17 @@ void Tracker::logic() { double tmp[3] = { t(0) - t_b[0], t(1) - t_b[1], t(2) - t_b[2] }; t_compensate(cam, tmp, tmp, false); - const rmat m_ = r * r_b.t(); + rmat m_; + switch (s.center_method) + { + case 0: + default: + m_ = r * r_b.t(); + break; + case 1: + m_ = r_b.t() * r; + } + const dmat<3, 1> euler = rmat::rmat_to_euler(m_); for (int i = 0; i < 3; i++) { -- cgit v1.2.3