History

Merge branch 'master' into 20073

David Rowe committed 12 years ago

Commit b718d272 parents 357d49d 49c0226191 files · +7915 −2244Browse files

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

Unified · Split

interface/src/Application.cpp+49−49
@@ -153,7 +153,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 152 unmodified lines
153153 _lastQueriedViewFrustum(),
154154 _lastQueriedTime(usecTimestampNow()),
155155 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
156− _cameraPushback(0.0f),
157156 _scaleMirror(1.0f),
158157 _rotateMirror(0.0f),
159158 _raiseMirror(0.0f),
@@ -350,7 +349,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 190 unmodified lines
350349
351350 QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
352351
353− NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
352+ QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
354353 QNetworkDiskCache* cache = new QNetworkDiskCache();
355354 cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");
356355 networkAccessManager.setCache(cache);
@@ -605,37 +604,40 @@ void Application::paintGL() { · 248 unmodified lines
605604 glEnable(GL_LINE_SMOOTH);
606605
607606 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
608− _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
609607 if (!OculusManager::isConnected()) {
610− _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition());
611− _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
608+ // If there isn't an HMD, match exactly to avatar's head
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());
612615 }
613− // OculusManager::display() updates camera position and rotation a bit further on.
614616
615617 } 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.
617− _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
618− _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());
618+ static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
619+ _myCamera.setPosition(_myAvatar->getUprightHeadPosition() +
620+ _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
619621 if (OculusManager::isConnected()) {
620− _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation());
622+ _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
621623 } else {
622− _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation());
624+ _myCamera.setRotation(_myAvatar->getHead()->getOrientation());
623625 }
624626
625627 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
626− _myCamera.setTightness(0.0f);
627628 //Only behave like a true mirror when in the OR
628629 if (OculusManager::isConnected()) {
629− _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
630− _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
631− _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0));
630+ _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
631+ _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
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);
632635 } else {
633− _myCamera.setTightness(0.0f);
634− glm::vec3 eyePosition = _myAvatar->getHead()->getEyePosition();
635− float headHeight = eyePosition.y - _myAvatar->getPosition().y;
636− _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
637− _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0));
638− _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
636+ _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
637+ _myCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
638+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) +
639+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
640+ glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
639641 }
640642 }
641643
@@ -659,12 +661,13 @@ void Application::paintGL() { · 17 unmodified lines
659661 ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset();
660662
661663 // set the camera to third-person view but offset so we can see the frustum
662− _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition());
663− _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3(
664− viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll))));
665− _viewFrustumOffsetCamera.setUpShift(viewFrustumOffset.up);
666− _viewFrustumOffsetCamera.setDistance(viewFrustumOffset.distance);
667− _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation
664+ glm::quat frustumRotation = glm::quat(glm::radians(glm::vec3(viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll)));
665+
666+ _viewFrustumOffsetCamera.setPosition(_myCamera.getPosition() +
667+ frustumRotation * glm::vec3(0.0f, viewFrustumOffset.up, -viewFrustumOffset.distance));
668+
669+ _viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);
670+
668671 _viewFrustumOffsetCamera.update(1.f/_fps);
669672 whichCamera = &_viewFrustumOffsetCamera;
670673 }
@@ -883,7 +886,11 @@ void Application::keyPressEvent(QKeyEvent* event) { · 212 unmodified lines
883886 break;
884887
885888 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+ }
887894 break;
888895
889896 case Qt::Key_S:
@@ -1781,10 +1788,8 @@ void Application::init() { · 891 unmodified lines
17811788 // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
17821789 _avatarManager.init();
17831790 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
1784− _myCamera.setModeShiftPeriod(1.0f);
17851791
17861792 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
1787− _mirrorCamera.setModeShiftPeriod(0.0f);
17881793
17891794 OculusManager::connect();
17901795 if (OculusManager::isConnected()) {
@@ -2124,17 +2129,14 @@ void Application::cameraMenuChanged() { · 333 unmodified lines
21242129 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
21252130 if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
21262131 _myCamera.setMode(CAMERA_MODE_MIRROR);
2127− _myCamera.setModeShiftPeriod(0.0f);
21282132 }
21292133 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) {
21302134 if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) {
21312135 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
2132− _myCamera.setModeShiftPeriod(modeShiftPeriod);
21332136 }
21342137 } else {
21352138 if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {
21362139 _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
2137− _myCamera.setModeShiftPeriod(modeShiftPeriod);
21382140 }
21392141 }
21402142 }
@@ -2908,10 +2910,8 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 767 unmodified lines
29082910 // draw a red sphere
29092911 float originSphereRadius = 0.05f;
29102912 glColor3f(1,0,0);
2911− glPushMatrix();
2912− glutSolidSphere(originSphereRadius, 15, 15);
2913− glPopMatrix();
2914−
2913+ _geometryCache.renderSphere(originSphereRadius, 15, 15);
2914+
29152915 // draw the audio reflector overlay
29162916 {
29172917 PerformanceTimer perfTimer("audio");
@@ -2966,7 +2966,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 48 unmodified lines
29662966 }
29672967 }
29682968
2969− bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR);
2969+ bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR);
29702970 {
29712971 PerformanceTimer perfTimer("avatars");
29722972 _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
31053105 bool eyeRelativeCamera = false;
31063106 if (billboard) {
31073107 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
3108− _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale());
3109− _mirrorCamera.setTargetPosition(_myAvatar->getPosition());
3108+ _mirrorCamera.setPosition(_myAvatar->getPosition() +
3109+ _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
31103110
31113111 } else if (_rearMirrorTools->getZoomLevel() == BODY) {
31123112 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
3113− _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
3114− _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());
3113+ _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
3114+ _myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
31153115
31163116 } else { // HEAD zoom level
31173117 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
3118− _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
31193118 if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead()->getFaceModel().isActive()) {
31203119 // as a hack until we have a better way of dealing with coordinate precision issues, reposition the
31213120 // face/body so that the average eye position lies at the origin
31223121 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());
31243123
31253124 } 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());
31273127 }
31283128 }
31293129 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
31303130
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)));
31323132 _mirrorCamera.update(1.0f/_fps);
31333133
31343134 // set the bounds of rear mirror view
@@ -3468,9 +3468,9 @@ void Application::updateWindowTitle(){ · 333 unmodified lines
34683468 void Application::updateLocationInServer() {
34693469
34703470 AccountManager& accountManager = AccountManager::getInstance();
3471− const QUuid& domainUUID = NodeList::getInstance()->getDomainHandler().getUUID();
3471+ DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler();
34723472
3473− if (accountManager.isLoggedIn() && !domainUUID.isNull()) {
3473+ if (accountManager.isLoggedIn() && domainHandler.isConnected() && !domainHandler.getUUID().isNull()) {
34743474
34753475 // construct a QJsonObject given the user's current address information
34763476 QJsonObject rootObject;
@@ -3484,7 +3484,7 @@ void Application::updateLocationInServer() { · 7 unmodified lines
34843484 const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
34853485
34863486 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());
34883488
34893489 rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
34903490

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t