Let's try subtracting the long-term average from the eye directions.

This commit is contained in:
Andrzej Kapolka 2013-09-09 14:30:26 -07:00
parent 8fec78d82a
commit f8aee88a5b
3 changed files with 33 additions and 7 deletions

View file

@ -1531,14 +1531,15 @@ void Application::update(float deltaTime) {
// Set where I am looking based on my mouse ray (so that other people can see)
glm::vec3 lookAtSpot;
// Update faceshift
_faceshift.update();
// if we have faceshift, use that to compute the lookat direction
glm::vec3 lookAtRayOrigin = mouseRayOrigin, lookAtRayDirection = mouseRayDirection;
if (_faceshift.isActive()) {
lookAtRayOrigin = _myAvatar.getHead().calculateAverageEyePosition();
float averagePitch = (_faceshift.getEyeGazeLeftPitch() + _faceshift.getEyeGazeRightPitch()) / 2.0f;
float averageYaw = (_faceshift.getEyeGazeLeftYaw() + _faceshift.getEyeGazeRightYaw()) / 2.0f;
lookAtRayDirection = _myAvatar.getHead().getOrientation() *
glm::quat(glm::radians(glm::vec3(averagePitch, averageYaw, 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
lookAtRayDirection = _myAvatar.getHead().getOrientation() * glm::quat(glm::radians(glm::vec3(
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
}
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
@ -1707,8 +1708,6 @@ void Application::update(float deltaTime) {
_serialHeadSensor.readData(deltaTime);
}
// Update transmitter
// Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
updateAvatar(deltaTime);

View file

@ -26,13 +26,30 @@ Faceshift::Faceshift() :
_browHeight(0.0f),
_browUpCenterIndex(-1),
_mouthSize(0.0f),
_jawOpenIndex(-1)
_jawOpenIndex(-1),
_longTermAverageEyePitch(0.0f),
_longTermAverageEyeYaw(0.0f),
_estimatedEyePitch(0.0f),
_estimatedEyeYaw(0.0f)
{
connect(&_socket, SIGNAL(connected()), SLOT(noteConnected()));
connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError)));
connect(&_socket, SIGNAL(readyRead()), SLOT(readFromSocket()));
}
void Faceshift::update() {
if (!isActive()) {
return;
}
float averageEyePitch = (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f;
float averageEyeYaw = (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f;
const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f;
_longTermAverageEyePitch = glm::mix(averageEyePitch, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyeYaw = glm::mix(averageEyeYaw, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
_estimatedEyePitch = averageEyePitch - _longTermAverageEyePitch;
_estimatedEyeYaw = averageEyeYaw - _longTermAverageEyeYaw;
}
void Faceshift::reset() {
if (isActive()) {
string message;

View file

@ -35,6 +35,9 @@ public:
float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; }
float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; }
float getEstimatedEyePitch() const { return _estimatedEyePitch; }
float getEstimatedEyeYaw() const { return _estimatedEyeYaw; }
float getLeftBlink() const { return _leftBlink; }
float getRightBlink() const { return _rightBlink; }
@ -42,6 +45,7 @@ public:
float getMouthSize() const { return _mouthSize; }
void update();
void reset();
public slots:
@ -85,6 +89,12 @@ private:
float _mouthSize;
int _jawOpenIndex;
float _longTermAverageEyePitch;
float _longTermAverageEyeYaw;
float _estimatedEyePitch;
float _estimatedEyeYaw;
};
#endif /* defined(__interface__Faceshift__) */