summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-22 10:15:17 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-23 11:05:33 +0200
commit81310e18abba8d17289cde6670e62d96f24e9d01 (patch)
treecee6e1713f84b12a89669eaa1781248e16c3131e
parent46f89ce2321909198774a1c1e8b481436540c11a (diff)
gui/options, logic: add experimental offset from center
This works fine for rotating the translation.
-rw-r--r--gui/options-dialog.cpp1
-rw-r--r--gui/settings.ui195
-rw-r--r--opentrack-logic/main-settings.hpp2
-rw-r--r--opentrack-logic/tracker.cpp7
4 files changed, 158 insertions, 47 deletions
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index fb0b3454..3b54ae9a 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -68,6 +68,7 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) :
tie_setting(main.camera_yaw, ui.camera_yaw);
tie_setting(main.camera_pitch, ui.camera_pitch);
tie_setting(main.camera_roll, ui.camera_roll);
+ tie_setting(main.use_camera_offset_from_centering, ui.use_center_as_translation_camera_offset);
tie_setting(main.center_method, ui.center_method);
diff --git a/gui/settings.ui b/gui/settings.ui
index 4c166a08..45541d45 100644
--- a/gui/settings.ui
+++ b/gui/settings.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>384</width>
- <height>639</height>
+ <width>480</width>
+ <height>625</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,12 +24,24 @@
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
+ <item alignment="Qt::AlignTop">
<widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<attribute name="title">
<string>Shortcuts</string>
</attribute>
@@ -279,46 +291,6 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="groupBox_9">
- <property name="title">
- <string>Centering method</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
- <widget class="QLabel" name="label_26">
- <property name="text">
- <string>Method</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="center_method">
- <item>
- <property name="text">
- <string>Relative (inertial device)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Absolute (camera device)</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="label_25">
- <property name="text">
- <string>Try changing this if centering doesn't perform correctly for your input device.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<widget class="QCheckBox" name="center_at_startup">
<property name="text">
<string>Center at startup</string>
@@ -332,13 +304,29 @@
</property>
</widget>
</item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Camera</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
@@ -364,6 +352,26 @@
</property>
</widget>
</item>
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="use_center_as_translation_camera_offset">
+ <property name="text">
+ <string>Use camera center as translation offset</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_29">
+ <property name="text">
+ <string>This option is experimental. Please report your findings on the github issue tracker.</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item row="3" column="0" alignment="Qt::AlignLeft">
<widget class="QGroupBox" name="groupBox_3">
<property name="styleSheet">
@@ -373,6 +381,12 @@
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <property name="bottomMargin">
+ <number>2</number>
+ </property>
<item row="2" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
@@ -445,6 +459,19 @@
</layout>
</widget>
</item>
+ <item row="4" column="0">
+ <widget class="Line" name="line">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -632,14 +659,69 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_9">
+ <property name="title">
+ <string>Centering method</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_26">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Method</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="center_method">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>3</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>Relative (inertial device)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Absolute (camera device)</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_25">
+ <property name="text">
+ <string>Try changing this if centering doesn't perform correctly for your input device.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>0</height>
</size>
</property>
</spacer>
@@ -1133,10 +1215,13 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>0</height>
</size>
</property>
</spacer>
@@ -1154,7 +1239,7 @@
<string>Game detection</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="1" column="0">
+ <item row="1" column="0" alignment="Qt::AlignTop">
<widget class="process_detector" name="game_detector" native="true"/>
</item>
<item row="0" column="0">
@@ -1176,6 +1261,22 @@
</layout>
</widget>
</item>
+ <item>
+ <spacer name="verticalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</widget>
diff --git a/opentrack-logic/main-settings.hpp b/opentrack-logic/main-settings.hpp
index 1aa0d38c..a7dcd11c 100644
--- a/opentrack-logic/main-settings.hpp
+++ b/opentrack-logic/main-settings.hpp
@@ -67,6 +67,7 @@ struct main_settings
value<bool> tcomp_p, tcomp_tz;
value<bool> tray_enabled;
value<int> camera_yaw, camera_pitch, camera_roll;
+ value<bool> use_camera_offset_from_centering;
value<bool> center_at_startup;
value<int> center_method;
key_opts key_start_tracking, key_stop_tracking, key_toggle_tracking, key_restart_tracking;
@@ -86,6 +87,7 @@ struct main_settings
camera_yaw(b, "camera-yaw", 0),
camera_pitch(b, "camera-pitch", 0),
camera_roll(b, "camera-roll", 0),
+ use_camera_offset_from_centering(b, "use-camera-offset-from-centering", false),
center_at_startup(b, "center-at-startup", true),
center_method(b, "centering-method", true),
key_start_tracking(b, "start-tracking"),
diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp
index 3602ad4e..3596eb19 100644
--- a/opentrack-logic/tracker.cpp
+++ b/opentrack-logic/tracker.cpp
@@ -195,6 +195,13 @@ void Tracker::logic()
const euler_t euler = r2d * rmat_to_euler(m_);
+ euler_t tmp(t(0) - t_b[0], t(1) - t_b[1], t(2) - t_b[2]);
+
+ if (s.use_camera_offset_from_centering)
+ t_compensate(r_b.t() * cam.t(), tmp, tmp, false);
+ else
+ t_compensate(cam.t(), tmp, tmp, false);
+
for (int i = 0; i < 3; i++)
{
value(i) = tmp(i);