mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 06:17:17 +02:00
preparing to clean code
This commit is contained in:
parent
73e628461e
commit
ef1be931dc
6 changed files with 210 additions and 14 deletions
|
@ -156,7 +156,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
function inputPlugins() {
|
||||
return InputConfiguration.activeInputPlugins();
|
||||
return InputConfiguration.inputPlugins();
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
|
|
@ -22,6 +22,7 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
|
||||
property int leftMargin: 75
|
||||
property int countDown: 0
|
||||
property string pluginName: ""
|
||||
property var displayInformation: openVrConfiguration.displayConfiguration()
|
||||
|
||||
|
@ -36,6 +37,16 @@ Rectangle {
|
|||
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
anchors.fill: parent
|
||||
propagateComposedEvents: true
|
||||
onPressed: {
|
||||
parent.forceActiveFocus()
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
color: hifi.colors.baseGray
|
||||
|
||||
RalewayBold {
|
||||
|
@ -374,13 +385,43 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
|
||||
onClicked: {
|
||||
InputCalibration.calibratePlugin(pluginName);
|
||||
console.log("calibration button pressed...");
|
||||
openVrConfiguration.countDown = timeToCalibrate.value;
|
||||
numberAnimation.start();
|
||||
calibrationTimer.start();
|
||||
info.visible = true;
|
||||
info.showCountDown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: calibrationTimer
|
||||
repeat: false
|
||||
interval: 20
|
||||
onTriggered: {
|
||||
InputConfiguration.calibratePlugin(pluginName)
|
||||
info.visible = false;
|
||||
info.showCountDown = false;
|
||||
console.log("calibration started");
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: displayTimer
|
||||
repeat: false
|
||||
interval: 3000
|
||||
onTriggered: {
|
||||
info.showCountDown = false;
|
||||
info.calibrationFailed = false
|
||||
info.calibrationSucceed = false;
|
||||
info.showCalibrationStatus = false;
|
||||
info.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
InputConfiguration.calibrationStatus.connect(calibrationStatus);
|
||||
InputConfiguration.calibrationStatus.connect(calibrationStatusInfo);
|
||||
}
|
||||
|
||||
HifiControls.SpinBox {
|
||||
|
@ -393,10 +434,63 @@ Rectangle {
|
|||
|
||||
label: "Time til calibration ( in seconds )"
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
|
||||
onEditingFinished: {
|
||||
calibrationTimer.interval = value * 1000;
|
||||
openVrConfiguration.countDown = value;
|
||||
numberAnimation.duration = calibrationTimer.interval;
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: numberAnimation
|
||||
target: openVrConfiguration
|
||||
property: "countDown"
|
||||
to: 0
|
||||
}
|
||||
|
||||
function calibrationStatus(status) {
|
||||
console.log("getting calibration status");
|
||||
function calibrationStatusInfo(status) {
|
||||
if (status["calibrated"]) {
|
||||
info.visible = true;
|
||||
info.showCalibrationStatus = true;
|
||||
info.calibrationSucceed = true;
|
||||
} else if (!status["calibrated"]) {
|
||||
var uncalibrated = status["success"];
|
||||
if (uncalibrated) {
|
||||
} else {
|
||||
info.visible = true;
|
||||
info.showCalibrationStatus = true;
|
||||
info.calibrationFailed = true;
|
||||
}
|
||||
}
|
||||
displayTimer.start();
|
||||
}
|
||||
|
||||
|
||||
function trackersForConfiguration() {
|
||||
var pucksNeeded = 0;
|
||||
|
||||
if (headPuckBox.checked) {
|
||||
pucksNeeded++;
|
||||
}
|
||||
|
||||
if (feetBox.checked) {
|
||||
pucksNeeded++;
|
||||
}
|
||||
|
||||
if (hipBox.checked) {
|
||||
pucksNeeded++;
|
||||
}
|
||||
|
||||
if (chestBox.checked) {
|
||||
pucksNeeded++;
|
||||
}
|
||||
|
||||
if (shoulderBox.checked) {
|
||||
pucksNeeded++;
|
||||
}
|
||||
|
||||
return pucksNeeded;
|
||||
}
|
||||
|
||||
function displayConfiguration() {
|
||||
|
@ -426,8 +520,70 @@ Rectangle {
|
|||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: info
|
||||
property bool showCountDown: false
|
||||
property bool showCalibrationStatus: false
|
||||
property bool calibrationFailed: false
|
||||
property bool calibrationSucceed: false
|
||||
|
||||
visible: false
|
||||
color: hifi.colors.baseGray
|
||||
anchors.top: openVrConfiguration.top
|
||||
anchors.bottom: bottomSeperator.bottom
|
||||
anchors.left: openVrConfiguration.left
|
||||
anchors.right: openVrConfiguration.right
|
||||
|
||||
Item {
|
||||
id: countDownContainer
|
||||
visible: info.showCountDown
|
||||
anchors.centerIn: parent
|
||||
RalewayBold {
|
||||
id: countDownText
|
||||
|
||||
text: openVrConfiguration.countDown
|
||||
size: 92
|
||||
|
||||
color: hifi.colors.blueHighlight
|
||||
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: calibrationStatus
|
||||
visible: info.showCalibrationStatus
|
||||
anchors.centerIn: parent
|
||||
Item {
|
||||
id: successInfo
|
||||
visible: info.calibrationSucceed
|
||||
anchors.centerIn: parent
|
||||
RalewayBold {
|
||||
id: successText
|
||||
text: "Calibration Successful"
|
||||
size: 42
|
||||
color: hifi.colors.greenHighlight
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: failedInfo
|
||||
visible: info.calibrationFailed
|
||||
anchors.fill: parent
|
||||
RalewayBold {
|
||||
id: failedText
|
||||
text: "Calibration Failed"
|
||||
size: 42
|
||||
color: hifi.colors.redAccent
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function displayTrackerConfiguration(type) {
|
||||
console.log(type);
|
||||
if (type === "Feet") {
|
||||
feetBox.checked = true;
|
||||
} else if (type === "FeetAndHips") {
|
||||
|
@ -449,7 +605,6 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function composeConfigurationSettings() {
|
||||
var trackerConfiguration = "";
|
||||
var overrideHead = false;
|
||||
|
|
|
@ -71,5 +71,6 @@ void InputConfiguration::calibratePlugin(QString pluginName) {
|
|||
}
|
||||
|
||||
void InputConfiguration::calibrated(const QJsonObject& status) {
|
||||
qDebug() << "-----------> emitting configuration status <------------";
|
||||
emit calibrationStatus(status);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ public:
|
|||
virtual void setConfigurationSettings(const QJsonObject configurationSettings) { }
|
||||
virtual QJsonObject configurationSettings() { return QJsonObject(); }
|
||||
virtual QString configurationLayout() { return QString(); }
|
||||
virtual bool calibrate() { return false; }
|
||||
virtual void calibrate() {}
|
||||
virtual bool configurable() { return false; }
|
||||
};
|
||||
|
|
|
@ -272,6 +272,14 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
|||
}
|
||||
_trackedControllers = numTrackedControllers;
|
||||
|
||||
calibrateFromHandController(inputCalibrationData);
|
||||
calibrateFromUI(inputCalibrationData);
|
||||
|
||||
updateCalibratedLimbs();
|
||||
_lastSimPoseData = _nextSimPoseData;
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData) {
|
||||
if (checkForCalibrationEvent()) {
|
||||
quint64 currentTime = usecTimestampNow();
|
||||
if (!_timeTilCalibrationSet) {
|
||||
|
@ -287,9 +295,14 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
|||
_triggersPressedHandled = false;
|
||||
_timeTilCalibrationSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
updateCalibratedLimbs();
|
||||
_lastSimPoseData = _nextSimPoseData;
|
||||
void ViveControllerManager::InputDevice::calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData) {
|
||||
if (_calibrate) {
|
||||
calibrateOrUncalibrate(inputCalibrationData);
|
||||
_calibrate = false;
|
||||
qDebug() << "------------> calibrateFromUI <-------------";
|
||||
}
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJsonObject configurationSettings) {
|
||||
|
@ -321,6 +334,12 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
|
|||
}
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::calibrateNextFrame() {
|
||||
Locker locker(_lock);
|
||||
_calibrate = true;
|
||||
qDebug() << "---------> calibrateNextFrame <----------";
|
||||
}
|
||||
|
||||
QJsonObject ViveControllerManager::InputDevice::configurationSettings() {
|
||||
Locker locker(_lock);
|
||||
QJsonObject configurationSettings;
|
||||
|
@ -330,9 +349,23 @@ QJsonObject ViveControllerManager::InputDevice::configurationSettings() {
|
|||
return configurationSettings;
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::emitCalibrationStatus() {
|
||||
void ViveControllerManager::InputDevice::emitCalibrationStatus(const bool success) {
|
||||
auto inputConfiguration = DependencyManager::get<InputConfiguration>();
|
||||
QJsonObject status = QJsonObject();
|
||||
|
||||
if (_calibrated && success) {
|
||||
status["calibrated"] = _calibrated;
|
||||
status["configuration"] = configToString(_preferedConfig);
|
||||
} else if (!_calibrated && !success) {
|
||||
status["calibrated"] = _calibrated;
|
||||
status["success"] = success;
|
||||
} else if (!_calibrated && success) {
|
||||
status["calibrated"] = _calibrated;
|
||||
status["success"] = success;
|
||||
status["configuration"] = configToString(_preferedConfig);
|
||||
status["puckCount"] = (int)_validTrackedObjects.size();
|
||||
}
|
||||
|
||||
inputConfiguration->calibrated(status);
|
||||
}
|
||||
|
||||
|
@ -381,6 +414,7 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller
|
|||
calibrate(inputCalibration);
|
||||
} else {
|
||||
uncalibrate();
|
||||
emitCalibrationStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,6 +444,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) {
|
||||
qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
emitCalibrationStatus(false);
|
||||
return;
|
||||
} else if (_config == Config::Auto){
|
||||
if (puckCount == MIN_PUCK_COUNT) {
|
||||
|
@ -424,6 +459,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
} else {
|
||||
qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
emitCalibrationStatus(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -465,10 +501,11 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
} else {
|
||||
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
emitCalibrationStatus(false);
|
||||
return;
|
||||
}
|
||||
_calibrated = true;
|
||||
emitCalibrationStatus();
|
||||
emitCalibrationStatus(true);
|
||||
qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful";
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
QString configurationLayout() override;
|
||||
void setConfigurationSettings(const QJsonObject configurationSettings) override;
|
||||
QJsonObject configurationSettings() override;
|
||||
void calibrate() override { _inputDevice->calibrateNextFrame(); }
|
||||
|
||||
bool activate() override;
|
||||
void deactivate() override;
|
||||
|
@ -99,8 +100,10 @@ private:
|
|||
void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration,
|
||||
int firstShoulderIndex, int secondShoulderIndex);
|
||||
void calibrateHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration);
|
||||
|
||||
void emitCalibrationStatus();
|
||||
void calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData);
|
||||
void calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData);
|
||||
void emitCalibrationStatus(const bool success);
|
||||
void calibrateNextFrame();
|
||||
|
||||
|
||||
class FilteredStick {
|
||||
|
|
Loading…
Reference in a new issue