mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Fix to use new HMD methods
This commit is contained in:
parent
e6473fc8b9
commit
3e8d0ad712
3 changed files with 37 additions and 10 deletions
|
@ -2371,11 +2371,19 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
} else {
|
||||
lookAtSpot = _myCamera.getPosition() + transformPoint(_myAvatar->getSensorToWorldMatrix(), extractTranslation(getHMDSensorPose()));
|
||||
}
|
||||
} else if (eyeTracker->isTracking() && (OculusManager::isConnected() || eyeTracker->isSimulating())) {
|
||||
} else if (eyeTracker->isTracking() && (isHMDMode() || eyeTracker->isSimulating())) {
|
||||
// Look at the point that the user is looking at.
|
||||
if (OculusManager::isConnected()) {
|
||||
lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition() +
|
||||
_myAvatar->getOrientation() * (OculusManager::getOrientation() * eyeTracker->getLookAtPosition());
|
||||
if (isHMDMode()) {
|
||||
|
||||
// TODO: Test ...
|
||||
// Position of simulated look-at target should change with change in HMD position and orientation
|
||||
|
||||
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
||||
glm::quat hmdOrientation = glm::quat_cast(headPose);
|
||||
glm::vec3 hmdPosition = glm::vec3(headPose[3]);
|
||||
|
||||
lookAtSpot = _myCamera.getPosition() + hmdPosition +
|
||||
_myAvatar->getOrientation() * (hmdOrientation * eyeTracker->getLookAtPosition());
|
||||
} else {
|
||||
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
||||
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * eyeTracker->getLookAtPosition());
|
||||
|
@ -2412,9 +2420,17 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
}
|
||||
} else {
|
||||
// I am not looking at anyone else, so just look forward
|
||||
if (OculusManager::isConnected()) {
|
||||
lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition() +
|
||||
_myAvatar->getOrientation() * (OculusManager::getOrientation() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||
if (isHMDMode()) {
|
||||
|
||||
// TODO: Test ...
|
||||
// Look-at vector should go into distance based on HMD position and orientation
|
||||
|
||||
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
||||
glm::quat hmdOrientation = glm::quat_cast(headPose);
|
||||
glm::vec3 hmdPosition = glm::vec3(headPose[3]);
|
||||
|
||||
lookAtSpot = _myCamera.getPosition() + hmdPosition +
|
||||
_myAvatar->getOrientation() * (hmdOrientation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||
} else {
|
||||
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
||||
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||
|
|
|
@ -292,9 +292,10 @@ public:
|
|||
virtual QGLWidget* getPrimarySurface() override;
|
||||
|
||||
void setActiveDisplayPlugin(const QString& pluginName);
|
||||
private:
|
||||
|
||||
DisplayPlugin * getActiveDisplayPlugin();
|
||||
const DisplayPlugin * getActiveDisplayPlugin() const;
|
||||
|
||||
public:
|
||||
|
||||
FileLogger* getLogger() { return _logger; }
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <AnimationHandle.h>
|
||||
#include <AudioClient.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <display-plugins/DisplayPlugin.h>
|
||||
#include <GeometryUtil.h>
|
||||
#include <NodeList.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
@ -1253,9 +1254,18 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, fl
|
|||
}
|
||||
|
||||
if (qApp->isHMDMode()) {
|
||||
|
||||
// TODO: Test ...
|
||||
// Look-at vectors should go from HMD mid eyes regardless of combined position and orientation
|
||||
|
||||
glm::mat4 leftEye = Application::getInstance()->getActiveDisplayPlugin()->getEyePose(Eye::Left);
|
||||
glm::vec3 leftEyePosition = glm::vec3(leftEye[3]);
|
||||
glm::mat4 rightEye = Application::getInstance()->getActiveDisplayPlugin()->getEyePose(Eye::Right);
|
||||
glm::vec3 rightEyePosition = glm::vec3(leftEye[3]);
|
||||
|
||||
glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition();
|
||||
getHead()->renderLookAts(renderArgs, cameraPosition + OculusManager::getLeftEyePosition(),
|
||||
cameraPosition + OculusManager::getRightEyePosition());
|
||||
getHead()->renderLookAts(renderArgs, cameraPosition + leftEyePosition,
|
||||
cameraPosition + rightEyePosition);
|
||||
} else {
|
||||
getHead()->renderLookAts(renderArgs);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue