Showing the changes to interface/src/Application.cpp (1 of 191 files). Show all
Unified · Split
| @@ -153,7 +153,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 152 unmodified lines | |||
| 153 | _lastQueriedViewFrustum(), | 153 | _lastQueriedViewFrustum(), |
| 154 | _lastQueriedTime(usecTimestampNow()), | 154 | _lastQueriedTime(usecTimestampNow()), |
| 155 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | 155 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 156 | _cameraPushback(0.0f), | ||
| 157 | _scaleMirror(1.0f), | 156 | _scaleMirror(1.0f), |
| 158 | _rotateMirror(0.0f), | 157 | _rotateMirror(0.0f), |
| 159 | _raiseMirror(0.0f), | 158 | _raiseMirror(0.0f), |
| @@ -350,7 +349,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 190 unmodified lines | |||
| 350 | 349 | ||
| 351 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | 350 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
| 352 | 351 | ||
| 353 | NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); | 352 | QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); |
| 354 | QNetworkDiskCache* cache = new QNetworkDiskCache(); | 353 | QNetworkDiskCache* cache = new QNetworkDiskCache(); |
| 355 | cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache"); | 354 | cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache"); |
| 356 | networkAccessManager.setCache(cache); | 355 | networkAccessManager.setCache(cache); |
| @@ -605,37 +604,40 @@ void Application::paintGL() { · 248 unmodified lines | |||
| 605 | glEnable(GL_LINE_SMOOTH); | 604 | glEnable(GL_LINE_SMOOTH); |
| 606 | 605 | ||
| 607 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | 606 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 608 | _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay | ||
| 609 | if (!OculusManager::isConnected()) { | 607 | if (!OculusManager::isConnected()) { |
| 610 | _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition()); | 608 | // If there isn't an HMD, match exactly to avatar's head |
| 611 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); | 609 | _myCamera.setPosition(_myAvatar->getHead()->getEyePosition()); |
| 610 | _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); | ||
| 611 | } else { | ||
| 612 | // For an HMD, set the base position and orientation to that of the avatar body | ||
| 613 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | ||
| 614 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); | ||
| 612 | } | 615 | } |
| 613 | // OculusManager::display() updates camera position and rotation a bit further on. | ||
| 614 | 616 | ||
| 615 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | 617 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 616 | //Note, the camera distance is set in Camera::setMode() so we dont have to do it here. | 618 | static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f; |
| 617 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing | 619 | _myCamera.setPosition(_myAvatar->getUprightHeadPosition() + |
| 618 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); | 620 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); |
| 619 | if (OculusManager::isConnected()) { | 621 | if (OculusManager::isConnected()) { |
| 620 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation()); | 622 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); |
| 621 | } else { | 623 | } else { |
| 622 | _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation()); | 624 | _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); |
| 623 | } | 625 | } |
| 624 | 626 | ||
| 625 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 627 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 626 | _myCamera.setTightness(0.0f); | ||
| 627 | //Only behave like a true mirror when in the OR | 628 | //Only behave like a true mirror when in the OR |
| 628 | if (OculusManager::isConnected()) { | 629 | if (OculusManager::isConnected()) { |
| 629 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | 630 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 630 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | 631 | _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() + |
| 631 | _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)); | 632 | glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) + |
| 633 | (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | ||
| 634 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | ||
| 632 | } else { | 635 | } else { |
| 633 | _myCamera.setTightness(0.0f); | 636 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 634 | glm::vec3 eyePosition = _myAvatar->getHead()->getEyePosition(); | 637 | _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() + |
| 635 | float headHeight = eyePosition.y - _myAvatar->getPosition().y; | 638 | glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) + |
| 636 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | 639 | (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * |
| 637 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); | 640 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 638 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | ||
| 639 | } | 641 | } |
| 640 | } | 642 | } |
| 641 | 643 | ||
| @@ -659,12 +661,13 @@ void Application::paintGL() { · 17 unmodified lines | |||
| 659 | ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset(); | 661 | ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset(); |
| 660 | 662 | ||
| 661 | // set the camera to third-person view but offset so we can see the frustum | 663 | // set the camera to third-person view but offset so we can see the frustum |
| 662 | _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition()); | 664 | glm::quat frustumRotation = glm::quat(glm::radians(glm::vec3(viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll))); |
| 663 | _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3( | 665 | |
| 664 | viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll)))); | 666 | _viewFrustumOffsetCamera.setPosition(_myCamera.getPosition() + |
| 665 | _viewFrustumOffsetCamera.setUpShift(viewFrustumOffset.up); | 667 | frustumRotation * glm::vec3(0.0f, viewFrustumOffset.up, -viewFrustumOffset.distance)); |
| 666 | _viewFrustumOffsetCamera.setDistance(viewFrustumOffset.distance); | 668 | |
| 667 | _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation | 669 | _viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation); |
| 670 | |||
| 668 | _viewFrustumOffsetCamera.update(1.f/_fps); | 671 | _viewFrustumOffsetCamera.update(1.f/_fps); |
| 669 | whichCamera = &_viewFrustumOffsetCamera; | 672 | whichCamera = &_viewFrustumOffsetCamera; |
| 670 | } | 673 | } |
| @@ -883,7 +886,11 @@ void Application::keyPressEvent(QKeyEvent* event) { · 212 unmodified lines | |||
| 883 | break; | 886 | break; |
| 884 | 887 | ||
| 885 | case Qt::Key_W: | 888 | case Qt::Key_W: |
| 886 | _myAvatar->setDriveKeys(FWD, 1.f); | 889 | if (isOption && !isShifted && !isMeta) { |
| 890 | Menu::getInstance()->triggerOption(MenuOption::Wireframe); | ||
| 891 | } else { | ||
| 892 | _myAvatar->setDriveKeys(FWD, 1.f); | ||
| 893 | } | ||
| 887 | break; | 894 | break; |
| 888 | 895 | ||
| 889 | case Qt::Key_S: | 896 | case Qt::Key_S: |
| @@ -1781,10 +1788,8 @@ void Application::init() { · 891 unmodified lines | |||
| 1781 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager | 1788 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1782 | _avatarManager.init(); | 1789 | _avatarManager.init(); |
| 1783 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 1790 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1784 | _myCamera.setModeShiftPeriod(1.0f); | ||
| 1785 | 1791 | ||
| 1786 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); | 1792 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1787 | _mirrorCamera.setModeShiftPeriod(0.0f); | ||
| 1788 | 1793 | ||
| 1789 | OculusManager::connect(); | 1794 | OculusManager::connect(); |
| 1790 | if (OculusManager::isConnected()) { | 1795 | if (OculusManager::isConnected()) { |
| @@ -2124,17 +2129,14 @@ void Application::cameraMenuChanged() { · 333 unmodified lines | |||
| 2124 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | 2129 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 2125 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | 2130 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| 2126 | _myCamera.setMode(CAMERA_MODE_MIRROR); | 2131 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 2127 | _myCamera.setModeShiftPeriod(0.0f); | ||
| 2128 | } | 2132 | } |
| 2129 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { | 2133 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { |
| 2130 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { | 2134 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 2131 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 2135 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2132 | _myCamera.setModeShiftPeriod(modeShiftPeriod); | ||
| 2133 | } | 2136 | } |
| 2134 | } else { | 2137 | } else { |
| 2135 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { | 2138 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2136 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | 2139 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2137 | _myCamera.setModeShiftPeriod(modeShiftPeriod); | ||
| 2138 | } | 2140 | } |
| 2139 | } | 2141 | } |
| 2140 | } | 2142 | } |
| @@ -2908,10 +2910,8 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 767 unmodified lines | |||
| 2908 | // draw a red sphere | 2910 | // draw a red sphere |
| 2909 | float originSphereRadius = 0.05f; | 2911 | float originSphereRadius = 0.05f; |
| 2910 | glColor3f(1,0,0); | 2912 | glColor3f(1,0,0); |
| 2911 | glPushMatrix(); | 2913 | _geometryCache.renderSphere(originSphereRadius, 15, 15); |
| 2912 | glutSolidSphere(originSphereRadius, 15, 15); | 2914 | |
| 2913 | glPopMatrix(); | ||
| 2914 | |||
| 2915 | // draw the audio reflector overlay | 2915 | // draw the audio reflector overlay |
| 2916 | { | 2916 | { |
| 2917 | PerformanceTimer perfTimer("audio"); | 2917 | PerformanceTimer perfTimer("audio"); |
| @@ -2966,7 +2966,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 48 unmodified lines | |||
| 2966 | } | 2966 | } |
| 2967 | } | 2967 | } |
| 2968 | 2968 | ||
| 2969 | bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); | 2969 | bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR); |
| 2970 | { | 2970 | { |
| 2971 | PerformanceTimer perfTimer("avatars"); | 2971 | PerformanceTimer perfTimer("avatars"); |
| 2972 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, | 2972 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, |
| @@ -3105,30 +3105,30 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 132 unmodified lines | |||
| 3105 | bool eyeRelativeCamera = false; | 3105 | bool eyeRelativeCamera = false; |
| 3106 | if (billboard) { | 3106 | if (billboard) { |
| 3107 | _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees | 3107 | _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees |
| 3108 | _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale()); | 3108 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 3109 | _mirrorCamera.setTargetPosition(_myAvatar->getPosition()); | 3109 | _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 3110 | 3110 | ||
| 3111 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { | 3111 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { |
| 3112 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees | 3112 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 3113 | _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); | 3113 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 3114 | _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); | 3114 | _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| 3115 | 3115 | ||
| 3116 | } else { // HEAD zoom level | 3116 | } else { // HEAD zoom level |
| 3117 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees | 3117 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 3118 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); | ||
| 3119 | if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead()->getFaceModel().isActive()) { | 3118 | if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead()->getFaceModel().isActive()) { |
| 3120 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the | 3119 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the |
| 3121 | // face/body so that the average eye position lies at the origin | 3120 | // face/body so that the average eye position lies at the origin |
| 3122 | eyeRelativeCamera = true; | 3121 | eyeRelativeCamera = true; |
| 3123 | _mirrorCamera.setTargetPosition(glm::vec3()); | 3122 | _mirrorCamera.setPosition(_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); |
| 3124 | 3123 | ||
| 3125 | } else { | 3124 | } else { |
| 3126 | _mirrorCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition()); | 3125 | _mirrorCamera.setPosition(_myAvatar->getHead()->getEyePosition() + |
| 3126 | _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); | ||
| 3127 | } | 3127 | } |
| 3128 | } | 3128 | } |
| 3129 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); | 3129 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); |
| 3130 | 3130 | ||
| 3131 | _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); | 3131 | _mirrorCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 3132 | _mirrorCamera.update(1.0f/_fps); | 3132 | _mirrorCamera.update(1.0f/_fps); |
| 3133 | 3133 | ||
| 3134 | // set the bounds of rear mirror view | 3134 | // set the bounds of rear mirror view |
| @@ -3468,9 +3468,9 @@ void Application::updateWindowTitle(){ · 333 unmodified lines | |||
| 3468 | void Application::updateLocationInServer() { | 3468 | void Application::updateLocationInServer() { |
| 3469 | 3469 | ||
| 3470 | AccountManager& accountManager = AccountManager::getInstance(); | 3470 | AccountManager& accountManager = AccountManager::getInstance(); |
| 3471 | const QUuid& domainUUID = NodeList::getInstance()->getDomainHandler().getUUID(); | 3471 | DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler(); |
| 3472 | 3472 | ||
| 3473 | if (accountManager.isLoggedIn() && !domainUUID.isNull()) { | 3473 | if (accountManager.isLoggedIn() && domainHandler.isConnected() && !domainHandler.getUUID().isNull()) { |
| 3474 | 3474 | ||
| 3475 | // construct a QJsonObject given the user's current address information | 3475 | // construct a QJsonObject given the user's current address information |
| 3476 | QJsonObject rootObject; | 3476 | QJsonObject rootObject; |
| @@ -3484,7 +3484,7 @@ void Application::updateLocationInServer() { · 7 unmodified lines | |||
| 3484 | const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; | 3484 | const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; |
| 3485 | 3485 | ||
| 3486 | locationObject.insert(PATH_KEY_IN_LOCATION, pathString); | 3486 | locationObject.insert(PATH_KEY_IN_LOCATION, pathString); |
| 3487 | locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainUUID.toString()); | 3487 | locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString()); |
| 3488 | 3488 | ||
| 3489 | rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); | 3489 | rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); |
| 3490 | 3490 | ||