Revert "Added FacialAnimationData class"

This reverts commit fc9fb11e4f.
This commit is contained in:
barnold1953 2014-07-23 15:54:47 -07:00
parent 7c89201ce8
commit ba9d896856
5 changed files with 60 additions and 130 deletions

View file

@ -92,7 +92,7 @@ function playRandomSound() {
botNumber = getRandomInt(1, 100); botNumber = getRandomInt(1, 100);
if (botNumber <= 20) { if (botNumber <= 20) {
newFaceFilePrefix = "amber"; newFaceFilePrefix = "bot" + botNumber;
newBodyFilePrefix = "defaultAvatar_body" newBodyFilePrefix = "defaultAvatar_body"
} else { } else {
if (botNumber <= 40) { if (botNumber <= 40) {

View file

@ -32,6 +32,18 @@ Faceshift::Faceshift() :
_eyeGazeLeftYaw(0.0f), _eyeGazeLeftYaw(0.0f),
_eyeGazeRightPitch(0.0f), _eyeGazeRightPitch(0.0f),
_eyeGazeRightYaw(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), _longTermAverageEyePitch(0.0f),
_longTermAverageEyeYaw(0.0f), _longTermAverageEyeYaw(0.0f),
_longTermAverageInitialized(false) _longTermAverageInitialized(false)
@ -95,14 +107,14 @@ void Faceshift::reset() {
void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
float jawOpen, QVector<float>& coefficients) const { float jawOpen, QVector<float>& 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); qFill(coefficients.begin(), coefficients.end(), 0.0f);
coefficients[_facialAnimationData._leftBlinkIndex] = leftBlink; coefficients[_leftBlinkIndex] = leftBlink;
coefficients[_facialAnimationData._rightBlinkIndex] = rightBlink; coefficients[_rightBlinkIndex] = rightBlink;
coefficients[_facialAnimationData._browUpCenterIndex] = browUp; coefficients[_browUpCenterIndex] = browUp;
coefficients[_facialAnimationData._browUpLeftIndex] = browUp; coefficients[_browUpLeftIndex] = browUp;
coefficients[_facialAnimationData._browUpRightIndex] = browUp; coefficients[_browUpRightIndex] = browUp;
coefficients[_facialAnimationData._jawOpenIndex] = jawOpen; coefficients[_jawOpenIndex] = jawOpen;
} }
void Faceshift::setTCPEnabled(bool enabled) { void Faceshift::setTCPEnabled(bool enabled) {
@ -205,40 +217,40 @@ void Faceshift::receive(const QByteArray& buffer) {
const vector<string>& names = static_cast<fsMsgBlendshapeNames*>(msg.get())->blendshape_names(); const vector<string>& names = static_cast<fsMsgBlendshapeNames*>(msg.get())->blendshape_names();
for (size_t i = 0; i < names.size(); i++) { for (size_t i = 0; i < names.size(); i++) {
if (names[i] == "EyeBlink_L") { if (names[i] == "EyeBlink_L") {
_facialAnimationData._leftBlinkIndex = i; _leftBlinkIndex = i;
} else if (names[i] == "EyeBlink_R") { } else if (names[i] == "EyeBlink_R") {
_facialAnimationData._rightBlinkIndex = i; _rightBlinkIndex = i;
} else if (names[i] == "EyeOpen_L") { } else if (names[i] == "EyeOpen_L") {
_facialAnimationData._leftEyeOpenIndex = i; _leftEyeOpenIndex = i;
} else if (names[i] == "EyeOpen_R") { } else if (names[i] == "EyeOpen_R") {
_facialAnimationData._rightEyeOpenIndex = i; _rightEyeOpenIndex = i;
} else if (names[i] == "BrowsD_L") { } else if (names[i] == "BrowsD_L") {
_facialAnimationData._browDownLeftIndex = i; _browDownLeftIndex = i;
} else if (names[i] == "BrowsD_R") { } else if (names[i] == "BrowsD_R") {
_facialAnimationData._browDownRightIndex = i; _browDownRightIndex = i;
} else if (names[i] == "BrowsU_C") { } else if (names[i] == "BrowsU_C") {
_facialAnimationData._browUpCenterIndex = i; _browUpCenterIndex = i;
} else if (names[i] == "BrowsU_L") { } else if (names[i] == "BrowsU_L") {
_facialAnimationData._browUpLeftIndex = i; _browUpLeftIndex = i;
} else if (names[i] == "BrowsU_R") { } else if (names[i] == "BrowsU_R") {
_facialAnimationData._browUpRightIndex = i; _browUpRightIndex = i;
} else if (names[i] == "JawOpen") { } else if (names[i] == "JawOpen") {
_facialAnimationData._jawOpenIndex = i; _jawOpenIndex = i;
} else if (names[i] == "MouthSmile_L") { } else if (names[i] == "MouthSmile_L") {
_facialAnimationData._mouthSmileLeftIndex = i; _mouthSmileLeftIndex = i;
} else if (names[i] == "MouthSmile_R") { } else if (names[i] == "MouthSmile_R") {
_facialAnimationData._mouthSmileRightIndex = i; _mouthSmileRightIndex = i;
} }
} }
break; break;

View file

@ -18,7 +18,6 @@
#include <fsbinarystream.h> #include <fsbinarystream.h>
#include "FaceTracker.h" #include "FaceTracker.h"
#include "FacialAnimationData.h"
/// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features.
class Faceshift : public FaceTracker { class Faceshift : public FaceTracker {
@ -43,20 +42,20 @@ public:
float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; } float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; }
float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; } float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; }
float getLeftBlink() const { return getBlendshapeCoefficient(_facialAnimationData._leftBlinkIndex); } float getLeftBlink() const { return getBlendshapeCoefficient(_leftBlinkIndex); }
float getRightBlink() const { return getBlendshapeCoefficient(_facialAnimationData._rightBlinkIndex); } float getRightBlink() const { return getBlendshapeCoefficient(_rightBlinkIndex); }
float getLeftEyeOpen() const { return getBlendshapeCoefficient(_facialAnimationData._leftEyeOpenIndex); } float getLeftEyeOpen() const { return getBlendshapeCoefficient(_leftEyeOpenIndex); }
float getRightEyeOpen() const { return getBlendshapeCoefficient(_facialAnimationData._rightEyeOpenIndex); } float getRightEyeOpen() const { return getBlendshapeCoefficient(_rightEyeOpenIndex); }
float getBrowDownLeft() const { return getBlendshapeCoefficient(_facialAnimationData._browDownLeftIndex); } float getBrowDownLeft() const { return getBlendshapeCoefficient(_browDownLeftIndex); }
float getBrowDownRight() const { return getBlendshapeCoefficient(_facialAnimationData._browDownRightIndex); } float getBrowDownRight() const { return getBlendshapeCoefficient(_browDownRightIndex); }
float getBrowUpCenter() const { return getBlendshapeCoefficient(_facialAnimationData._browUpCenterIndex); } float getBrowUpCenter() const { return getBlendshapeCoefficient(_browUpCenterIndex); }
float getBrowUpLeft() const { return getBlendshapeCoefficient(_facialAnimationData._browUpLeftIndex); } float getBrowUpLeft() const { return getBlendshapeCoefficient(_browUpLeftIndex); }
float getBrowUpRight() const { return getBlendshapeCoefficient(_facialAnimationData._browUpRightIndex); } float getBrowUpRight() const { return getBlendshapeCoefficient(_browUpRightIndex); }
float getMouthSize() const { return getBlendshapeCoefficient(_facialAnimationData._jawOpenIndex); } float getMouthSize() const { return getBlendshapeCoefficient(_jawOpenIndex); }
float getMouthSmileLeft() const { return getBlendshapeCoefficient(_facialAnimationData._mouthSmileLeftIndex); } float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); }
float getMouthSmileRight() const { return getBlendshapeCoefficient(_facialAnimationData._mouthSmileRightIndex); } float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); }
void update(); void update();
void reset(); void reset();
@ -103,9 +102,23 @@ private:
float _eyeGazeRightPitch; float _eyeGazeRightPitch;
float _eyeGazeRightYaw; float _eyeGazeRightYaw;
// stores blendshape indexes int _leftBlinkIndex;
FacialAnimationData _facialAnimationData; int _rightBlinkIndex;
int _leftEyeOpenIndex;
int _rightEyeOpenIndex;
// Brows
int _browDownLeftIndex;
int _browDownRightIndex;
int _browUpCenterIndex;
int _browUpLeftIndex;
int _browUpRightIndex;
int _mouthSmileLeftIndex;
int _mouthSmileRightIndex;
int _jawOpenIndex;
// degrees // degrees
float _longTermAverageEyePitch; float _longTermAverageEyePitch;
float _longTermAverageEyeYaw; float _longTermAverageEyeYaw;

View file

@ -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;
}

View file

@ -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 <QObject>
#include <QVector>
/// 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<float> _blendshapeCoefficients;
};
#endif // hifi_FacialAnimationData_h