From ffc1c334556f51762b4f6a1a8e9a3bf0a98c366c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 6 Jun 2013 17:25:52 -0700 Subject: [PATCH] Removed double negation for coordinates, world aligned orientation -> camera orientation, removed roll. --- interface/src/Application.cpp | 4 ++-- interface/src/Head.cpp | 5 ++--- interface/src/Head.h | 2 +- interface/src/SerialInterface.cpp | 10 +++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c85e8ecd96..0480a4a087 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -311,11 +311,11 @@ void Application::paintGL() { } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay _myCamera.setTargetPosition(_myAvatar.getBallPosition(AVATAR_JOINT_HEAD_BASE)); - _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation()); } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { _myCamera.setTargetPosition(_myAvatar.getHeadJointPosition()); - _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation()); } // Update camera position diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 44a8ef299d..b4459f52b3 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -314,10 +314,9 @@ glm::quat Head::getOrientation() const { glm::vec3(_pitch, -_yaw, -_roll) : glm::vec3(_pitch, _yaw, _roll))); } -glm::quat Head::getWorldAlignedOrientation () const { +glm::quat Head::getCameraOrientation () const { Avatar* owningAvatar = static_cast(_owningAvatar); - return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(_lookingInMirror ? - glm::vec3(_pitch, -_yaw, -_roll) : glm::vec3(_pitch, _yaw, _roll))); + return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, 0.0f))); } void Head::renderHeadSphere() { diff --git a/interface/src/Head.h b/interface/src/Head.h index 66ce07d133..65f944205b 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -47,7 +47,7 @@ public: void setRenderLookatVectors(bool onOff ) { _renderLookatVectors = onOff; } glm::quat getOrientation() const; - glm::quat getWorldAlignedOrientation () const; + glm::quat getCameraOrientation () const; glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getUpDirection () const { return getOrientation() * IDENTITY_UP; } diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index 8c765544fd..b585e4b428 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -215,7 +215,7 @@ void SerialInterface::readData(float deltaTime) { // From MPU-9150 register map, with setting on // highest resolution = +/- 2G - _lastAcceleration = glm::vec3(-accelXRate, -accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2; + _lastAcceleration = glm::vec3(accelXRate, accelYRate, accelZRate) * LSB_TO_METERS_PER_SECOND2; int rollRate, yawRate, pitchRate; @@ -225,9 +225,9 @@ void SerialInterface::readData(float deltaTime) { // 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. - _lastRotationRates[0] = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND; - _lastRotationRates[1] = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND; - _lastRotationRates[2] = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRotationRates[0] = ((float) pitchRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRotationRates[1] = ((float) yawRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRotationRates[2] = ((float) rollRate) * LSB_TO_DEGREES_PER_SECOND; // Update raw rotation estimates glm::quat estimatedRotation = glm::quat(glm::radians(_estimatedRotation)) * @@ -264,7 +264,7 @@ void SerialInterface::readData(float deltaTime) { 1.0f / SENSOR_FUSION_SAMPLES); // Without a compass heading, always decay estimated Yaw slightly - const float YAW_DECAY = 0.995; + const float YAW_DECAY = 0.999f; glm::vec3 forward = estimatedRotation * glm::vec3(0.0f, 0.0f, -1.0f); estimatedRotation = safeMix(glm::angleAxis(glm::degrees(atan2f(forward.x, -forward.z)), glm::vec3(0.0f, 1.0f, 0.0f)) * estimatedRotation, estimatedRotation, YAW_DECAY);