From a7683fa07f2569834f3a08b99c70ae73a00a53d8 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 1 Nov 2013 18:15:43 -0700 Subject: [PATCH] More tweaks to eye offsets. --- interface/src/Application.cpp | 5 ++++- interface/src/devices/Faceshift.cpp | 13 +++++++++++-- interface/src/devices/Faceshift.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 236d914b09..54c903f569 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1958,8 +1958,11 @@ void Application::update(float deltaTime) { } if (_faceshift.isActive()) { glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition(); + float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; + const float PITCH_SCALE = 0.25f; + const float YAW_SCALE = 0.25f; lookAtSpot = origin + _myCamera.getRotation() * _faceshift.getHeadRotation() * glm::quat(glm::radians(glm::vec3( - _faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * + _faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) * glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); } _myAvatar.getHead().setLookAtPosition(lookAtSpot); diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 239acde637..2989b4e421 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -41,6 +41,7 @@ Faceshift::Faceshift() : _jawOpenIndex(21), _longTermAverageEyePitch(0.0f), _longTermAverageEyeYaw(0.0f), + _longTermAverageInitialized(false), _estimatedEyePitch(0.0f), _estimatedEyeYaw(0.0f) { @@ -71,8 +72,15 @@ void Faceshift::update() { // smooth relative to the window const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f; - _longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING); - _longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING); + if (!_longTermAverageInitialized) { + _longTermAverageEyePitch = eyeEulers.x; + _longTermAverageEyeYaw = eyeEulers.y; + _longTermAverageInitialized = true; + + } else { + _longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING); + _longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING); + } // back to head-relative float windowEyePitch = eyeEulers.x - _longTermAverageEyePitch; @@ -89,6 +97,7 @@ void Faceshift::reset() { fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral()); send(message); } + _longTermAverageInitialized = false; } void Faceshift::setTCPEnabled(bool enabled) { diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 3cda28a3a0..150f3bb0b7 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -120,6 +120,7 @@ private: float _longTermAverageEyePitch; float _longTermAverageEyeYaw; + bool _longTermAverageInitialized; float _estimatedEyePitch; float _estimatedEyeYaw;