mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:36:30 +02:00
improving the ui
This commit is contained in:
parent
a1782bf7d2
commit
07102cc98d
3 changed files with 222 additions and 165 deletions
|
@ -35,8 +35,21 @@ Rectangle {
|
||||||
readonly property bool handController: handBox.checked
|
readonly property bool handController: handBox.checked
|
||||||
readonly property bool handPuck: handPuckBox.checked
|
readonly property bool handPuck: handPuckBox.checked
|
||||||
|
|
||||||
|
property int state: buttonState.disabled
|
||||||
|
property var lastConfiguration: null
|
||||||
|
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: buttonState
|
||||||
|
readonly property int disabled: 0
|
||||||
|
readonly property int apply: 1
|
||||||
|
readonly property int applyAndCalibrate: 2
|
||||||
|
readonly property int calibrate: 3
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
|
@ -66,7 +79,7 @@ Rectangle {
|
||||||
anchors.top: head.bottom
|
anchors.top: head.bottom
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -81,7 +94,7 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +116,7 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +125,35 @@ Rectangle {
|
||||||
text: "Tracker"
|
text: "Tracker"
|
||||||
color: hifi.colors.lightGrayText
|
color: hifi.colors.lightGrayText
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
HifiControls.SpinBox {
|
||||||
|
id: headYOffset
|
||||||
|
decimals: 4
|
||||||
|
width: 110
|
||||||
|
label: "Y: offset"
|
||||||
|
value: -0.0254
|
||||||
|
stepSize: 0.0254
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HifiControls.SpinBox {
|
||||||
|
id: headZOffset
|
||||||
|
width: 105
|
||||||
|
label: "Z: offset"
|
||||||
|
value: -0.152
|
||||||
|
stepSize: 0.0254
|
||||||
|
decimals: 4
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
id: hands
|
id: hands
|
||||||
|
|
||||||
|
@ -133,7 +173,7 @@ Rectangle {
|
||||||
anchors.top: hands.bottom
|
anchors.top: hands.bottom
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -148,7 +188,7 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +210,7 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +219,33 @@ Rectangle {
|
||||||
text: "Trackers"
|
text: "Trackers"
|
||||||
color: hifi.colors.lightGrayText
|
color: hifi.colors.lightGrayText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControls.SpinBox {
|
||||||
|
id: handYOffset
|
||||||
|
decimals: 4
|
||||||
|
width: 105
|
||||||
|
label: "Y: offset"
|
||||||
|
value: -0.0508
|
||||||
|
stepSize: 0.0254
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HifiControls.SpinBox {
|
||||||
|
id: handZOffset
|
||||||
|
width: 105
|
||||||
|
label: "Z: offset"
|
||||||
|
value: -0.0254
|
||||||
|
stepSize: 0.0254
|
||||||
|
decimals: 4
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -200,7 +267,7 @@ Rectangle {
|
||||||
anchors.top: additional.bottom
|
anchors.top: additional.bottom
|
||||||
anchors.topMargin: 15
|
anchors.topMargin: 15
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -213,7 +280,7 @@ Rectangle {
|
||||||
if (hipsChecked) {
|
if (hipsChecked) {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +296,7 @@ Rectangle {
|
||||||
anchors.top: feetConfig.bottom
|
anchors.top: feetConfig.bottom
|
||||||
anchors.topMargin: 15
|
anchors.topMargin: 15
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -246,7 +313,7 @@ Rectangle {
|
||||||
if (chestChecked) {
|
if (chestChecked) {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +336,7 @@ Rectangle {
|
||||||
anchors.top: hipConfig.bottom
|
anchors.top: hipConfig.bottom
|
||||||
anchors.topMargin: 15
|
anchors.topMargin: 15
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -283,7 +350,7 @@ Rectangle {
|
||||||
hipBox.checked = true;
|
hipBox.checked = true;
|
||||||
feetBox.checked = true;
|
feetBox.checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +373,7 @@ Rectangle {
|
||||||
anchors.top: chestConfig.bottom
|
anchors.top: chestConfig.bottom
|
||||||
anchors.topMargin: 15
|
anchors.topMargin: 15
|
||||||
anchors.left: openVrConfiguration.left
|
anchors.left: openVrConfiguration.left
|
||||||
anchors.leftMargin: leftMargin + 20
|
anchors.leftMargin: leftMargin + 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
|
@ -320,7 +387,7 @@ Rectangle {
|
||||||
hipBox.checked = true;
|
hipBox.checked = true;
|
||||||
feetBox.checked = true;
|
feetBox.checked = true;
|
||||||
}
|
}
|
||||||
composeConfigurationSettings();
|
sendConfigurationSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,52 +412,23 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
HifiControls.Button {
|
||||||
|
|
||||||
id: calibrationButton
|
id: calibrationButton
|
||||||
width: 200
|
color: hifi.buttons.blue
|
||||||
height: 35
|
text: "Calibrate"
|
||||||
radius: 6
|
//glyph: hifi.glyphs.avatar1
|
||||||
|
|
||||||
color: hifi.colors.blueHighlight
|
|
||||||
|
|
||||||
anchors.top: bottomSeperator.bottom
|
anchors.top: bottomSeperator.bottom
|
||||||
anchors.topMargin: 10
|
anchors.topMargin: 10
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: leftMargin
|
anchors.leftMargin: leftMargin
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
HiFiGlyphs {
|
openVrConfiguration.countDown = timeToCalibrate.value;
|
||||||
id: calibrationGlyph
|
numberAnimation.start();
|
||||||
text: hifi.glyphs.avatar1
|
calibrationTimer.start();
|
||||||
size: 36
|
info.visible = true;
|
||||||
color: hifi.colors.white
|
info.showCountDown = true;
|
||||||
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: 30
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
RalewayRegular {
|
|
||||||
id: calibrate
|
|
||||||
text: "CALIBRATE"
|
|
||||||
size: 17
|
|
||||||
color: hifi.colors.white
|
|
||||||
|
|
||||||
anchors.left: calibrationGlyph.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: 8
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
openVrConfiguration.countDown = timeToCalibrate.value;
|
|
||||||
numberAnimation.start();
|
|
||||||
calibrationTimer.start();
|
|
||||||
info.visible = true;
|
|
||||||
info.showCountDown = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,16 +459,18 @@ Rectangle {
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
InputConfiguration.calibrationStatus.connect(calibrationStatusInfo);
|
InputConfiguration.calibrationStatus.connect(calibrationStatusInfo);
|
||||||
|
lastConfiguration = composeConfigurationSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.SpinBox {
|
HifiControls.SpinBox {
|
||||||
id: timeToCalibrate
|
id: timeToCalibrate
|
||||||
|
width: 70
|
||||||
anchors.top: calibrationButton.bottom
|
anchors.top: calibrationButton.bottom
|
||||||
anchors.topMargin: 40
|
anchors.topMargin: 40
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: leftMargin
|
anchors.leftMargin: leftMargin
|
||||||
|
|
||||||
|
minimumValue: 3
|
||||||
label: "Time til calibration ( in seconds )"
|
label: "Time til calibration ( in seconds )"
|
||||||
colorScheme: hifi.colorSchemes.dark
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
||||||
|
@ -590,7 +630,7 @@ Rectangle {
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
id: uncalibrateText
|
id: uncalibrateText
|
||||||
text: "Uncalibration Successful"
|
text: "Uncalibration Successful"
|
||||||
size: 42
|
size: 37
|
||||||
color: hifi.colors.greenHighlight
|
color: hifi.colors.greenHighlight
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
|
@ -621,6 +661,58 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateButtonState() {
|
||||||
|
var settings = composeConfigurationSettings();
|
||||||
|
var bodySetting = settings["bodyConfiguration"];
|
||||||
|
var headSetting = settings["headConfiguration"];
|
||||||
|
var headOverride = headSetting["override"];
|
||||||
|
var handSetting = settings["handConfiguration"];
|
||||||
|
var handOverride = settings["override"];
|
||||||
|
|
||||||
|
var settingsChanged = false;
|
||||||
|
|
||||||
|
if (lastConfiguration["bodyConfiguration"]["override"] !== bodySetting["override"]) {
|
||||||
|
settingsChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastHead = lastConfiguration["headConfiguration"];
|
||||||
|
if (lastHead["override"] !== headOverride) {
|
||||||
|
settingsChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastHand = lastConfiguration["handConfiguration"];
|
||||||
|
if (lastHand["override"] !== handOverride) {
|
||||||
|
settingsChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsChanged) {
|
||||||
|
if ((!handOverride) && (!headOverride) && (bodySetting === "Auto")) {
|
||||||
|
state = buttonState.apply;
|
||||||
|
} else {
|
||||||
|
state = buttonState.applyAndCalibrate;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == buttonState.apply) {
|
||||||
|
state = buttonState.disabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastConfiguration = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCalibrationText() {
|
||||||
|
updateButtonState();
|
||||||
|
if (buttonState.disabled == state) {
|
||||||
|
calibrationButton.text = "Apply";
|
||||||
|
} else if (buttonState.apply == state) {
|
||||||
|
calibrationButton.text = "Apply";
|
||||||
|
} else if (buttonState.applyAndCalibrate == state) {
|
||||||
|
calibrationButton.text = "Apply And Calibrate";
|
||||||
|
} else if (buttonState.calibrate == state) {
|
||||||
|
calibrationButton.text = "Calibrate";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function composeConfigurationSettings() {
|
function composeConfigurationSettings() {
|
||||||
var trackerConfiguration = "";
|
var trackerConfiguration = "";
|
||||||
var overrideHead = false;
|
var overrideHead = false;
|
||||||
|
@ -631,7 +723,7 @@ Rectangle {
|
||||||
} else if (shouldersChecked) {
|
} else if (shouldersChecked) {
|
||||||
trackerConfiguration = "FeetHipsAndShoulders";
|
trackerConfiguration = "FeetHipsAndShoulders";
|
||||||
} else if (chestChecked) {
|
} else if (chestChecked) {
|
||||||
trackerConfiguration = "FeetHipsChest";
|
trackerConfiguration = "FeetHipsAndChest";
|
||||||
} else if (hipsChecked) {
|
} else if (hipsChecked) {
|
||||||
trackerConfiguration = "FeetAndHips";
|
trackerConfiguration = "FeetAndHips";
|
||||||
} else if (feetChecked) {
|
} else if (feetChecked) {
|
||||||
|
@ -652,14 +744,30 @@ Rectangle {
|
||||||
overrideHandController = true;
|
overrideHandController = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var headObject = {
|
||||||
var settingsObject = {
|
"override": overrideHead,
|
||||||
"trackerConfiguration": trackerConfiguration,
|
"Y": headYOffset.value,
|
||||||
"overrideHead": overrideHead,
|
"Z": headZOffset.value
|
||||||
"overrideHandController": overrideHandController
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputConfiguration.setConfigurationSettings(settingsObject, pluginName);
|
var handObject = {
|
||||||
|
"override": overrideHandController,
|
||||||
|
"Y": handYOffset.value,
|
||||||
|
"Z": handZOffset.value
|
||||||
|
}
|
||||||
|
|
||||||
|
var settingsObject = {
|
||||||
|
"bodyConfiguration": trackerConfiguration,
|
||||||
|
"headConfiguration": headObject,
|
||||||
|
"handConfiguration": handObject
|
||||||
|
}
|
||||||
|
|
||||||
|
return settingsObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendConfigurationSettings() {
|
||||||
|
var settings = composeConfigurationSettings();
|
||||||
|
InputConfiguration.setConfigurationSettings(settings, pluginName);
|
||||||
|
updateCalibrationText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,19 +47,23 @@ static const char* MENU_PARENT = "Avatar";
|
||||||
static const char* MENU_NAME = "Vive Controllers";
|
static const char* MENU_NAME = "Vive Controllers";
|
||||||
static const char* MENU_PATH = "Avatar" ">" "Vive Controllers";
|
static const char* MENU_PATH = "Avatar" ">" "Vive Controllers";
|
||||||
static const char* RENDER_CONTROLLERS = "Render Hand Controllers";
|
static const char* RENDER_CONTROLLERS = "Render Hand Controllers";
|
||||||
|
|
||||||
static const int MIN_HEAD = 1;
|
static const int MIN_HEAD = 1;
|
||||||
static const int MIN_PUCK_COUNT = 2;
|
static const int MIN_PUCK_COUNT = 2;
|
||||||
static const int MIN_FEET_AND_HIPS = 3;
|
static const int MIN_FEET_AND_HIPS = 3;
|
||||||
static const int MIN_FEET_HIPS_CHEST = 4;
|
static const int MIN_FEET_HIPS_CHEST = 4;
|
||||||
static const int MIN_FEET_HIPS_HEAD = 4;
|
|
||||||
static const int MIN_FEET_HIPS_SHOULDERS = 5;
|
static const int MIN_FEET_HIPS_SHOULDERS = 5;
|
||||||
static const int MIN_FEET_HIPS_CHEST_HEAD = 5;
|
static const int MIN_FEET_HIPS_CHEST_SHOULDERS = 6;
|
||||||
|
|
||||||
static const int FIRST_FOOT = 0;
|
static const int FIRST_FOOT = 0;
|
||||||
static const int SECOND_FOOT = 1;
|
static const int SECOND_FOOT = 1;
|
||||||
static const int HIP = 2;
|
static const int HIP = 2;
|
||||||
static const int CHEST = 3;
|
static const int CHEST = 3;
|
||||||
|
|
||||||
static float HEAD_PUCK_Y_OFFSET = -0.0254f;
|
static float HEAD_PUCK_Y_OFFSET = -0.0254f;
|
||||||
static float HEAD_PUCK_Z_OFFSET = -0.152f;
|
static float HEAD_PUCK_Z_OFFSET = -0.152f;
|
||||||
|
static float HAND_PUCK_Y_OFFSET = -0.0508f;
|
||||||
|
static float HAND_PUCK_Z_OFFSET = 0.0254f;
|
||||||
|
|
||||||
const char* ViveControllerManager::NAME { "OpenVR" };
|
const char* ViveControllerManager::NAME { "OpenVR" };
|
||||||
|
|
||||||
|
@ -117,6 +121,12 @@ static QString deviceTrackingResultToString(vr::ETrackingResult trackingResult)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::calibrate() {
|
||||||
|
if (isSupported()) {
|
||||||
|
_inputDevice->calibrateNextFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ViveControllerManager::isSupported() const {
|
bool ViveControllerManager::isSupported() const {
|
||||||
return openVrSupported();
|
return openVrSupported();
|
||||||
}
|
}
|
||||||
|
@ -233,7 +243,7 @@ ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : contro
|
||||||
_configStringMap[Config::FeetHipsAndShoulders] = QString("FeetHipsAndShoulders");
|
_configStringMap[Config::FeetHipsAndShoulders] = QString("FeetHipsAndShoulders");
|
||||||
|
|
||||||
if (openVrSupported()) {
|
if (openVrSupported()) {
|
||||||
createPreferences();
|
loadSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +350,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::calibrateNextFrame() {
|
void ViveControllerManager::InputDevice::calibrateNextFrame() {
|
||||||
|
@ -469,11 +481,15 @@ bool ViveControllerManager::InputDevice::configureHands(glm::mat4& defaultToRefe
|
||||||
if (determineLimbOrdering(firstHandPose, secondHandPose, headXAxis, headPosition)) {
|
if (determineLimbOrdering(firstHandPose, secondHandPose, headXAxis, headPosition)) {
|
||||||
calibrateLeftHand(defaultToReferenceMat, inputCalibration, firstHand);
|
calibrateLeftHand(defaultToReferenceMat, inputCalibration, firstHand);
|
||||||
calibrateRightHand(defaultToReferenceMat, inputCalibration, secondHand);
|
calibrateRightHand(defaultToReferenceMat, inputCalibration, secondHand);
|
||||||
|
_validTrackedObjects.erase(_validTrackedObjects.begin());
|
||||||
|
_validTrackedObjects.erase(_validTrackedObjects.end() - 1);
|
||||||
_overrideHands = true;
|
_overrideHands = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
calibrateLeftHand(defaultToReferenceMat, inputCalibration, secondHand);
|
calibrateLeftHand(defaultToReferenceMat, inputCalibration, secondHand);
|
||||||
calibrateRightHand(defaultToReferenceMat, inputCalibration, firstHand);
|
calibrateRightHand(defaultToReferenceMat, inputCalibration, firstHand);
|
||||||
|
_validTrackedObjects.erase(_validTrackedObjects.begin());
|
||||||
|
_validTrackedObjects.erase(_validTrackedObjects.end() - 1);
|
||||||
_overrideHands = true;
|
_overrideHands = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +505,7 @@ bool ViveControllerManager::InputDevice::configureHead(glm::mat4& defaultToRefer
|
||||||
int puckCount = (int)_validTrackedObjects.size();
|
int puckCount = (int)_validTrackedObjects.size();
|
||||||
if (_headConfig == HeadConfig::Puck && puckCount >= MIN_HEAD) {
|
if (_headConfig == HeadConfig::Puck && puckCount >= MIN_HEAD) {
|
||||||
calibrateHead(defaultToReferenceMat, inputCalibration);
|
calibrateHead(defaultToReferenceMat, inputCalibration);
|
||||||
_validTrackedObjects.erase(_validTrackedObjects.end());
|
_validTrackedObjects.erase(_validTrackedObjects.end() - 1);
|
||||||
_overrideHead = true;
|
_overrideHead = true;
|
||||||
return true;
|
return true;
|
||||||
} else if (_headConfig == HeadConfig::HMD) {
|
} else if (_headConfig == HeadConfig::HMD) {
|
||||||
|
@ -499,7 +515,10 @@ bool ViveControllerManager::InputDevice::configureHead(glm::mat4& defaultToRefer
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViveControllerManager::InputDevice::configureBody(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) {
|
bool ViveControllerManager::InputDevice::configureBody(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) {
|
||||||
|
std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition);
|
||||||
int puckCount = (int)_validTrackedObjects.size();
|
int puckCount = (int)_validTrackedObjects.size();
|
||||||
|
glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
||||||
|
glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
||||||
if (_config == Config::None) {
|
if (_config == Config::None) {
|
||||||
return true;
|
return true;
|
||||||
} else if (_config == Config::Feet && puckCount >= MIN_PUCK_COUNT) {
|
} else if (_config == Config::Feet && puckCount >= MIN_PUCK_COUNT) {
|
||||||
|
@ -521,24 +540,15 @@ bool ViveControllerManager::InputDevice::configureBody(glm::mat4& defaultToRefer
|
||||||
int secondShoulderIndex = 4;
|
int secondShoulderIndex = 4;
|
||||||
calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex);
|
calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex);
|
||||||
return true;
|
return true;
|
||||||
} /*else if (_config == Config::FeetHipsAndHead && puckCount == MIN_FEET_HIPS_HEAD) {
|
} else if (_config == Config::FeetHipsChestAndShoulders && puckCount >= MIN_FEET_HIPS_CHEST_SHOULDERS) {
|
||||||
glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
calibrateFeet(defaultToReferenceMat, inputCalibration);
|
||||||
glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
|
||||||
calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition);
|
|
||||||
calibrateHips(defaultToReferenceMat, inputCalibration);
|
|
||||||
calibrateHead(defaultToReferenceMat, inputCalibration);
|
|
||||||
_overrideHead = true;
|
|
||||||
return true;
|
|
||||||
} else if (_config == Config::FeetHipsChestAndHead && puckCount == MIN_FEET_HIPS_CHEST_HEAD) {
|
|
||||||
glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
|
||||||
glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
|
||||||
calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition);
|
|
||||||
calibrateHips(defaultToReferenceMat, inputCalibration);
|
calibrateHips(defaultToReferenceMat, inputCalibration);
|
||||||
calibrateChest(defaultToReferenceMat, inputCalibration);
|
calibrateChest(defaultToReferenceMat, inputCalibration);
|
||||||
calibrateHead(defaultToReferenceMat, inputCalibration);
|
int firstShoulderIndex = 4;
|
||||||
_overrideHead = true;
|
int secondShoulderIndex = 5;
|
||||||
|
calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex);
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
|
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
|
||||||
uncalibrate();
|
uncalibrate();
|
||||||
emitCalibrationStatus(false);
|
emitCalibrationStatus(false);
|
||||||
|
@ -861,25 +871,6 @@ void ViveControllerManager::InputDevice::hapticsHelper(float deltaTime, bool lef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) {
|
|
||||||
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
|
|
||||||
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
|
|
||||||
controller::Pose& firstFootPose = firstFoot.second;
|
|
||||||
controller::Pose& secondFootPose = secondFoot.second;
|
|
||||||
|
|
||||||
if (firstFootPose.translation.x < secondFootPose.translation.x) {
|
|
||||||
_jointToPuckMap[controller::LEFT_FOOT] = firstFoot.first;
|
|
||||||
_pucksOffset[firstFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftFoot, firstFootPose);
|
|
||||||
_jointToPuckMap[controller::RIGHT_FOOT] = secondFoot.first;
|
|
||||||
_pucksOffset[secondFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightFoot, secondFootPose);
|
|
||||||
} else {
|
|
||||||
_jointToPuckMap[controller::LEFT_FOOT] = secondFoot.first;
|
|
||||||
_pucksOffset[secondFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftFoot, secondFootPose);
|
|
||||||
_jointToPuckMap[controller::RIGHT_FOOT] = firstFoot.first;
|
|
||||||
_pucksOffset[firstFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightFoot, firstFootPose);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) {
|
void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) {
|
||||||
controller::Pose& handPose = handPair.second;
|
controller::Pose& handPose = handPair.second;
|
||||||
glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation());
|
glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation());
|
||||||
|
@ -897,19 +888,19 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR
|
||||||
glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime));
|
glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime));
|
||||||
|
|
||||||
glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f),
|
glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f),
|
||||||
glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f));
|
glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f);
|
glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET);
|
||||||
glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat);
|
glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat);
|
||||||
glm::quat finalRotation = glmExtractRotation(newHandMat);
|
glm::quat finalRotation = glmExtractRotation(newHandMat);
|
||||||
|
|
||||||
glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation;
|
glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation;
|
||||||
|
|
||||||
glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset);
|
glm::mat4 offsetMat = createMatFromQuatAndPos(rotationOffset, translationOffset);
|
||||||
|
|
||||||
_jointToPuckMap[controller::LEFT_HAND] = handPair.first;
|
_jointToPuckMap[controller::LEFT_HAND] = handPair.first;
|
||||||
_pucksOffset[handPair.first] = offset;
|
_pucksOffset[handPair.first] = offsetMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) {
|
void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) {
|
||||||
|
@ -929,24 +920,26 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo
|
||||||
glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime));
|
glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime));
|
||||||
|
|
||||||
glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f),
|
glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f),
|
||||||
glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f));
|
glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f);
|
glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET);
|
||||||
glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat);
|
glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat);
|
||||||
glm::quat finalRotation = glmExtractRotation(newHandMat);
|
glm::quat finalRotation = glmExtractRotation(newHandMat);
|
||||||
|
|
||||||
glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation;
|
glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation;
|
||||||
|
|
||||||
glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset);
|
glm::mat4 offsetMat = createMatFromQuatAndPos(rotationOffset, translationOffset);
|
||||||
|
|
||||||
_jointToPuckMap[controller::RIGHT_HAND] = handPair.first;
|
_jointToPuckMap[controller::RIGHT_HAND] = handPair.first;
|
||||||
_pucksOffset[handPair.first] = offset;
|
_pucksOffset[handPair.first] = offsetMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition) {
|
void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) {
|
||||||
|
glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
||||||
|
glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat);
|
||||||
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
|
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
|
||||||
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
|
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
|
||||||
controller::Pose& firstFootPose = firstFoot.second;
|
controller::Pose& firstFootPose = firstFoot.second;
|
||||||
|
@ -1016,7 +1009,9 @@ void ViveControllerManager::InputDevice::loadSettings() {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("PUCK_CONFIG");
|
settings.beginGroup("PUCK_CONFIG");
|
||||||
{
|
{
|
||||||
_preferedConfig = (Config)settings.value("configuration", QVariant((int)Config::None)).toInt();
|
_preferedConfig = (Config)settings.value("body configuration", QVariant((int)Config::None)).toInt();
|
||||||
|
_headConfig = (HeadConfig)settings.value("head configuration", QVariant((int)HeadConfig::HMD)).toInt();
|
||||||
|
_handConfig = (HandConfig)settings.value("hand configuration", QVariant((int)HandConfig::HandController)).toInt();
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1020,9 @@ void ViveControllerManager::InputDevice::saveSettings() const {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("PUCK_CONFIG");
|
settings.beginGroup("PUCK_CONFIG");
|
||||||
{
|
{
|
||||||
settings.setValue(QString("configuration"), (int)_preferedConfig);
|
settings.setValue(QString("body configuration"), (int)_preferedConfig);
|
||||||
|
settings.setValue(QString("head configuration"), (int)_headConfig);
|
||||||
|
settings.setValue(QString("hand configuration"), (int)_handConfig);
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -1045,54 +1042,8 @@ void ViveControllerManager::InputDevice::setConfigFromString(const QString& valu
|
||||||
_preferedConfig = Config::FeetHipsAndChest;
|
_preferedConfig = Config::FeetHipsAndChest;
|
||||||
} else if (value == "FeetHipsAndShoulders") {
|
} else if (value == "FeetHipsAndShoulders") {
|
||||||
_preferedConfig = Config::FeetHipsAndShoulders;
|
_preferedConfig = Config::FeetHipsAndShoulders;
|
||||||
}
|
} else if (value == "FeetHipsChestAndShoulders") {
|
||||||
}
|
_preferedConfig = Config::FeetHipsChestAndShoulders;
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::createPreferences() {
|
|
||||||
loadSettings();
|
|
||||||
auto preferences = DependencyManager::get<Preferences>();
|
|
||||||
static const QString VIVE_PUCKS_CONFIG = "Vive Pucks Configuration";
|
|
||||||
|
|
||||||
{
|
|
||||||
static const float MIN_VALUE = -3.0f;
|
|
||||||
static const float MAX_VALUE = 3.0f;
|
|
||||||
static const float STEP = 0.01f;
|
|
||||||
|
|
||||||
auto getter = [this]()->float { return HEAD_PUCK_Y_OFFSET; };
|
|
||||||
auto setter = [this](const float& value) { HEAD_PUCK_Y_OFFSET = value; };
|
|
||||||
|
|
||||||
auto preference = new SpinnerPreference(VIVE_PUCKS_CONFIG, "HeadPuckYOffset", getter, setter);
|
|
||||||
preference->setMin(MIN_VALUE);
|
|
||||||
preference->setMax(MAX_VALUE);
|
|
||||||
preference->setDecimals(3);
|
|
||||||
preference->setStep(STEP);
|
|
||||||
preferences->addPreference(preference);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
static const float MIN_VALUE = -3.0f;
|
|
||||||
static const float MAX_VALUE = 3.0f;
|
|
||||||
static const float STEP = 0.01f;
|
|
||||||
|
|
||||||
auto getter = [this]()->float { return HEAD_PUCK_Z_OFFSET; };
|
|
||||||
auto setter = [this](const float& value) { HEAD_PUCK_Z_OFFSET = value; };
|
|
||||||
|
|
||||||
auto preference = new SpinnerPreference(VIVE_PUCKS_CONFIG, "HeadPuckXOffset", getter, setter);
|
|
||||||
preference->setMin(MIN_VALUE);
|
|
||||||
preference->setMax(MAX_VALUE);
|
|
||||||
preference->setStep(STEP);
|
|
||||||
preference->setDecimals(3);
|
|
||||||
preferences->addPreference(preference);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto getter = [this]()->QString { return _configStringMap[_preferedConfig]; };
|
|
||||||
auto setter = [this](const QString& value) { setConfigFromString(value); saveSettings(); };
|
|
||||||
auto preference = new ComboBoxPreference(VIVE_PUCKS_CONFIG, "Configuration", getter, setter);
|
|
||||||
QStringList list = {"Auto", "Feet", "FeetAndHips", "FeetHipsAndChest", "FeetHipsAndShoulders", "FeetHipsAndHead"};
|
|
||||||
preference->setItems(list);
|
|
||||||
preferences->addPreference(preference);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
QString configurationLayout() override;
|
QString configurationLayout() override;
|
||||||
void setConfigurationSettings(const QJsonObject configurationSettings) override;
|
void setConfigurationSettings(const QJsonObject configurationSettings) override;
|
||||||
QJsonObject configurationSettings() override;
|
QJsonObject configurationSettings() override;
|
||||||
void calibrate() override { _inputDevice->calibrateNextFrame(); }
|
void calibrate() override;
|
||||||
bool isHeadController() const override { return true; }
|
bool isHeadController() const override { return true; }
|
||||||
bool isHeadControllerMounted() const;
|
bool isHeadControllerMounted() const;
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ private:
|
||||||
QString getDefaultMappingConfig() const override;
|
QString getDefaultMappingConfig() const override;
|
||||||
void update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
|
void update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
|
||||||
void focusOutEvent() override;
|
void focusOutEvent() override;
|
||||||
void createPreferences();
|
|
||||||
bool triggerHapticPulse(float strength, float duration, controller::Hand hand) override;
|
bool triggerHapticPulse(float strength, float duration, controller::Hand hand) override;
|
||||||
void hapticsHelper(float deltaTime, bool leftHand);
|
void hapticsHelper(float deltaTime, bool leftHand);
|
||||||
void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration);
|
void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration);
|
||||||
|
@ -102,7 +101,6 @@ private:
|
||||||
void calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair);
|
void calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair);
|
||||||
void calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair);
|
void calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair);
|
||||||
void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
||||||
void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition);
|
|
||||||
void calibrateHips(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
void calibrateHips(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
||||||
void calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
void calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
||||||
void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration,
|
void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration,
|
||||||
|
|
Loading…
Reference in a new issue