Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -69,6 +69,11 @@ · 68 unmodified lines | ||
| 69 | 69 | #include "ui/TextRenderer.h" |
| 70 | 70 | #include "InfoView.h" |
| 71 | 71 | |
| 72 | +#include <QSvgRenderer> | |
| 73 | +#include <QPainter> | |
| 74 | +#include <QGLWidget> | |
| 75 | +#include <SharedUtil.h> | |
| 76 | + | |
| 72 | 77 | using namespace std; |
| 73 | 78 | |
| 74 | 79 | // Starfield information |
| @@ -85,11 +90,12 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 10 unmodified lines | ||
| 85 | 90 | // Startup optimistically with small jitter buffer that |
| 86 | 91 | // will start playback on the second received audio packet. |
| 87 | 92 | |
| 88 | − | |
| 89 | 93 | const int MIRROR_VIEW_TOP_PADDING = 5; |
| 90 | 94 | const int MIRROR_VIEW_LEFT_PADDING = 10; |
| 91 | 95 | const int MIRROR_VIEW_WIDTH = 265; |
| 92 | 96 | const int MIRROR_VIEW_HEIGHT = 215; |
| 97 | +const int MIRROR_ICON_SIZE = 16; | |
| 98 | +const int MIRROR_CLOSE_ICON_PADDING = 5; | |
| 93 | 99 | |
| 94 | 100 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 95 | 101 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| @@ -258,12 +264,12 @@ void Application::restoreSizeAndPosition() { · 162 unmodified lines | ||
| 258 | 264 | |
| 259 | 265 | settings->beginGroup("Window"); |
| 260 | 266 | |
| 261 | − float x = loadSetting(settings, "x", 0); | |
| 262 | − float y = loadSetting(settings, "y", 0); | |
| 267 | + int x = (int) loadSetting(settings, "x", 0); | |
| 268 | + int y = (int) loadSetting(settings, "y", 0); | |
| 263 | 269 | _window->move(x, y); |
| 264 | 270 | |
| 265 | − int width = loadSetting(settings, "width", available.width()); | |
| 266 | − int height = loadSetting(settings, "height", available.height()); | |
| 271 | + int width = (int) loadSetting(settings, "width", available.width()); | |
| 272 | + int height = (int) loadSetting(settings, "height", available.height()); | |
| 267 | 273 | _window->resize(width, height); |
| 268 | 274 | |
| 269 | 275 | settings->endGroup(); |
| @@ -427,7 +433,6 @@ void Application::paintGL() { · 157 unmodified lines | ||
| 427 | 433 | _glowEffect.render(); |
| 428 | 434 | |
| 429 | 435 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 430 | − | |
| 431 | 436 | glm::vec3 targetPosition = _myAvatar.getEyeLevelPosition(); |
| 432 | 437 | if (_myAvatar.getHead().getBlendFace().isActive()) { |
| 433 | 438 | // make sure we're aligned to the blend face eyes |
| @@ -441,21 +446,30 @@ void Application::paintGL() { · 7 unmodified lines | ||
| 441 | 446 | _mirrorCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f))); |
| 442 | 447 | _mirrorCamera.update(1.0f/_fps); |
| 443 | 448 | |
| 444 | − glViewport(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 445 | − glScissor(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 446 | − | |
| 449 | + // set the bounds of rear mirror view | |
| 450 | + glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height()); | |
| 451 | + glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height()); | |
| 447 | 452 | updateProjectionMatrix(_mirrorCamera); |
| 448 | − | |
| 449 | 453 | glEnable(GL_SCISSOR_TEST); |
| 450 | 454 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 455 | + | |
| 456 | + // render rear mirror view | |
| 451 | 457 | glPushMatrix(); |
| 452 | 458 | displaySide(_mirrorCamera); |
| 453 | 459 | glPopMatrix(); |
| 454 | 460 | |
| 455 | − // reset Viewport | |
| 461 | + // render rear view tools if mouse is in the bounds | |
| 462 | + QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos()); | |
| 463 | + | |
| 464 | + qDebug("mouse pos: x = %d, y = %d\n", mousePosition.x(), mousePosition.y()); | |
| 465 | + | |
| 466 | + if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) { | |
| 467 | + displayRearMirrorTools(); | |
| 468 | + } | |
| 469 | + | |
| 470 | + // reset Viewport and projection matrix | |
| 456 | 471 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 457 | 472 | glDisable(GL_SCISSOR_TEST); |
| 458 | − | |
| 459 | 473 | updateProjectionMatrix(); |
| 460 | 474 | } |
| 461 | 475 | |
| @@ -481,6 +495,8 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 19 unmodified lines | ||
| 481 | 495 | void Application::resizeGL(int width, int height) { |
| 482 | 496 | resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); |
| 483 | 497 | resetCamerasOnResizeGL(_myCamera, width, height); |
| 498 | + | |
| 499 | + _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 484 | 500 | |
| 485 | 501 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? |
| 486 | 502 | |
| @@ -1024,7 +1040,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 537 unmodified lines | ||
| 1024 | 1040 | if (activeWindow() == _window) { |
| 1025 | 1041 | _mouseX = event->x(); |
| 1026 | 1042 | _mouseY = event->y(); |
| 1027 | − | |
| 1043 | + | |
| 1028 | 1044 | // detect drag |
| 1029 | 1045 | glm::vec3 mouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); |
| 1030 | 1046 | if (!_justEditedVoxel && mouseVoxelPos != _lastMouseVoxelPos) { |
| @@ -1062,6 +1078,15 @@ void Application::mousePressEvent(QMouseEvent* event) { · 31 unmodified lines | ||
| 1062 | 1078 | return; |
| 1063 | 1079 | } |
| 1064 | 1080 | |
| 1081 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1082 | + | |
| 1083 | + QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE); | |
| 1084 | + | |
| 1085 | + if (closeIconRect.contains(_mouseX, _mouseY)) { | |
| 1086 | + Menu::getInstance()->triggerOption(MenuOption::Mirror); | |
| 1087 | + } | |
| 1088 | + } | |
| 1089 | + | |
| 1065 | 1090 | if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) { |
| 1066 | 1091 | _pieMenu.mousePressEvent(_mouseX, _mouseY); |
| 1067 | 1092 | } |
| @@ -1636,11 +1661,14 @@ void Application::init() { · 568 unmodified lines | ||
| 1636 | 1661 | _myAvatar.setPosition(START_LOCATION); |
| 1637 | 1662 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1638 | 1663 | _myCamera.setModeShiftRate(1.0f); |
| 1639 | − _myAvatar.setDisplayingLookatVectors(false); | |
| 1664 | + _myAvatar.setDisplayingLookatVectors(false); | |
| 1665 | + | |
| 1640 | 1666 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1641 | − _mirrorCamera.setModeShiftRate(1.0f); | |
| 1642 | 1667 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); |
| 1643 | − _mirrorCamera.setFieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES); | |
| 1668 | + _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); | |
| 1669 | + | |
| 1670 | + switchToResourcesParentIfRequired(); | |
| 1671 | + _closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png")); | |
| 1644 | 1672 | |
| 1645 | 1673 | OculusManager::connect(); |
| 1646 | 1674 | if (OculusManager::isConnected()) { |
| @@ -2472,15 +2500,6 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 825 unmodified lines | ||
| 2472 | 2500 | float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { |
| 2473 | 2501 | |
| 2474 | 2502 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane); |
| 2475 | − | |
| 2476 | − /* | |
| 2477 | − // when mirrored, we must flip left and right | |
| 2478 | − if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 2479 | − float tmp = left; | |
| 2480 | − left = -right; | |
| 2481 | − right = -tmp; | |
| 2482 | − } | |
| 2483 | − */ | |
| 2484 | 2503 | } |
| 2485 | 2504 | |
| 2486 | 2505 | void Application::displaySide(Camera& whichCamera) { |
| @@ -2730,7 +2749,7 @@ void Application::displaySide(Camera& whichCamera) { · 243 unmodified lines | ||
| 2730 | 2749 | } |
| 2731 | 2750 | |
| 2732 | 2751 | // brad's frustum for debugging |
| 2733 | − if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { | |
| 2752 | + if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) { | |
| 2734 | 2753 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2735 | 2754 | "Application::displaySide() ... renderViewFrustum..."); |
| 2736 | 2755 | renderViewFrustum(_viewFrustum); |
| @@ -2962,7 +2981,7 @@ void Application::displayOverlay() { · 225 unmodified lines | ||
| 2962 | 2981 | if (_pieMenu.isDisplayed()) { |
| 2963 | 2982 | _pieMenu.render(); |
| 2964 | 2983 | } |
| 2965 | − | |
| 2984 | + | |
| 2966 | 2985 | glPopMatrix(); |
| 2967 | 2986 | } |
| 2968 | 2987 | |
| @@ -3781,3 +3800,42 @@ void* Application::networkReceive(void* args) { · 812 unmodified lines | ||
| 3781 | 3800 | void Application::packetSentNotification(ssize_t length) { |
| 3782 | 3801 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); |
| 3783 | 3802 | } |
| 3803 | + | |
| 3804 | +void Application::displayRearMirrorTools() { | |
| 3805 | + | |
| 3806 | + glMatrixMode(GL_PROJECTION); | |
| 3807 | + glPushMatrix(); | |
| 3808 | + glLoadIdentity(); | |
| 3809 | + gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top()); | |
| 3810 | + glDisable(GL_DEPTH_TEST); | |
| 3811 | + glDisable(GL_LIGHTING); | |
| 3812 | + | |
| 3813 | + glEnable(GL_TEXTURE_2D); | |
| 3814 | + glBindTexture(GL_TEXTURE_2D, _closeTextureId); | |
| 3815 | + | |
| 3816 | + glColor3f(1, 1, 1); | |
| 3817 | + glBegin(GL_QUADS); | |
| 3818 | + | |
| 3819 | + int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(); | |
| 3820 | + int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(); | |
| 3821 | + int lwp = MIRROR_ICON_SIZE + lp; | |
| 3822 | + int twp = MIRROR_ICON_SIZE + tp; | |
| 3823 | + | |
| 3824 | + glTexCoord2f(1, 1); | |
| 3825 | + glVertex2f(lp, tp); | |
| 3826 | + | |
| 3827 | + glTexCoord2f(0, 1); | |
| 3828 | + glVertex2f(lwp, tp); | |
| 3829 | + | |
| 3830 | + glTexCoord2f(0, 0); | |
| 3831 | + glVertex2f(lwp, twp); | |
| 3832 | + | |
| 3833 | + glTexCoord2f(1, 0); | |
| 3834 | + glVertex2f(lp, twp); | |
| 3835 | + | |
| 3836 | + glEnd(); | |
| 3837 | + | |
| 3838 | + glPopMatrix(); | |
| 3839 | + | |
| 3840 | + glDisable(GL_TEXTURE_2D); | |
| 3841 | +} | |