From 997a10c98170a88fb924153745c8aa3a51c531a5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 May 2013 18:56:38 -0700 Subject: [PATCH 1/4] correct the sign of yaw for oculus --- interface/src/Application.cpp | 2 +- interface/src/Head.cpp | 8 ++++---- interface/src/OculusManager.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9a8c44a772..1992ab678b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1377,7 +1377,7 @@ void Application::updateAvatar(float deltaTime) { float yaw, pitch, roll; OculusManager::getEulerAngles(yaw, pitch, roll); - _myAvatar.getHead().setYaw(-yaw); + _myAvatar.getHead().setYaw(yaw); _myAvatar.getHead().setPitch(pitch); _myAvatar.getHead().setRoll(roll); } diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 06f00ad78c..2f50e30b92 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -131,12 +131,12 @@ void Head::calculateGeometry(bool lookingInMirror) { //generate orientation directions based on Euler angles... float pitch = _pitch; - float yaw = -_yaw; - float roll = -_roll; + float yaw = _yaw; + float roll = _roll; if (lookingInMirror) { - yaw = _yaw; - roll = _roll; + yaw = -_yaw; + roll = -_roll; } _orientation.setToIdentity(); diff --git a/interface/src/OculusManager.cpp b/interface/src/OculusManager.cpp index f07741a3ec..e0272ac8ef 100644 --- a/interface/src/OculusManager.cpp +++ b/interface/src/OculusManager.cpp @@ -38,7 +38,7 @@ void OculusManager::connect() { void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { #ifdef __APPLE__ - _sensorFusion.GetOrientation().GetEulerAngles(&yaw, &pitch, &roll); + _sensorFusion.GetOrientation().GetEulerAngles(&yaw, &pitch, &roll); // convert each angle to degrees yaw = glm::degrees(yaw); From 3e192cda9be19eae175e53a0cb7ff2cb46c4b9ab Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 May 2013 19:15:52 -0700 Subject: [PATCH 2/4] correct rendering for first-person for oculus --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1992ab678b..56145e0154 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -303,8 +303,8 @@ void Application::paintGL() { _myCamera.setTightness (100.0f); _myCamera.setTargetPosition(_myAvatar.getHeadPosition()); _myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(), - -_myAvatar.getHead().getPitch(), - _myAvatar.getHead().getRoll()); + _myAvatar.getHead().getPitch(), + -_myAvatar.getHead().getRoll()); } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition()); _myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(), From d7a1cc6ea87bac0c9784b9ddea16d6992bef2bf5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 May 2013 19:38:17 -0700 Subject: [PATCH 3/4] correct the sign for yaw and roll for invensense serial data --- interface/src/Avatar.cpp | 3 +-- interface/src/Head.cpp | 2 -- interface/src/SerialInterface.cpp | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 22466ec690..6d278e641b 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -143,8 +143,7 @@ void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterfa // Update head lean distance based on accelerometer data glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll()); - - glm::vec3 leaning = (serialInterface->getLastAcceleration() - serialInterface->getGravity()) + glm::vec3 leaning = (serialInterface->getLastAcceleration() - serialInterface->getGravity()) * LEAN_SENSITIVITY * (1.f - fminf(glm::length(headRotationRates), HEAD_RATE_MAX) / HEAD_RATE_MAX); leaning.y = 0.f; diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 08e46d2271..33a5f792ee 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -210,8 +210,6 @@ void Head::renderEars() { glPopMatrix(); } - - void Head::renderMouth() { float s = sqrt(_averageLoudness); diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index 233a004568..1989736bf8 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -203,8 +203,8 @@ void SerialInterface::readData() { // Convert the integer rates to floats const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec. - _lastRollRate = ((float) rollRate) * LSB_TO_DEGREES_PER_SECOND; - _lastYawRate = ((float) yawRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRollRate = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND; + _lastYawRate = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND; _lastPitchRate = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND; // Accumulate a set of initial baseline readings for setting gravity From 120c8350043ee8b756a98eaef8085ce41e4ebecb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 May 2013 19:46:33 -0700 Subject: [PATCH 4/4] fix head mouse --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 56145e0154..a66b56b809 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1365,7 +1365,7 @@ void Application::updateAvatar(float deltaTime) { const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f; if (powf(measuredYawRate * measuredYawRate + measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) { - _headMouseX += measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; + _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; } _headMouseX = max(_headMouseX, 0);