From e97a912d9746600afd880cf74bab4d5b64e592ac Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 17:19:29 -0800 Subject: [PATCH] Working on blendshape coefficients. --- interface/src/avatar/Head.cpp | 26 +++++++++++--------------- interface/src/devices/Visage.cpp | 11 +++++++++-- interface/src/devices/Visage.h | 6 ++++++ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index ddb0660364..5c6100764a 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -62,24 +62,20 @@ void Head::simulate(float deltaTime, bool isMine) { // Update audio trailing average for rendering facial animations Faceshift* faceshift = Application::getInstance()->getFaceshift(); + Visage* visage = Application::getInstance()->getVisage(); if (isMine) { - _isFaceshiftConnected = faceshift->isActive(); + _isFaceshiftConnected = false; + if (faceshift->isActive()) { + _blendshapeCoefficients = faceshift->getBlendshapeCoefficients(); + _isFaceshiftConnected = true; + + } else if (visage->isActive()) { + _blendshapeCoefficients = visage->getBlendshapeCoefficients(); + _isFaceshiftConnected = true; + } } - if (isMine && faceshift->isActive()) { - const float EYE_OPEN_SCALE = 0.5f; - _leftEyeBlink = faceshift->getLeftBlink() - EYE_OPEN_SCALE * faceshift->getLeftEyeOpen(); - _rightEyeBlink = faceshift->getRightBlink() - EYE_OPEN_SCALE * faceshift->getRightEyeOpen(); - - // set these values based on how they'll be used. if we use faceshift in the long term, we'll want a complete - // mapping between their blendshape coefficients and our avatar features - const float MOUTH_SIZE_SCALE = 2500.0f; - _averageLoudness = faceshift->getMouthSize() * faceshift->getMouthSize() * MOUTH_SIZE_SCALE; - const float BROW_HEIGHT_SCALE = 0.005f; - _browAudioLift = faceshift->getBrowUpCenter() * BROW_HEIGHT_SCALE; - _blendshapeCoefficients = faceshift->getBlendshapeCoefficients(); - - } else if (!_isFaceshiftConnected) { + if (!_isFaceshiftConnected) { // Update eye saccades const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f; const float AVERAGE_SACCADE_INTERVAL = 4.0f; diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 8696db3af4..c6fb5b9668 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -67,8 +67,15 @@ void Visage::update() { _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin) * TRANSLATION_SCALE; - _estimatedEyePitch = glm::degrees(_data->gazeDirection[1]); - _estimatedEyeYaw = glm::degrees(_data->gazeDirection[0]); + _estimatedEyePitch = glm::degrees(-_data->gazeDirection[1]); + _estimatedEyeYaw = glm::degrees(-_data->gazeDirection[0]); + + for (int i = 0; i < _data->actionUnitCount; i++) { + if (!_data->actionUnitsUsed[i]) { + continue; + } + qDebug() << _data->actionUnitsNames[i] << _data->actionUnits[i]; + } #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 966c41335e..383c81be54 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -9,6 +9,8 @@ #ifndef __interface__Visage__ #define __interface__Visage__ +#include + #include #include @@ -32,6 +34,8 @@ public: float getEstimatedEyePitch() const { return _estimatedEyePitch; } float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } + const std::vector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + void update(); void reset(); @@ -48,6 +52,8 @@ private: float _estimatedEyePitch; float _estimatedEyeYaw; + + std::vector _blendshapeCoefficients; }; #endif /* defined(__interface__Visage__) */