mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:16:56 +02:00
Working on blinking, etc.
This commit is contained in:
parent
636e3b1910
commit
8076f571fd
2 changed files with 29 additions and 1 deletions
|
@ -33,7 +33,10 @@ Visage::Visage() :
|
||||||
_active(false),
|
_active(false),
|
||||||
_headOrigin(DEFAULT_HEAD_ORIGIN),
|
_headOrigin(DEFAULT_HEAD_ORIGIN),
|
||||||
_estimatedEyePitch(0.0f),
|
_estimatedEyePitch(0.0f),
|
||||||
_estimatedEyeYaw(0.0f) {
|
_estimatedEyeYaw(0.0f),
|
||||||
|
_leftInnerBrowIndex(0),
|
||||||
|
_rightInnerBrowIndex(0) {
|
||||||
|
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
QByteArray licensePath = "resources/visage/license.vlc";
|
QByteArray licensePath = "resources/visage/license.vlc";
|
||||||
|
@ -59,6 +62,10 @@ Visage::~Visage() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int leftEyeBlinkIndex = 0;
|
||||||
|
static int rightEyeBlinkIndex = 1;
|
||||||
|
static int centerBrowIndex = 16;
|
||||||
|
|
||||||
static QHash<QByteArray, int> createBlendshapeIndices() {
|
static QHash<QByteArray, int> createBlendshapeIndices() {
|
||||||
QHash<QByteArray, QByteArray> blendshapeMap;
|
QHash<QByteArray, QByteArray> blendshapeMap;
|
||||||
blendshapeMap.insert("Sneer", "au_nose_wrinkler");
|
blendshapeMap.insert("Sneer", "au_nose_wrinkler");
|
||||||
|
@ -82,6 +89,15 @@ static QHash<QByteArray, int> createBlendshapeIndices() {
|
||||||
if (blendshape.isEmpty()) {
|
if (blendshape.isEmpty()) {
|
||||||
break;
|
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);
|
QByteArray mapping = blendshapeMap.value(blendshape);
|
||||||
if (!mapping.isEmpty()) {
|
if (!mapping.isEmpty()) {
|
||||||
blendshapeIndices.insert(mapping, i + 1);
|
blendshapeIndices.insert(mapping, i + 1);
|
||||||
|
@ -114,6 +130,12 @@ void Visage::update() {
|
||||||
_blendshapeIndices.resize(_data->actionUnitCount);
|
_blendshapeIndices.resize(_data->actionUnitCount);
|
||||||
int maxIndex = -1;
|
int maxIndex = -1;
|
||||||
for (int i = 0; i < _data->actionUnitCount; i++) {
|
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;
|
int index = getBlendshapeIndices().value(_data->actionUnitsNames[i]) - 1;
|
||||||
maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index);
|
maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +152,10 @@ void Visage::update() {
|
||||||
_blendshapeCoefficients[index] = _data->actionUnits[i];
|
_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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ private:
|
||||||
std::vector<float> _blendshapeCoefficients;
|
std::vector<float> _blendshapeCoefficients;
|
||||||
|
|
||||||
QVector<int> _blendshapeIndices;
|
QVector<int> _blendshapeIndices;
|
||||||
|
int _leftInnerBrowIndex;
|
||||||
|
int _rightInnerBrowIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__Visage__) */
|
#endif /* defined(__interface__Visage__) */
|
||||||
|
|
Loading…
Reference in a new issue