mirror of
https://github.com/lubosz/overte.git
synced 2025-08-16 22:31:12 +02:00
Add world space eye locations (for making eye contact) to the oculus manager
This commit is contained in:
parent
fbfaf43646
commit
7836fd8a85
4 changed files with 31 additions and 4 deletions
|
@ -1995,8 +1995,12 @@ void Application::updateMyAvatarLookAtPosition() {
|
||||||
glm::vec3 lookAtSpot;
|
glm::vec3 lookAtSpot;
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
// When I am in mirror mode, just look right at the camera (myself)
|
// When I am in mirror mode, just look right at the camera (myself)
|
||||||
lookAtSpot = _myCamera.getPosition();
|
if (!OculusManager::isConnected()) {
|
||||||
|
lookAtSpot = _myCamera.getPosition();
|
||||||
|
} else {
|
||||||
|
lookAtSpot = OculusManager::getLeftEyePosition();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
|
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
|
||||||
if (lookingAt && _myAvatar != lookingAt.data()) {
|
if (lookingAt && _myAvatar != lookingAt.data()) {
|
||||||
|
|
|
@ -978,7 +978,11 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
||||||
howManyLookingAtMe++;
|
howManyLookingAtMe++;
|
||||||
// Have that avatar look directly at my camera
|
// Have that avatar look directly at my camera
|
||||||
// Philip TODO: correct to look at left/right eye
|
// Philip TODO: correct to look at left/right eye
|
||||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
if (OculusManager::isConnected()) {
|
||||||
|
avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition());
|
||||||
|
} else {
|
||||||
|
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
avatar->getHead()->clearCorrectedLookAtPosition();
|
avatar->getHead()->clearCorrectedLookAtPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ bool OculusManager::_programInitialized = false;
|
||||||
Camera* OculusManager::_camera = NULL;
|
Camera* OculusManager::_camera = NULL;
|
||||||
int OculusManager::_activeEyeIndex = -1;
|
int OculusManager::_activeEyeIndex = -1;
|
||||||
|
|
||||||
|
glm::vec3 OculusManager::_leftEyePosition;
|
||||||
|
glm::vec3 OculusManager::_rightEyePosition;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OculusManager::connect() {
|
void OculusManager::connect() {
|
||||||
|
@ -348,6 +351,15 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
_camera->setTargetRotation(bodyOrientation * orientation);
|
_camera->setTargetRotation(bodyOrientation * orientation);
|
||||||
_camera->setTargetPosition(position + trackerPosition);
|
_camera->setTargetPosition(position + trackerPosition);
|
||||||
|
|
||||||
|
// Store the latest left and right eye render locations for things that need to know
|
||||||
|
if (eyeIndex == 0) {
|
||||||
|
//_leftEyePosition = position + trackerPosition;
|
||||||
|
glm::vec3 leftEye = position + trackerPosition;
|
||||||
|
qDebug() << "LE: " << leftEye.x << ", " << leftEye.y << ", " << leftEye.z;
|
||||||
|
} else {
|
||||||
|
whichCamera.setRightEyePosition(position + trackerPosition);
|
||||||
|
}
|
||||||
|
|
||||||
_camera->update(1.0f / Application::getInstance()->getFps());
|
_camera->update(1.0f / Application::getInstance()->getFps());
|
||||||
|
|
||||||
Matrix4f proj = ovrMatrix4f_Projection(_eyeRenderDesc[eye].Fov, whichCamera.getNearClip(), whichCamera.getFarClip(), true);
|
Matrix4f proj = ovrMatrix4f_Projection(_eyeRenderDesc[eye].Fov, whichCamera.getNearClip(), whichCamera.getFarClip(), true);
|
||||||
|
@ -362,7 +374,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
|
glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
|
||||||
|
|
||||||
Application::getInstance()->displaySide(*_camera);
|
Application::getInstance()->displaySide(*_camera);
|
||||||
|
|
||||||
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
|
|
||||||
static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane);
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane);
|
||||||
|
|
||||||
|
static glm::vec3 getLeftEyePosition() { return _leftEyePosition; }
|
||||||
|
static glm::vec3 getRightEyePosition() { return _rightEyePosition; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef HAVE_LIBOVR
|
#ifdef HAVE_LIBOVR
|
||||||
|
@ -96,6 +99,10 @@ private:
|
||||||
static bool _programInitialized;
|
static bool _programInitialized;
|
||||||
static Camera* _camera;
|
static Camera* _camera;
|
||||||
static int _activeEyeIndex;
|
static int _activeEyeIndex;
|
||||||
|
|
||||||
|
static glm::vec3 _leftEyePosition;
|
||||||
|
static glm::vec3 _rightEyePosition;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue