More tweaks to eye offsets.

This commit is contained in:
Andrzej Kapolka 2013-11-01 18:15:43 -07:00
parent e4bf5358eb
commit a7683fa07f
3 changed files with 16 additions and 3 deletions

View file

@ -1958,8 +1958,11 @@ void Application::update(float deltaTime) {
}
if (_faceshift.isActive()) {
glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition();
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
const float PITCH_SCALE = 0.25f;
const float YAW_SCALE = 0.25f;
lookAtSpot = origin + _myCamera.getRotation() * _faceshift.getHeadRotation() * glm::quat(glm::radians(glm::vec3(
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) *
_faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) *
glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
}
_myAvatar.getHead().setLookAtPosition(lookAtSpot);

View file

@ -41,6 +41,7 @@ Faceshift::Faceshift() :
_jawOpenIndex(21),
_longTermAverageEyePitch(0.0f),
_longTermAverageEyeYaw(0.0f),
_longTermAverageInitialized(false),
_estimatedEyePitch(0.0f),
_estimatedEyeYaw(0.0f)
{
@ -71,8 +72,15 @@ void Faceshift::update() {
// smooth relative to the window
const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f;
_longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
if (!_longTermAverageInitialized) {
_longTermAverageEyePitch = eyeEulers.x;
_longTermAverageEyeYaw = eyeEulers.y;
_longTermAverageInitialized = true;
} else {
_longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
}
// back to head-relative
float windowEyePitch = eyeEulers.x - _longTermAverageEyePitch;
@ -89,6 +97,7 @@ void Faceshift::reset() {
fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral());
send(message);
}
_longTermAverageInitialized = false;
}
void Faceshift::setTCPEnabled(bool enabled) {

View file

@ -120,6 +120,7 @@ private:
float _longTermAverageEyePitch;
float _longTermAverageEyeYaw;
bool _longTermAverageInitialized;
float _estimatedEyePitch;
float _estimatedEyeYaw;