mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
Use estimated eye pitch and yaw from DDE to deflect eyes
This commit is contained in:
parent
228e8d4fc0
commit
9980233a0d
3 changed files with 26 additions and 15 deletions
|
@ -2359,23 +2359,22 @@ void Application::updateMyAvatarLookAtPosition() {
|
||||||
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
||||||
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Deflect the eyes a bit to match the detected gaze from Faceshift if active.
|
// Deflect the eyes a bit to match the detected gaze from the face tracker if active.
|
||||||
// DDE doesn't track eyes.
|
if (tracker && !tracker->isMuted()) {
|
||||||
if (tracker && typeid(*tracker) == typeid(Faceshift) && !tracker->isMuted()) {
|
float eyePitch = tracker->getEstimatedEyePitch();
|
||||||
float eyePitch = tracker->getEstimatedEyePitch();
|
float eyeYaw = tracker->getEstimatedEyeYaw();
|
||||||
float eyeYaw = tracker->getEstimatedEyeYaw();
|
const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f;
|
||||||
const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f;
|
glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
|
||||||
glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
|
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
|
||||||
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
|
float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
|
||||||
float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
|
if (isLookingAtSomeone) {
|
||||||
if (isLookingAtSomeone) {
|
deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
|
||||||
deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
|
}
|
||||||
}
|
lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
|
||||||
lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
|
eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) *
|
||||||
eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) *
|
|
||||||
glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
|
glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_myAvatar->getHead()->setLookAtPosition(lookAtSpot);
|
_myAvatar->getHead()->setLookAtPosition(lookAtSpot);
|
||||||
|
|
|
@ -294,6 +294,17 @@ void DdeFaceTracker::reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DdeFaceTracker::update(float deltaTime) {
|
||||||
|
if (!isActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FaceTracker::update(deltaTime);
|
||||||
|
|
||||||
|
glm::vec3 headEulers = glm::degrees(glm::eulerAngles(_headRotation));
|
||||||
|
_estimatedEyePitch = _eyePitch - headEulers.x;
|
||||||
|
_estimatedEyeYaw = _eyeYaw - headEulers.y;
|
||||||
|
}
|
||||||
|
|
||||||
bool DdeFaceTracker::isActive() const {
|
bool DdeFaceTracker::isActive() const {
|
||||||
return (_ddeProcess != NULL);
|
return (_ddeProcess != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ class DdeFaceTracker : public FaceTracker, public Dependency {
|
||||||
public:
|
public:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
virtual void update(float deltaTime);
|
||||||
|
|
||||||
virtual bool isActive() const;
|
virtual bool isActive() const;
|
||||||
virtual bool isTracking() const;
|
virtual bool isTracking() const;
|
||||||
|
|
Loading…
Reference in a new issue