From 8076f571fd5ea93aedfd91047e2e776458c5e3bc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 18:39:38 -0800 Subject: [PATCH] Working on blinking, etc. --- interface/src/devices/Visage.cpp | 28 +++++++++++++++++++++++++++- interface/src/devices/Visage.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 2ed36e9594..8a6b9d5947 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -33,7 +33,10 @@ Visage::Visage() : _active(false), _headOrigin(DEFAULT_HEAD_ORIGIN), _estimatedEyePitch(0.0f), - _estimatedEyeYaw(0.0f) { + _estimatedEyeYaw(0.0f), + _leftInnerBrowIndex(0), + _rightInnerBrowIndex(0) { + #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); QByteArray licensePath = "resources/visage/license.vlc"; @@ -59,6 +62,10 @@ Visage::~Visage() { #endif } +static int leftEyeBlinkIndex = 0; +static int rightEyeBlinkIndex = 1; +static int centerBrowIndex = 16; + static QHash createBlendshapeIndices() { QHash blendshapeMap; blendshapeMap.insert("Sneer", "au_nose_wrinkler"); @@ -82,6 +89,15 @@ static QHash createBlendshapeIndices() { if (blendshape.isEmpty()) { break; } + if (blendshape == "EyeBlink_L") { + leftEyeBlinkIndex = i; + + } else if (blendshape == "EyeBlink_R") { + rightEyeBlinkIndex = i; + + } else if (blendshape == "BrowsU_C") { + centerBrowIndex = i; + } QByteArray mapping = blendshapeMap.value(blendshape); if (!mapping.isEmpty()) { blendshapeIndices.insert(mapping, i + 1); @@ -114,6 +130,12 @@ void Visage::update() { _blendshapeIndices.resize(_data->actionUnitCount); int maxIndex = -1; for (int i = 0; i < _data->actionUnitCount; i++) { + QByteArray name = _data->actionUnitsNames[i]; + if (name == "au_left_inner_brow_raiser") { + _leftInnerBrowIndex = i; + } else if (name == "au_right_inner_brow_raiser") { + _rightInnerBrowIndex = i; + } int index = getBlendshapeIndices().value(_data->actionUnitsNames[i]) - 1; maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index); } @@ -130,6 +152,10 @@ void Visage::update() { _blendshapeCoefficients[index] = _data->actionUnits[i]; } } + _blendshapeCoefficients[leftEyeBlinkIndex] = 1.0f - _data->eyeClosure[0]; + _blendshapeCoefficients[rightEyeBlinkIndex] = 1.0f - _data->eyeClosure[1]; + _blendshapeCoefficients[centerBrowIndex] = (_data->actionUnits[_leftInnerBrowIndex] + + _data->actionUnits[_rightInnerBrowIndex]) * 0.5f; #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 0559a859de..124ef29e3b 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -58,6 +58,8 @@ private: std::vector _blendshapeCoefficients; QVector _blendshapeIndices; + int _leftInnerBrowIndex; + int _rightInnerBrowIndex; }; #endif /* defined(__interface__Visage__) */