From ba9d89685678ae38433abe45c5b2f4ad340e3921 Mon Sep 17 00:00:00 2001 From: barnold1953 Date: Wed, 23 Jul 2014 15:54:47 -0700 Subject: [PATCH] Revert "Added FacialAnimationData class" This reverts commit fc9fb11e4f6039f5c70bf0e00de2f4c82984929f. --- examples/bot.js | 2 +- interface/src/devices/Faceshift.cpp | 50 ++++++++------ interface/src/devices/Faceshift.h | 43 +++++++----- .../animation/src/FacialAnimationData.cpp | 30 --------- libraries/animation/src/FacialAnimationData.h | 65 ------------------- 5 files changed, 60 insertions(+), 130 deletions(-) delete mode 100644 libraries/animation/src/FacialAnimationData.cpp delete mode 100644 libraries/animation/src/FacialAnimationData.h diff --git a/examples/bot.js b/examples/bot.js index edef280e21..e42d234abf 100644 --- a/examples/bot.js +++ b/examples/bot.js @@ -92,7 +92,7 @@ function playRandomSound() { botNumber = getRandomInt(1, 100); if (botNumber <= 20) { - newFaceFilePrefix = "amber"; + newFaceFilePrefix = "bot" + botNumber; newBodyFilePrefix = "defaultAvatar_body" } else { if (botNumber <= 40) { diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 4105b17652..a7d50814e2 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -32,6 +32,18 @@ Faceshift::Faceshift() : _eyeGazeLeftYaw(0.0f), _eyeGazeRightPitch(0.0f), _eyeGazeRightYaw(0.0f), + _leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes + _rightBlinkIndex(1), + _leftEyeOpenIndex(8), + _rightEyeOpenIndex(9), + _browDownLeftIndex(14), + _browDownRightIndex(15), + _browUpCenterIndex(16), + _browUpLeftIndex(17), + _browUpRightIndex(18), + _mouthSmileLeftIndex(28), + _mouthSmileRightIndex(29), + _jawOpenIndex(21), _longTermAverageEyePitch(0.0f), _longTermAverageEyeYaw(0.0f), _longTermAverageInitialized(false) @@ -95,14 +107,14 @@ void Faceshift::reset() { void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, float jawOpen, QVector& coefficients) const { - coefficients.resize(max((int)coefficients.size(), _facialAnimationData._jawOpenIndex + 1)); + coefficients.resize(max((int)coefficients.size(), _jawOpenIndex + 1)); qFill(coefficients.begin(), coefficients.end(), 0.0f); - coefficients[_facialAnimationData._leftBlinkIndex] = leftBlink; - coefficients[_facialAnimationData._rightBlinkIndex] = rightBlink; - coefficients[_facialAnimationData._browUpCenterIndex] = browUp; - coefficients[_facialAnimationData._browUpLeftIndex] = browUp; - coefficients[_facialAnimationData._browUpRightIndex] = browUp; - coefficients[_facialAnimationData._jawOpenIndex] = jawOpen; + coefficients[_leftBlinkIndex] = leftBlink; + coefficients[_rightBlinkIndex] = rightBlink; + coefficients[_browUpCenterIndex] = browUp; + coefficients[_browUpLeftIndex] = browUp; + coefficients[_browUpRightIndex] = browUp; + coefficients[_jawOpenIndex] = jawOpen; } void Faceshift::setTCPEnabled(bool enabled) { @@ -205,40 +217,40 @@ void Faceshift::receive(const QByteArray& buffer) { const vector& names = static_cast(msg.get())->blendshape_names(); for (size_t i = 0; i < names.size(); i++) { if (names[i] == "EyeBlink_L") { - _facialAnimationData._leftBlinkIndex = i; + _leftBlinkIndex = i; } else if (names[i] == "EyeBlink_R") { - _facialAnimationData._rightBlinkIndex = i; + _rightBlinkIndex = i; } else if (names[i] == "EyeOpen_L") { - _facialAnimationData._leftEyeOpenIndex = i; + _leftEyeOpenIndex = i; } else if (names[i] == "EyeOpen_R") { - _facialAnimationData._rightEyeOpenIndex = i; + _rightEyeOpenIndex = i; } else if (names[i] == "BrowsD_L") { - _facialAnimationData._browDownLeftIndex = i; + _browDownLeftIndex = i; } else if (names[i] == "BrowsD_R") { - _facialAnimationData._browDownRightIndex = i; + _browDownRightIndex = i; } else if (names[i] == "BrowsU_C") { - _facialAnimationData._browUpCenterIndex = i; + _browUpCenterIndex = i; } else if (names[i] == "BrowsU_L") { - _facialAnimationData._browUpLeftIndex = i; + _browUpLeftIndex = i; } else if (names[i] == "BrowsU_R") { - _facialAnimationData._browUpRightIndex = i; + _browUpRightIndex = i; } else if (names[i] == "JawOpen") { - _facialAnimationData._jawOpenIndex = i; + _jawOpenIndex = i; } else if (names[i] == "MouthSmile_L") { - _facialAnimationData._mouthSmileLeftIndex = i; + _mouthSmileLeftIndex = i; } else if (names[i] == "MouthSmile_R") { - _facialAnimationData._mouthSmileRightIndex = i; + _mouthSmileRightIndex = i; } } break; diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 87fd1076ee..2fc1aaddb1 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -18,7 +18,6 @@ #include #include "FaceTracker.h" -#include "FacialAnimationData.h" /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. class Faceshift : public FaceTracker { @@ -43,20 +42,20 @@ public: float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; } float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; } - float getLeftBlink() const { return getBlendshapeCoefficient(_facialAnimationData._leftBlinkIndex); } - float getRightBlink() const { return getBlendshapeCoefficient(_facialAnimationData._rightBlinkIndex); } - float getLeftEyeOpen() const { return getBlendshapeCoefficient(_facialAnimationData._leftEyeOpenIndex); } - float getRightEyeOpen() const { return getBlendshapeCoefficient(_facialAnimationData._rightEyeOpenIndex); } + float getLeftBlink() const { return getBlendshapeCoefficient(_leftBlinkIndex); } + float getRightBlink() const { return getBlendshapeCoefficient(_rightBlinkIndex); } + float getLeftEyeOpen() const { return getBlendshapeCoefficient(_leftEyeOpenIndex); } + float getRightEyeOpen() const { return getBlendshapeCoefficient(_rightEyeOpenIndex); } - float getBrowDownLeft() const { return getBlendshapeCoefficient(_facialAnimationData._browDownLeftIndex); } - float getBrowDownRight() const { return getBlendshapeCoefficient(_facialAnimationData._browDownRightIndex); } - float getBrowUpCenter() const { return getBlendshapeCoefficient(_facialAnimationData._browUpCenterIndex); } - float getBrowUpLeft() const { return getBlendshapeCoefficient(_facialAnimationData._browUpLeftIndex); } - float getBrowUpRight() const { return getBlendshapeCoefficient(_facialAnimationData._browUpRightIndex); } + float getBrowDownLeft() const { return getBlendshapeCoefficient(_browDownLeftIndex); } + float getBrowDownRight() const { return getBlendshapeCoefficient(_browDownRightIndex); } + float getBrowUpCenter() const { return getBlendshapeCoefficient(_browUpCenterIndex); } + float getBrowUpLeft() const { return getBlendshapeCoefficient(_browUpLeftIndex); } + float getBrowUpRight() const { return getBlendshapeCoefficient(_browUpRightIndex); } - float getMouthSize() const { return getBlendshapeCoefficient(_facialAnimationData._jawOpenIndex); } - float getMouthSmileLeft() const { return getBlendshapeCoefficient(_facialAnimationData._mouthSmileLeftIndex); } - float getMouthSmileRight() const { return getBlendshapeCoefficient(_facialAnimationData._mouthSmileRightIndex); } + float getMouthSize() const { return getBlendshapeCoefficient(_jawOpenIndex); } + float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); } + float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); } void update(); void reset(); @@ -103,9 +102,23 @@ private: float _eyeGazeRightPitch; float _eyeGazeRightYaw; - // stores blendshape indexes - FacialAnimationData _facialAnimationData; + int _leftBlinkIndex; + int _rightBlinkIndex; + int _leftEyeOpenIndex; + int _rightEyeOpenIndex; + // Brows + int _browDownLeftIndex; + int _browDownRightIndex; + int _browUpCenterIndex; + int _browUpLeftIndex; + int _browUpRightIndex; + + int _mouthSmileLeftIndex; + int _mouthSmileRightIndex; + + int _jawOpenIndex; + // degrees float _longTermAverageEyePitch; float _longTermAverageEyeYaw; diff --git a/libraries/animation/src/FacialAnimationData.cpp b/libraries/animation/src/FacialAnimationData.cpp deleted file mode 100644 index 0f45675083..0000000000 --- a/libraries/animation/src/FacialAnimationData.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// FacialAnimationData.cpp -// interface/src/devices -// -// Created by Ben Arnold on 7/21/2014. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "FacialAnimationData.h" - -FacialAnimationData::FacialAnimationData() :_leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes -_rightBlinkIndex(1), -_leftEyeOpenIndex(8), -_rightEyeOpenIndex(9), -_browDownLeftIndex(14), -_browDownRightIndex(15), -_browUpCenterIndex(16), -_browUpLeftIndex(17), -_browUpRightIndex(18), -_mouthSmileLeftIndex(28), -_mouthSmileRightIndex(29), -_jawOpenIndex(21) { -} - -float FacialAnimationData::getBlendshapeCoefficient(int index) const { - return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f; -} \ No newline at end of file diff --git a/libraries/animation/src/FacialAnimationData.h b/libraries/animation/src/FacialAnimationData.h deleted file mode 100644 index c8d740c1c9..0000000000 --- a/libraries/animation/src/FacialAnimationData.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// FacialAnimationData.h -// interface/src/devices -// -// Created by Ben Arnold on 7/21/2014. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_FacialAnimationData_h -#define hifi_FacialAnimationData_h - -#include -#include - -/// Stores facial animation data for use by faceshift or scripts -class FacialAnimationData : public QObject { - Q_OBJECT - -public: - friend class Faceshift; - - FacialAnimationData(); - - float getLeftBlink() const { return getBlendshapeCoefficient(_leftBlinkIndex); } - float getRightBlink() const { return getBlendshapeCoefficient(_rightBlinkIndex); } - float getLeftEyeOpen() const { return getBlendshapeCoefficient(_leftEyeOpenIndex); } - float getRightEyeOpen() const { return getBlendshapeCoefficient(_rightEyeOpenIndex); } - - float getBrowDownLeft() const { return getBlendshapeCoefficient(_browDownLeftIndex); } - float getBrowDownRight() const { return getBlendshapeCoefficient(_browDownRightIndex); } - float getBrowUpCenter() const { return getBlendshapeCoefficient(_browUpCenterIndex); } - float getBrowUpLeft() const { return getBlendshapeCoefficient(_browUpLeftIndex); } - float getBrowUpRight() const { return getBlendshapeCoefficient(_browUpRightIndex); } - - float getMouthSize() const { return getBlendshapeCoefficient(_jawOpenIndex); } - float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); } - float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); } - -private: - float getBlendshapeCoefficient(int index) const; - - int _leftBlinkIndex; - int _rightBlinkIndex; - int _leftEyeOpenIndex; - int _rightEyeOpenIndex; - - int _browDownLeftIndex; - int _browDownRightIndex; - int _browUpCenterIndex; - int _browUpLeftIndex; - int _browUpRightIndex; - - int _mouthSmileLeftIndex; - int _mouthSmileRightIndex; - - int _jawOpenIndex; - - //Only used by agents, since FaceTracker has its own _blendshapeCoefficients; - QVector _blendshapeCoefficients; -}; - -#endif // hifi_FacialAnimationData_h \ No newline at end of file