mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge pull request #1119 from ey6es/master
Gaze adjustments: use the eye positions from the face model, subtract long term average relative to window (not head).
This commit is contained in:
commit
256ca85efe
3 changed files with 31 additions and 26 deletions
|
@ -371,12 +371,12 @@ void Application::paintGL() {
|
|||
_myCamera.setUpShift (0.0f);
|
||||
_myCamera.setDistance (0.0f);
|
||||
_myCamera.setTightness (0.0f); // Camera is directly connected to head without smoothing
|
||||
_myCamera.setTargetPosition(_myAvatar.getHeadJointPosition());
|
||||
_myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getOrientation());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay
|
||||
_myCamera.setTargetPosition(_myAvatar.getEyeLevelPosition());
|
||||
_myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
|
@ -386,15 +386,7 @@ void Application::paintGL() {
|
|||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_myCamera.setTightness(0.0f);
|
||||
_myCamera.setDistance(0.3f);
|
||||
glm::vec3 targetPosition = _myAvatar.getUprightHeadPosition();
|
||||
if (_myAvatar.getHead().getFaceModel().isActive()) {
|
||||
// make sure we're aligned to the blend face eyes
|
||||
glm::vec3 leftEyePosition, rightEyePosition;
|
||||
if (_myAvatar.getHead().getFaceModel().getEyePositions(leftEyePosition, rightEyePosition)) {
|
||||
targetPosition = (leftEyePosition + rightEyePosition) * 0.5f;
|
||||
}
|
||||
}
|
||||
_myCamera.setTargetPosition(targetPosition);
|
||||
_myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
|
||||
}
|
||||
|
||||
|
@ -1765,7 +1757,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con
|
|||
float distance;
|
||||
if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition,
|
||||
HEAD_SPHERE_RADIUS * avatar->getHead().getScale(), distance)) {
|
||||
eyePosition = avatar->getHead().getEyePosition();
|
||||
eyePosition = avatar->getHead().calculateAverageEyePosition();
|
||||
_lookatIndicatorScale = avatar->getHead().getScale();
|
||||
_lookatOtherPosition = headPosition;
|
||||
nodeUUID = avatar->getOwningNode()->getUUID();
|
||||
|
@ -1932,10 +1924,15 @@ void Application::update(float deltaTime) {
|
|||
if (_lookatTargetAvatar && !_faceshift.isActive()) {
|
||||
// If the mouse is over another avatar's head...
|
||||
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||
|
||||
} else if (_isHoverVoxel && !_faceshift.isActive()) {
|
||||
// Look at the hovered voxel
|
||||
lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
|
||||
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR && !_faceshift.isActive()) {
|
||||
_myAvatar.getHead().setLookAtPosition(_myCamera.getPosition());
|
||||
|
||||
} else {
|
||||
// Just look in direction of the mouse ray
|
||||
const float FAR_AWAY_STARE = TREE_SCALE;
|
||||
|
@ -2792,9 +2789,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
|||
}
|
||||
|
||||
// Render my own Avatar
|
||||
if (whichCamera.getMode() == CAMERA_MODE_MIRROR && !_faceshift.isActive()) {
|
||||
_myAvatar.getHead().setLookAtPosition(whichCamera.getPosition());
|
||||
}
|
||||
_myAvatar.render(whichCamera.getMode() == CAMERA_MODE_MIRROR,
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
|
||||
_myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
|
||||
|
|
|
@ -238,6 +238,11 @@ void Head::simulate(float deltaTime, bool isMine) {
|
|||
}
|
||||
|
||||
_faceModel.simulate(deltaTime);
|
||||
|
||||
calculateGeometry();
|
||||
|
||||
// the blend face may have custom eye meshes
|
||||
_faceModel.getEyePositions(_leftEyePosition, _rightEyePosition);
|
||||
}
|
||||
|
||||
void Head::calculateGeometry() {
|
||||
|
@ -286,8 +291,6 @@ void Head::render(float alpha, bool isMine) {
|
|||
_renderAlpha = alpha;
|
||||
|
||||
if (!(_videoFace.render(alpha) || _faceModel.render(alpha))) {
|
||||
calculateGeometry();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
|
@ -299,11 +302,6 @@ void Head::render(float alpha, bool isMine) {
|
|||
renderNose();
|
||||
renderEyeBrows();
|
||||
}
|
||||
|
||||
if (_faceModel.isActive()) {
|
||||
// the blend face may have custom eye meshes
|
||||
_faceModel.getEyePositions(_leftEyePosition, _rightEyePosition);
|
||||
}
|
||||
|
||||
if (_renderLookatVectors) {
|
||||
renderLookatVectors(_leftEyePosition, _rightEyePosition, _lookAtPosition);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "Faceshift.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
using namespace fs;
|
||||
using namespace std;
|
||||
|
@ -63,11 +64,23 @@ 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
|
||||
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;
|
||||
_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;
|
||||
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;
|
||||
}
|
||||
|
||||
void Faceshift::reset() {
|
||||
|
|
Loading…
Reference in a new issue