I don't think Faceshift's gaze data is actually head-relative.

This commit is contained in:
Andrzej Kapolka 2013-11-01 18:28:35 -07:00
parent a7683fa07f
commit def3707041
2 changed files with 11 additions and 20 deletions

View file

@ -1957,11 +1957,12 @@ void Application::update(float deltaTime) {
}
}
if (_faceshift.isActive()) {
// deflect using Faceshift gaze data
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(
const float PITCH_SCALE = 0.5f;
const float YAW_SCALE = 0.5f;
lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
_faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) *
glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
}

View file

@ -66,29 +66,19 @@ void Faceshift::update() {
float averageEyePitch = (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f;
float averageEyeYaw = (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f;
// get the gaze relative to the window
glm::vec3 eyeEulers = safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3(
averageEyePitch, averageEyeYaw, 0.0f))));
// smooth relative to the window
// compute and subtract the long term average
const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f;
if (!_longTermAverageInitialized) {
_longTermAverageEyePitch = eyeEulers.x;
_longTermAverageEyeYaw = eyeEulers.y;
_longTermAverageEyePitch = averageEyePitch;
_longTermAverageEyeYaw = averageEyeYaw;
_longTermAverageInitialized = true;
} else {
_longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyePitch = glm::mix(averageEyePitch, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
_longTermAverageEyeYaw = glm::mix(averageEyeYaw, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
}
// back to head-relative
float windowEyePitch = eyeEulers.x - _longTermAverageEyePitch;
float windowEyeYaw = eyeEulers.y - _longTermAverageEyeYaw;
glm::vec3 relativeEyeEulers = safeEulerAngles(glm::inverse(_headRotation) * glm::quat(glm::radians(glm::vec3(
windowEyePitch, windowEyeYaw, 0.0f))));
_estimatedEyePitch = relativeEyeEulers.x;
_estimatedEyeYaw = relativeEyeEulers.y;
_estimatedEyePitch = averageEyePitch - _longTermAverageEyePitch;
_estimatedEyeYaw = averageEyeYaw - _longTermAverageEyeYaw;
}
void Faceshift::reset() {