From cce8a110e1ede64ef98ec3dba3e5d4f227a0edf4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Dec 2014 17:26:52 +0100 Subject: implement camera offset --- facetracknoir/curve-config.cpp | 3 + facetracknoir/mapping.ui | 827 ++++++++++++++++++++++++----------------- opentrack/main-settings.hpp | 5 +- opentrack/tracker.cpp | 19 +- 4 files changed, 516 insertions(+), 338 deletions(-) diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index db5a4a75..ac34e57a 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -76,6 +76,9 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : tie_setting(s.a_x.src, ui.src_x); tie_setting(s.a_y.src, ui.src_y); tie_setting(s.a_z.src, ui.src_z); + + tie_setting(s.camera_yaw, ui.camera_yaw); + tie_setting(s.camera_pitch, ui.camera_pitch); } void MapWidget::doOK() { diff --git a/facetracknoir/mapping.ui b/facetracknoir/mapping.ui index 9f422b9b..574f320f 100644 --- a/facetracknoir/mapping.ui +++ b/facetracknoir/mapping.ui @@ -7,7 +7,7 @@ 0 0 970 - 655 + 664 @@ -626,350 +626,400 @@ false - + QLayout::SetMinAndMaxSize 6 - - - - X - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Y - - - - - - - Z - - - - - - - Roll - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + Assign input axis to output axis. - - - - - - + + Qt::AlignJustify|Qt::AlignVCenter - - - - - - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - Source + + true - - - - Invert + + + + QFrame::NoFrame - - - - - - Destination + + QFrame::Raised + + + + + + + + + + + + Roll + + + + + + + X + + + + + + + Invert + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + Pitch + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + + + Y + + + + + + + Destination + + + + + + + + + + + + + + Yaw + + + + + + + + + + + + + + Source + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + Z + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + label_15 + label_14 + label_13 + label_15 + label_15 + label_13 + label_14 + src_yaw + invert_yaw + label_7 + src_pitch + label_8 + invert_pitch + label_9 + src_roll + invert_roll + label_10 + src_x + invert_x + label_11 + src_y + invert_y + label_12 + src_z + invert_z @@ -993,7 +1043,7 @@ true - + @@ -1009,7 +1059,7 @@ - + @@ -1019,6 +1069,117 @@ + + + + With compensation on, translation is applied after rotation. For example, rotating +180 degrees yaw and moving backwards results in moving forward as a result of that rotation. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + Camera offset + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + 0 + 0 + + + + Yaw + + + + + + + + 0 + 0 + + + + -90 + + + 90 + + + + + + + + 0 + 0 + + + + Pitch + + + + + + + + 0 + 0 + + + + -90 + + + 90 + + + + + + + + + + Specify an angle for off-center camera as a basis for which direction is which, avoiding axis interconnect. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index 2c909d27..def21f31 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -28,6 +28,7 @@ struct main_settings { axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; value tcomp_p, tcomp_tz; value tray_enabled; + value camera_yaw, camera_pitch; main_settings(pbundle b) : b(b), tracker_dll(b, "tracker-dll", ""), @@ -42,6 +43,8 @@ struct main_settings { a_roll(b, "roll", Roll), tcomp_p(b, "compensate-translation", true), tcomp_tz(b, "compensate-translation-disable-z-axis", false), - tray_enabled(b, "use-system-tray", false) + tray_enabled(b, "use-system-tray", false), + camera_yaw(b, "camera-yaw", 0), + camera_pitch(b, "camera-pitch", 0) {} }; diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index f621083b..60ed4c33 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -94,22 +94,33 @@ void Tracker::logic() raw(i) = value(i) = t_b[i]; } } + + const double off[] = { + s.camera_yaw, + s.camera_pitch, + 0. + }; + const rmat cam = rmat::euler_to_rmat(off); + rmat r = rmat::euler_to_rmat(&value[Yaw]); + dmat<3, 1> t { value(0), value(1), value(3) }; + + r = cam * r; + t = cam * t; if (centerp) { centerp = false; for (int i = 0; i < 3; i++) - t_b[i] = value(i); - r_b = rmat::euler_to_rmat(&value[Yaw]); + t_b[i] = t(i, 0); + r_b = r; } { - const rmat r = rmat::euler_to_rmat(&value[Yaw]); const rmat m_ = r * r_b.t(); const dmat<3, 1> euler = rmat::rmat_to_euler(m_); for (int i = 0; i < 3; i++) { - value(i) -= t_b[i]; + value(i) = t(i, 0) - t_b[i]; value(i+3) = euler(i, 0) * r2d; } } -- cgit v1.2.3