Showing the changes to interface/src/Application.cpp (1 of 38 files). Show all
Unified · Split
| @@ -450,22 +450,22 @@ void Application::paintGL() { · 449 unmodified lines | |||
| 450 | _myCamera.setUpShift(0.0f); | 450 | _myCamera.setUpShift(0.0f); |
| 451 | _myCamera.setDistance(0.0f); | 451 | _myCamera.setDistance(0.0f); |
| 452 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing | 452 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 453 | _myCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition()); | 453 | _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); |
| 454 | _myCamera.setTargetRotation(_myAvatar->getHead().getOrientation()); | 454 | _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation()); |
| 455 | 455 | ||
| 456 | } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | 456 | } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 457 | _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay | 457 | _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay |
| 458 | _myCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition()); | 458 | _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); |
| 459 | _myCamera.setTargetRotation(_myAvatar->getHead().getCameraOrientation()); | 459 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); |
| 460 | 460 | ||
| 461 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | 461 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 462 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing | 462 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 463 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); | 463 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); |
| 464 | _myCamera.setTargetRotation(_myAvatar->getHead().getCameraOrientation()); | 464 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); |
| 465 | 465 | ||
| 466 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 466 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 467 | _myCamera.setTightness(0.0f); | 467 | _myCamera.setTightness(0.0f); |
| 468 | float headHeight = _myAvatar->getHead().calculateAverageEyePosition().y - _myAvatar->getPosition().y; | 468 | float headHeight = _myAvatar->getHead()->calculateAverageEyePosition().y - _myAvatar->getPosition().y; |
| 469 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); | 469 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); |
| 470 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); | 470 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); |
| 471 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f))); | 471 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f))); |
| @@ -529,14 +529,14 @@ void Application::paintGL() { · 57 unmodified lines | |||
| 529 | _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); | 529 | _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); |
| 530 | } else { // HEAD zoom level | 530 | } else { // HEAD zoom level |
| 531 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); | 531 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); |
| 532 | if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead().getFaceModel().isActive()) { | 532 | if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead()->getFaceModel().isActive()) { |
| 533 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the | 533 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the |
| 534 | // face/body so that the average eye position lies at the origin | 534 | // face/body so that the average eye position lies at the origin |
| 535 | eyeRelativeCamera = true; | 535 | eyeRelativeCamera = true; |
| 536 | _mirrorCamera.setTargetPosition(glm::vec3()); | 536 | _mirrorCamera.setTargetPosition(glm::vec3()); |
| 537 | 537 | ||
| 538 | } else { | 538 | } else { |
| 539 | _mirrorCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition()); | 539 | _mirrorCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); |
| 540 | } | 540 | } |
| 541 | } | 541 | } |
| 542 | 542 | ||
| @@ -558,26 +558,26 @@ void Application::paintGL() { · 15 unmodified lines | |||
| 558 | if (eyeRelativeCamera) { | 558 | if (eyeRelativeCamera) { |
| 559 | // save absolute translations | 559 | // save absolute translations |
| 560 | glm::vec3 absoluteSkeletonTranslation = _myAvatar->getSkeletonModel().getTranslation(); | 560 | glm::vec3 absoluteSkeletonTranslation = _myAvatar->getSkeletonModel().getTranslation(); |
| 561 | glm::vec3 absoluteFaceTranslation = _myAvatar->getHead().getFaceModel().getTranslation(); | 561 | glm::vec3 absoluteFaceTranslation = _myAvatar->getHead()->getFaceModel().getTranslation(); |
| 562 | 562 | ||
| 563 | // get the eye positions relative to the neck and use them to set the face translation | 563 | // get the eye positions relative to the neck and use them to set the face translation |
| 564 | glm::vec3 leftEyePosition, rightEyePosition; | 564 | glm::vec3 leftEyePosition, rightEyePosition; |
| 565 | _myAvatar->getHead().getFaceModel().setTranslation(glm::vec3()); | 565 | _myAvatar->getHead()->getFaceModel().setTranslation(glm::vec3()); |
| 566 | _myAvatar->getHead().getFaceModel().getEyePositions(leftEyePosition, rightEyePosition); | 566 | _myAvatar->getHead()->getFaceModel().getEyePositions(leftEyePosition, rightEyePosition); |
| 567 | _myAvatar->getHead().getFaceModel().setTranslation((leftEyePosition + rightEyePosition) * -0.5f); | 567 | _myAvatar->getHead()->getFaceModel().setTranslation((leftEyePosition + rightEyePosition) * -0.5f); |
| 568 | 568 | ||
| 569 | // get the neck position relative to the body and use it to set the skeleton translation | 569 | // get the neck position relative to the body and use it to set the skeleton translation |
| 570 | glm::vec3 neckPosition; | 570 | glm::vec3 neckPosition; |
| 571 | _myAvatar->getSkeletonModel().setTranslation(glm::vec3()); | 571 | _myAvatar->getSkeletonModel().setTranslation(glm::vec3()); |
| 572 | _myAvatar->getSkeletonModel().getNeckPosition(neckPosition); | 572 | _myAvatar->getSkeletonModel().getNeckPosition(neckPosition); |
| 573 | _myAvatar->getSkeletonModel().setTranslation(_myAvatar->getHead().getFaceModel().getTranslation() - | 573 | _myAvatar->getSkeletonModel().setTranslation(_myAvatar->getHead()->getFaceModel().getTranslation() - |
| 574 | neckPosition); | 574 | neckPosition); |
| 575 | 575 | ||
| 576 | displaySide(_mirrorCamera, true); | 576 | displaySide(_mirrorCamera, true); |
| 577 | 577 | ||
| 578 | // restore absolute translations | 578 | // restore absolute translations |
| 579 | _myAvatar->getSkeletonModel().setTranslation(absoluteSkeletonTranslation); | 579 | _myAvatar->getSkeletonModel().setTranslation(absoluteSkeletonTranslation); |
| 580 | _myAvatar->getHead().getFaceModel().setTranslation(absoluteFaceTranslation); | 580 | _myAvatar->getHead()->getFaceModel().setTranslation(absoluteFaceTranslation); |
| 581 | } else { | 581 | } else { |
| 582 | displaySide(_mirrorCamera, true); | 582 | displaySide(_mirrorCamera, true); |
| 583 | } | 583 | } |
| @@ -1867,7 +1867,7 @@ void Application::init() { · 1283 unmodified lines | |||
| 1867 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager | 1867 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1868 | _avatarManager.init(); | 1868 | _avatarManager.init(); |
| 1869 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 1869 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1870 | _myCamera.setModeShiftRate(1.0f); | 1870 | _myCamera.setModeShiftPeriod(1.0f); |
| 1871 | 1871 | ||
| 1872 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); | 1872 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1873 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); | 1873 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); |
| @@ -1978,8 +1978,8 @@ const float MAX_VOXEL_EDIT_DISTANCE = 50.0f; · 104 unmodified lines | |||
| 1978 | const float HEAD_SPHERE_RADIUS = 0.07f; | 1978 | const float HEAD_SPHERE_RADIUS = 0.07f; |
| 1979 | 1979 | ||
| 1980 | bool Application::isLookingAtMyAvatar(Avatar* avatar) { | 1980 | bool Application::isLookingAtMyAvatar(Avatar* avatar) { |
| 1981 | glm::vec3 theirLookat = avatar->getHead().getLookAtPosition(); | 1981 | glm::vec3 theirLookat = avatar->getHead()->getLookAtPosition(); |
| 1982 | glm::vec3 myHeadPosition = _myAvatar->getHead().getPosition(); | 1982 | glm::vec3 myHeadPosition = _myAvatar->getHead()->getPosition(); |
| 1983 | 1983 | ||
| 1984 | if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) { | 1984 | if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) { |
| 1985 | return true; | 1985 | return true; |
| @@ -2040,10 +2040,19 @@ void Application::updateFaceshift() { · 54 unmodified lines | |||
| 2040 | 2040 | ||
| 2041 | // Copy angular velocity if measured by faceshift, to the head | 2041 | // Copy angular velocity if measured by faceshift, to the head |
| 2042 | if (_faceshift.isActive()) { | 2042 | if (_faceshift.isActive()) { |
| 2043 | _myAvatar->getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity()); | 2043 | _myAvatar->getHead()->setAngularVelocity(_faceshift.getHeadAngularVelocity()); |
| 2044 | } | 2044 | } |
| 2045 | } | 2045 | } |
| 2046 | 2046 | ||
| 2047 | void Application::updateVisage() { | ||
| 2048 | |||
| 2049 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 2050 | PerformanceWarning warn(showWarnings, "Application::updateVisage()"); | ||
| 2051 | |||
| 2052 | // Update Visage | ||
| 2053 | _visage.update(); | ||
| 2054 | } | ||
| 2055 | |||
| 2047 | void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { | 2056 | void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { |
| 2048 | 2057 | ||
| 2049 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2058 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| @@ -2057,23 +2066,35 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { · 7 unmodified lines | |||
| 2057 | float distance = TREE_SCALE; | 2066 | float distance = TREE_SCALE; |
| 2058 | if (_myAvatar->getLookAtTargetAvatar()) { | 2067 | if (_myAvatar->getLookAtTargetAvatar()) { |
| 2059 | distance = glm::distance(_mouseRayOrigin, | 2068 | distance = glm::distance(_mouseRayOrigin, |
| 2060 | static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead().calculateAverageEyePosition()); | 2069 | static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); |
| 2061 | 2070 | ||
| 2062 | } else if (_isHoverVoxel) { | 2071 | } else if (_isHoverVoxel) { |
| 2063 | distance = glm::distance(_mouseRayOrigin, getMouseVoxelWorldCoordinates(_hoverVoxel)); | 2072 | distance = glm::distance(_mouseRayOrigin, getMouseVoxelWorldCoordinates(_hoverVoxel)); |
| 2064 | } | 2073 | } |
| 2065 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * distance; | 2074 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * distance; |
| 2066 | } | 2075 | } |
| 2076 | bool trackerActive = false; | ||
| 2077 | float eyePitch, eyeYaw; | ||
| 2067 | if (_faceshift.isActive()) { | 2078 | if (_faceshift.isActive()) { |
| 2079 | eyePitch = _faceshift.getEstimatedEyePitch(); | ||
| 2080 | eyeYaw = _faceshift.getEstimatedEyeYaw(); | ||
| 2081 | trackerActive = true; | ||
| 2082 | |||
| 2083 | } else if (_visage.isActive()) { | ||
| 2084 | eyePitch = _visage.getEstimatedEyePitch(); | ||
| 2085 | eyeYaw = _visage.getEstimatedEyeYaw(); | ||
| 2086 | trackerActive = true; | ||
| 2087 | } | ||
| 2088 | if (trackerActive) { | ||
| 2068 | // deflect using Faceshift gaze data | 2089 | // deflect using Faceshift gaze data |
| 2069 | glm::vec3 origin = _myAvatar->getHead().calculateAverageEyePosition(); | 2090 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 2070 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; | 2091 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 2071 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); | 2092 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); |
| 2072 | lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( | 2093 | lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( |
| 2073 | _faceshift.getEstimatedEyePitch() * pitchSign * deflection, _faceshift.getEstimatedEyeYaw() * deflection, 0.0f))) * | 2094 | eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) * |
| 2074 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); | 2095 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); |
| 2075 | } | 2096 | } |
| 2076 | _myAvatar->getHead().setLookAtPosition(lookAtSpot); | 2097 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); |
| 2077 | } | 2098 | } |
| 2078 | 2099 | ||
| 2079 | void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) { | 2100 | void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) { |
| @@ -2229,17 +2250,17 @@ void Application::cameraMenuChanged() { · 149 unmodified lines | |||
| 2229 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | 2250 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 2230 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | 2251 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| 2231 | _myCamera.setMode(CAMERA_MODE_MIRROR); | 2252 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 2232 | _myCamera.setModeShiftRate(100.0f); | 2253 | _myCamera.setModeShiftPeriod(0.00f); |
| 2233 | } | 2254 | } |
| 2234 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { | 2255 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { |
| 2235 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { | 2256 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 2236 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 2257 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2237 | _myCamera.setModeShiftRate(1.0f); | 2258 | _myCamera.setModeShiftPeriod(1.0f); |
| 2238 | } | 2259 | } |
| 2239 | } else { | 2260 | } else { |
| 2240 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { | 2261 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2241 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | 2262 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2242 | _myCamera.setModeShiftRate(1.0f); | 2263 | _myCamera.setModeShiftPeriod(1.0f); |
| 2243 | } | 2264 | } |
| 2244 | } | 2265 | } |
| 2245 | } | 2266 | } |
| @@ -2321,6 +2342,7 @@ void Application::update(float deltaTime) { · 75 unmodified lines | |||
| 2321 | glm::vec3 lookAtSpot; | 2342 | glm::vec3 lookAtSpot; |
| 2322 | 2343 | ||
| 2323 | updateFaceshift(); | 2344 | updateFaceshift(); |
| 2345 | updateVisage(); | ||
| 2324 | _myAvatar->updateLookAtTargetAvatar(lookAtSpot); | 2346 | _myAvatar->updateLookAtTargetAvatar(lookAtSpot); |
| 2325 | updateMyAvatarLookAtPosition(lookAtSpot); | 2347 | updateMyAvatarLookAtPosition(lookAtSpot); |
| 2326 | 2348 | ||
| @@ -3833,6 +3855,7 @@ void Application::resetSensors() { · 1506 unmodified lines | |||
| 3833 | _mouseY = _glWidget->height() / 2; | 3855 | _mouseY = _glWidget->height() / 2; |
| 3834 | 3856 | ||
| 3835 | _faceshift.reset(); | 3857 | _faceshift.reset(); |
| 3858 | _visage.reset(); | ||
| 3836 | 3859 | ||
| 3837 | if (OculusManager::isConnected()) { | 3860 | if (OculusManager::isConnected()) { |
| 3838 | OculusManager::reset(); | 3861 | OculusManager::reset(); |