mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-17 06:20:11 +02:00
Adjust gaze target for someone looking at me
This commit is contained in:
parent
3a92878544
commit
9efeda9716
4 changed files with 22 additions and 5 deletions
|
@ -2306,8 +2306,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
if (!OculusManager::isConnected()) {
|
||||
lookAtSpot = _myCamera.getPosition();
|
||||
} else {
|
||||
lookAtSpot = _myCamera.getPosition()
|
||||
+ (OculusManager::getLeftEyePosition() + OculusManager::getRightEyePosition()) / 2.0f;
|
||||
lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition();
|
||||
}
|
||||
} else {
|
||||
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock();
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include <TextRenderer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "Environment.h"
|
||||
|
@ -42,7 +45,6 @@
|
|||
#include "MyAvatar.h"
|
||||
#include "Physics.h"
|
||||
#include "Recorder.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "Util.h"
|
||||
#include "InterfaceLogging.h"
|
||||
|
||||
|
@ -893,8 +895,22 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
smallestAngleTo = angleTo;
|
||||
}
|
||||
if (Application::getInstance()->isLookingAtMyAvatar(avatar)) {
|
||||
// Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
||||
// Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face.
|
||||
// Offset their gaze according to whether they're looking at one of my eyes or my mouth.
|
||||
glm::vec3 gazeOffset = avatar->getHead()->getLookAtPosition() - getHead()->getEyePosition();
|
||||
const float HUMAN_EYE_SEPARATION = 0.065f;
|
||||
float myEyeSeparation = glm::length(getHead()->getLeftEyePosition() - getHead()->getRightEyePosition());
|
||||
gazeOffset = gazeOffset * HUMAN_EYE_SEPARATION / myEyeSeparation;
|
||||
|
||||
if (Application::getInstance()->isHMDMode()) {
|
||||
//avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getCamera()->getPosition()
|
||||
// + OculusManager::getMidEyePosition() + gazeOffset);
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()
|
||||
+ OculusManager::getMidEyePosition() + gazeOffset);
|
||||
} else {
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()
|
||||
+ gazeOffset);
|
||||
}
|
||||
} else {
|
||||
avatar->getHead()->clearCorrectedLookAtPosition();
|
||||
}
|
||||
|
|
|
@ -283,6 +283,7 @@ static ovrVector3f _eyeOffsets[ovrEye_Count];
|
|||
|
||||
glm::vec3 OculusManager::getLeftEyePosition() { return _eyePositions[ovrEye_Left]; }
|
||||
glm::vec3 OculusManager::getRightEyePosition() { return _eyePositions[ovrEye_Right]; }
|
||||
glm::vec3 OculusManager::getMidEyePosition() { return (_eyePositions[ovrEye_Left] + _eyePositions[ovrEye_Right]) / 2.0f; }
|
||||
|
||||
void OculusManager::connect(QOpenGLContext* shareContext) {
|
||||
qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING;
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
static glm::vec3 getLeftEyePosition();
|
||||
static glm::vec3 getRightEyePosition();
|
||||
static glm::vec3 getMidEyePosition();
|
||||
|
||||
static int getHMDScreen();
|
||||
|
||||
|
|
Loading…
Reference in a new issue