Added Smile

This commit is contained in:
RyanDowne 2013-09-10 17:33:22 -07:00
parent 61f9088d3e
commit 13c228e796
4 changed files with 67 additions and 18 deletions

View file

@ -89,6 +89,8 @@ PerlinFace::PerlinFace(Head *owningHead)
_browsU_L(0),
_browsU_R(0),
_mouthSize(0),
_mouthSmileLeft(0),
_mouthSmileRight(0),
_leftBlink(0),
_rightBlink(0) {
}
@ -258,6 +260,8 @@ void PerlinFace::updatePositions() {
_browsU_L = faceshift->getBrowUpLeft();
_browsU_R = faceshift->getBrowUpRight();
_mouthSize = faceshift->getMouthSize();
_mouthSmileLeft = faceshift->getMouthSmileLeft();
_mouthSmileRight = faceshift->getMouthSmileRight();
_leftBlink = faceshift->getLeftBlink();
_rightBlink = faceshift->getRightBlink();
}
@ -294,33 +298,51 @@ void PerlinFace::updatePositions() {
+ _browsU_C * BROWS_UP_CENTER_MAX;
// Mouth
_vertices[MOUTH_BOTTOM_IN].y = VERTICES[FLOAT_PER_VERTEX * MOUTH_BOTTOM_IN + 1]
+ (1.0 - _mouthSize) * 6.2;
+ (1.0 - _mouthSize) * 6.5;
_vertices[MOUTH_BOTTOM_OUT].y = VERTICES[FLOAT_PER_VERTEX * MOUTH_BOTTOM_OUT + 1]
+ (1.0 - _mouthSize) * 6;
+ (1.0 - _mouthSize) * 6.5;
_vertices[MOUTH_MID_IN].y = VERTICES[FLOAT_PER_VERTEX * MOUTH_MID_IN + 1]
+ (1.0 - _mouthSize) * 3;
+ (1.0 - _mouthSize) * 4 + _mouthSmileLeft * 2;
_vertices[MOUTH_MID_OUT].y = VERTICES[FLOAT_PER_VERTEX * MOUTH_MID_OUT + 1]
+ (1.0 - _mouthSize) * 3;
+ (1.0 - _mouthSize) * 4 + _mouthSmileLeft * 2;
_vertices[NUM_VERTICES + MOUTH_BOTTOM_IN].y = VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + MOUTH_BOTTOM_IN) + 1]
+ (1.0 - _mouthSize) * 6.2;
+ (1.0 - _mouthSize) * 6.5;
_vertices[NUM_VERTICES + MOUTH_BOTTOM_OUT].y = VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + MOUTH_BOTTOM_OUT) + 1]
+ (1.0 - _mouthSize) * 6;
+ (1.0 - _mouthSize) * 6.5;
_vertices[NUM_VERTICES + MOUTH_MID_IN].y = VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + MOUTH_MID_IN) + 1]
+ (1.0 - _mouthSize) * 3;
+ (1.0 - _mouthSize) * 4 + _mouthSmileRight * 2;
_vertices[NUM_VERTICES + MOUTH_MID_OUT].y = VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + MOUTH_MID_OUT) + 1]
+ (1.0 - _mouthSize) * 3;
// Eyelid
_vertices[EYE_MID_TOP] = (1.0f - _leftBlink) * _vertices[EYE_MID_TOP] + _leftBlink * (_vertices[EYE_MID_TOP] + _vertices[EYE_MID_BOTTOM]) / 2.0f;
_vertices[EYE_MID_BOTTOM] = (1.0f - _leftBlink) * _vertices[EYE_MID_BOTTOM] + _leftBlink * (_vertices[EYE_MID_TOP] + _vertices[EYE_MID_BOTTOM]) / 2.0f;
_vertices[NUM_VERTICES + EYE_MID_TOP] = (1.0f - _leftBlink) * _vertices[NUM_VERTICES + EYE_MID_TOP]
+ _leftBlink * (_vertices[NUM_VERTICES + EYE_MID_TOP] + _vertices[NUM_VERTICES + EYE_MID_BOTTOM]) / 2.0f;
_vertices[NUM_VERTICES + EYE_MID_BOTTOM] = (1.0f - _leftBlink) * _vertices[NUM_VERTICES + EYE_MID_BOTTOM]
+ _leftBlink * (_vertices[NUM_VERTICES + EYE_MID_TOP] + _vertices[NUM_VERTICES + EYE_MID_BOTTOM]) / 2.0f;
+ (1.0 - _mouthSize) * 4 + _mouthSmileRight * 2;
qDebug("[DEBUG] %f : %f\n", _mouthSmileLeft, _mouthSmileRight);
// Eyelids
glm::vec3 topLeftEyelid = glm::vec3(VERTICES[FLOAT_PER_VERTEX * EYE_MID_TOP],
VERTICES[FLOAT_PER_VERTEX * EYE_MID_TOP + 1],
-VERTICES[FLOAT_PER_VERTEX * EYE_MID_TOP + 2]);
glm::vec3 bottomLeftEyelid = glm::vec3(VERTICES[FLOAT_PER_VERTEX * EYE_MID_BOTTOM],
VERTICES[FLOAT_PER_VERTEX * EYE_MID_BOTTOM + 1],
-VERTICES[FLOAT_PER_VERTEX * EYE_MID_BOTTOM + 2]);
glm::vec3 topRightEyelid = glm::vec3(VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_TOP)],
VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_TOP) + 1],
-VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_TOP) + 2]);
glm::vec3 bottomRightEyelid = glm::vec3(VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_BOTTOM)],
VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_BOTTOM) + 1],
-VERTICES[FLOAT_PER_VERTEX * (NUM_VERTICES + EYE_MID_BOTTOM) + 2]);
_vertices[EYE_MID_TOP] = (1.0f - _leftBlink) * topLeftEyelid
+ _leftBlink * (topLeftEyelid + bottomLeftEyelid) / 2.0f;
_vertices[EYE_MID_BOTTOM] = (1.0f - _leftBlink) * bottomLeftEyelid
+ _leftBlink * (topLeftEyelid + bottomLeftEyelid) / 2.0f;
_vertices[NUM_VERTICES + EYE_MID_TOP] = (1.0f - _leftBlink) * topRightEyelid
+ _leftBlink * (topRightEyelid + bottomRightEyelid) / 2.0f;
_vertices[NUM_VERTICES + EYE_MID_BOTTOM] = (1.0f - _leftBlink) * bottomRightEyelid
+ _leftBlink * (topRightEyelid + bottomRightEyelid) / 2.0f;
}
void PerlinFace::updateVertices() {

View file

@ -63,6 +63,8 @@ private:
float _browsU_R;
float _mouthSize;
float _mouthSmileLeft;
float _mouthSmileRight;
float _leftBlink;
float _rightBlink;

View file

@ -34,6 +34,10 @@ Faceshift::Faceshift() :
_browUpLeftIndex(-1),
_browUpRightIndex(-1),
_mouthSize(0.0f),
_mouthSmileLeft(0),
_mouthSmileRight(0),
_mouthSmileLeftIndex(-1),
_mouthSmileRightIndex(0),
_jawOpenIndex(-1),
_longTermAverageEyePitch(0.0f),
_longTermAverageEyeYaw(0.0f),
@ -146,6 +150,12 @@ void Faceshift::readFromSocket() {
if (_jawOpenIndex != -1) {
_mouthSize = data.m_coeffs[_jawOpenIndex];
}
if (_mouthSmileLeftIndex != -1) {
_mouthSmileLeft = data.m_coeffs[_mouthSmileLeftIndex];
}
if (_mouthSmileRightIndex != -1) {
_mouthSmileRight = data.m_coeffs[_mouthSmileRightIndex];
}
}
break;
}
@ -175,6 +185,13 @@ void Faceshift::readFromSocket() {
} else if (names[i] == "JawOpen") {
_jawOpenIndex = i;
} else if (names[i] == "MouthSmile_L") {
_mouthSmileLeftIndex = i;
} else if (names[i] == "MouthSmile_R") {
_mouthSmileRightIndex = i;
}
}
break;

View file

@ -48,6 +48,8 @@ public:
float getBrowUpRight() const { return _browUpRight; }
float getMouthSize() const { return _mouthSize; }
float getMouthSmileLeft() const { return _mouthSmileLeft; }
float getMouthSmileRight() const { return _mouthSmileRight; }
void update();
void reset();
@ -103,6 +105,12 @@ private:
float _mouthSize;
float _mouthSmileLeft;
float _mouthSmileRight;
int _mouthSmileLeftIndex;
int _mouthSmileRightIndex;
int _jawOpenIndex;
float _longTermAverageEyePitch;