mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
Revert "Moved some FaceShift stuff to FacialAnimationData. Made use of"
This reverts commit f3ae228030
.
This commit is contained in:
parent
6aa9e6b736
commit
7c89201ce8
9 changed files with 30 additions and 57 deletions
|
@ -66,7 +66,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
|||
if (isMine) {
|
||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||
if ((_isFaceshiftConnected = faceTracker)) {
|
||||
_facialAnimationData->setBlendshapeCoefficients(faceTracker->getBlendshapeCoefficients());
|
||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||
_isFaceshiftConnected = true;
|
||||
}
|
||||
}
|
||||
|
@ -141,10 +141,11 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
|||
|
||||
// use data to update fake Faceshift blendshape coefficients
|
||||
const float JAW_OPEN_SCALE = 10.f;
|
||||
_facialAnimationData->updateFakeCoefficients(_leftEyeBlink,
|
||||
_rightEyeBlink,
|
||||
_browAudioLift,
|
||||
glm::clamp(log(_averageLoudness) / JAW_OPEN_SCALE, 0.0f, 1.0f));
|
||||
Application::getInstance()->getFaceshift()->updateFakeCoefficients(_leftEyeBlink,
|
||||
_rightEyeBlink,
|
||||
_browAudioLift,
|
||||
glm::clamp(log(_averageLoudness) / JAW_OPEN_SCALE, 0.0f, 1.0f),
|
||||
_blendshapeCoefficients);
|
||||
}
|
||||
|
||||
if (!isMine) {
|
||||
|
|
|
@ -93,6 +93,18 @@ void Faceshift::reset() {
|
|||
_longTermAverageInitialized = false;
|
||||
}
|
||||
|
||||
void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
||||
float jawOpen, QVector<float>& coefficients) const {
|
||||
coefficients.resize(max((int)coefficients.size(), _facialAnimationData._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;
|
||||
}
|
||||
|
||||
void Faceshift::setTCPEnabled(bool enabled) {
|
||||
if ((_tcpEnabled = enabled)) {
|
||||
connectSocket();
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
void update();
|
||||
void reset();
|
||||
|
||||
void updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
||||
float jawOpen, QVector<float>& coefficients) const;
|
||||
|
||||
signals:
|
||||
|
||||
void connectionStateChanged();
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
|
||||
#include "FacialAnimationData.h"
|
||||
|
||||
#ifndef max
|
||||
inline int max(int a, int b) { return a > b ? a : b; }
|
||||
#endif
|
||||
|
||||
FacialAnimationData::FacialAnimationData() :_leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes
|
||||
_rightBlinkIndex(1),
|
||||
_leftEyeOpenIndex(8),
|
||||
|
@ -31,16 +27,4 @@ _jawOpenIndex(21) {
|
|||
|
||||
float FacialAnimationData::getBlendshapeCoefficient(int index) const {
|
||||
return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f;
|
||||
}
|
||||
|
||||
void FacialAnimationData::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
||||
float jawOpen) {
|
||||
_blendshapeCoefficients.resize(max((int)_blendshapeCoefficients.size(), _jawOpenIndex + 1));
|
||||
qFill(_blendshapeCoefficients.begin(), _blendshapeCoefficients.end(), 0.0f);
|
||||
_blendshapeCoefficients[_leftBlinkIndex] = leftBlink;
|
||||
_blendshapeCoefficients[_rightBlinkIndex] = rightBlink;
|
||||
_blendshapeCoefficients[_browUpCenterIndex] = browUp;
|
||||
_blendshapeCoefficients[_browUpLeftIndex] = browUp;
|
||||
_blendshapeCoefficients[_browUpRightIndex] = browUp;
|
||||
_blendshapeCoefficients[_jawOpenIndex] = jawOpen;
|
||||
}
|
|
@ -21,8 +21,6 @@ class FacialAnimationData : public QObject {
|
|||
|
||||
public:
|
||||
friend class Faceshift;
|
||||
friend class HeadData;
|
||||
friend class AvatarData;
|
||||
|
||||
FacialAnimationData();
|
||||
|
||||
|
@ -41,11 +39,6 @@ public:
|
|||
float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); }
|
||||
float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); }
|
||||
|
||||
void updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, float jawOpen);
|
||||
|
||||
void setBlendshapeCoefficients(const QVector<float>& coefficients) { _blendshapeCoefficients = coefficients; }
|
||||
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||
|
||||
private:
|
||||
float getBlendshapeCoefficient(int index) const;
|
||||
|
||||
|
@ -65,6 +58,7 @@ private:
|
|||
|
||||
int _jawOpenIndex;
|
||||
|
||||
//Only used by agents, since FaceTracker has its own _blendshapeCoefficients;
|
||||
QVector<float> _blendshapeCoefficients;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
#include "AvatarData.h"
|
||||
|
||||
#include "../animation/src/FacialAnimationData.h"
|
||||
|
||||
quint64 DEFAULT_FILTERED_LOG_EXPIRY = 2 * USECS_PER_SECOND;
|
||||
|
||||
using namespace std;
|
||||
|
@ -153,12 +151,10 @@ QByteArray AvatarData::toByteArray() {
|
|||
memcpy(destinationBuffer, &_headData->_browAudioLift, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
const QVector<float>& blendshapeCoefficients = _headData->_facialAnimationData->getBlendshapeCoefficients();
|
||||
|
||||
*destinationBuffer++ = blendshapeCoefficients.size();
|
||||
memcpy(destinationBuffer, blendshapeCoefficients.data(),
|
||||
blendshapeCoefficients.size() * sizeof(float));
|
||||
destinationBuffer += blendshapeCoefficients.size() * sizeof(float);
|
||||
*destinationBuffer++ = _headData->_blendshapeCoefficients.size();
|
||||
memcpy(destinationBuffer, _headData->_blendshapeCoefficients.data(),
|
||||
_headData->_blendshapeCoefficients.size() * sizeof(float));
|
||||
destinationBuffer += _headData->_blendshapeCoefficients.size() * sizeof(float);
|
||||
}
|
||||
|
||||
// pupil dilation
|
||||
|
@ -433,8 +429,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
return maxAvailableSize;
|
||||
}
|
||||
|
||||
_headData->_facialAnimationData->_blendshapeCoefficients.resize(numCoefficients);
|
||||
memcpy(_headData->_facialAnimationData->_blendshapeCoefficients.data(), sourceBuffer, blendDataSize);
|
||||
_headData->_blendshapeCoefficients.resize(numCoefficients);
|
||||
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, blendDataSize);
|
||||
sourceBuffer += numCoefficients * sizeof(float);
|
||||
|
||||
//bitItemsDataSize = 4 * sizeof(float) + 1 + blendDataSize;
|
||||
|
|
|
@ -206,11 +206,6 @@ public:
|
|||
|
||||
Q_INVOKABLE virtual QStringList getJointNames() const { return _jointNames; }
|
||||
|
||||
// Facial Animation
|
||||
Q_INVOKABLE void setLeftEyebrow(float f) {
|
||||
_headData->setLeftEyebrow(f);
|
||||
}
|
||||
|
||||
// key state
|
||||
void setKeyState(KeyState s) { _keyState = s; }
|
||||
KeyState keyState() const { return _keyState; }
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include "AvatarData.h"
|
||||
#include "HeadData.h"
|
||||
|
||||
#include "../animation/src/FacialAnimationData.h"
|
||||
|
||||
HeadData::HeadData(AvatarData* owningAvatar) :
|
||||
_baseYaw(0.0f),
|
||||
_basePitch(0.0f),
|
||||
|
@ -31,7 +29,6 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
|||
_rightEyeBlink(0.0f),
|
||||
_averageLoudness(0.0f),
|
||||
_browAudioLift(0.0f),
|
||||
_facialAnimationData(new FacialAnimationData),
|
||||
_owningAvatar(owningAvatar)
|
||||
{
|
||||
|
||||
|
@ -67,6 +64,3 @@ void HeadData::addRoll(float roll) {
|
|||
setBaseRoll(_baseRoll + roll);
|
||||
}
|
||||
|
||||
const QVector<float>& HeadData::getBlendshapeCoefficients() const {
|
||||
return _facialAnimationData->_blendshapeCoefficients;
|
||||
}
|
|
@ -28,7 +28,6 @@ const float MIN_HEAD_ROLL = -50.f;
|
|||
const float MAX_HEAD_ROLL = 50.f;
|
||||
|
||||
class AvatarData;
|
||||
class FacialAnimationData;
|
||||
|
||||
class HeadData {
|
||||
public:
|
||||
|
@ -55,16 +54,11 @@ public:
|
|||
float getAudioAverageLoudness() const { return _audioAverageLoudness; }
|
||||
void setAudioAverageLoudness(float audioAverageLoudness) { _audioAverageLoudness = audioAverageLoudness; }
|
||||
|
||||
const QVector<float>& getBlendshapeCoefficients() const;
|
||||
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||
|
||||
float getPupilDilation() const { return _pupilDilation; }
|
||||
void setPupilDilation(float pupilDilation) { _pupilDilation = pupilDilation; }
|
||||
|
||||
// Facial animation
|
||||
void setLeftEyebrow(float f) {
|
||||
|
||||
}
|
||||
|
||||
// degrees
|
||||
void addYaw(float yaw);
|
||||
void addPitch(float pitch);
|
||||
|
@ -91,7 +85,7 @@ protected:
|
|||
float _averageLoudness;
|
||||
float _browAudioLift;
|
||||
float _audioAverageLoudness;
|
||||
FacialAnimationData* _facialAnimationData;
|
||||
QVector<float> _blendshapeCoefficients;
|
||||
float _pupilDilation;
|
||||
AvatarData* _owningAvatar;
|
||||
|
||||
|
|
Loading…
Reference in a new issue