History

Fix to use new HMD methods

David Rowe committed 11 years ago

Commit 3e8d0ad1 parent e6473fc3 files · +37 −10Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+23−7
@@ -2371,11 +2371,19 @@ void Application::updateMyAvatarLookAtPosition() { · 2370 unmodified lines
23712371 } else {
23722372 lookAtSpot = _myCamera.getPosition() + transformPoint(_myAvatar->getSensorToWorldMatrix(), extractTranslation(getHMDSensorPose()));
23732373 }
2374− } else if (eyeTracker->isTracking() && (OculusManager::isConnected() || eyeTracker->isSimulating())) {
2374+ } else if (eyeTracker->isTracking() && (isHMDMode() || eyeTracker->isSimulating())) {
23752375 // Look at the point that the user is looking at.
2376− if (OculusManager::isConnected()) {
2377− lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition() +
2378− _myAvatar->getOrientation() * (OculusManager::getOrientation() * eyeTracker->getLookAtPosition());
2376+ if (isHMDMode()) {
2377+
2378+ // TODO: Test ...
2379+ // Position of simulated look-at target should change with change in HMD position and orientation
2380+
2381+ glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
2382+ glm::quat hmdOrientation = glm::quat_cast(headPose);
2383+ glm::vec3 hmdPosition = glm::vec3(headPose[3]);
2384+
2385+ lookAtSpot = _myCamera.getPosition() + hmdPosition +
2386+ _myAvatar->getOrientation() * (hmdOrientation * eyeTracker->getLookAtPosition());
23792387 } else {
23802388 lookAtSpot = _myAvatar->getHead()->getEyePosition() +
23812389 (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * eyeTracker->getLookAtPosition());
@@ -2412,9 +2420,17 @@ void Application::updateMyAvatarLookAtPosition() { · 30 unmodified lines
24122420 }
24132421 } else {
24142422 // I am not looking at anyone else, so just look forward
2415− if (OculusManager::isConnected()) {
2416− lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition() +
2417− _myAvatar->getOrientation() * (OculusManager::getOrientation() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
2423+ if (isHMDMode()) {
2424+
2425+ // TODO: Test ...
2426+ // Look-at vector should go into distance based on HMD position and orientation
2427+
2428+ glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
2429+ glm::quat hmdOrientation = glm::quat_cast(headPose);
2430+ glm::vec3 hmdPosition = glm::vec3(headPose[3]);
2431+
2432+ lookAtSpot = _myCamera.getPosition() + hmdPosition +
2433+ _myAvatar->getOrientation() * (hmdOrientation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
24182434 } else {
24192435 lookAtSpot = _myAvatar->getHead()->getEyePosition() +
24202436 (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));