Showing the changes to interface/src/Application.cpp (1 of 28 files). Show all
Unified · Split
| @@ -26,17 +26,11 @@ · 25 unmodified lines | |||
| 26 | #include "InterfaceConfig.h" | 26 | #include "InterfaceConfig.h" |
| 27 | 27 | ||
| 28 | #include <QActionGroup> | 28 | #include <QActionGroup> |
| 29 | #include <QBoxLayout> | ||
| 30 | #include <QColorDialog> | 29 | #include <QColorDialog> |
| 31 | #include <QDialogButtonBox> | ||
| 32 | #include <QDesktopWidget> | 30 | #include <QDesktopWidget> |
| 33 | #include <QDoubleSpinBox> | ||
| 34 | #include <QCheckBox> | 31 | #include <QCheckBox> |
| 35 | #include <QFormLayout> | ||
| 36 | #include <QGLWidget> | ||
| 37 | #include <QImage> | 32 | #include <QImage> |
| 38 | #include <QKeyEvent> | 33 | #include <QKeyEvent> |
| 39 | #include <QLineEdit> | ||
| 40 | #include <QMainWindow> | 34 | #include <QMainWindow> |
| 41 | #include <QMenuBar> | 35 | #include <QMenuBar> |
| 42 | #include <QMouseEvent> | 36 | #include <QMouseEvent> |
| @@ -64,6 +58,7 @@ · 21 unmodified lines | |||
| 64 | #include "Application.h" | 58 | #include "Application.h" |
| 65 | #include "LogDisplay.h" | 59 | #include "LogDisplay.h" |
| 66 | #include "LeapManager.h" | 60 | #include "LeapManager.h" |
| 61 | #include "Menu.h" | ||
| 67 | #include "OculusManager.h" | 62 | #include "OculusManager.h" |
| 68 | #include "Util.h" | 63 | #include "Util.h" |
| 69 | #include "renderer/ProgramObject.h" | 64 | #include "renderer/ProgramObject.h" |
| @@ -79,11 +74,6 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; · 9 unmodified lines | |||
| 79 | 74 | ||
| 80 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored | 75 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 81 | 76 | ||
| 82 | // Where one's own Avatar begins in the world (will be overwritten if avatar data file is found) | ||
| 83 | // this is basically in the center of the ground plane. Slightly adjusted. This was asked for by | ||
| 84 | // Grayson as he's building a street around here for demo dinner 2 | ||
| 85 | const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); | ||
| 86 | |||
| 87 | const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff | 77 | const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff |
| 88 | // in the idle loop? (60 FPS is default) | 78 | // in the idle loop? (60 FPS is default) |
| 89 | static QTimer* idleTimer = NULL; | 79 | static QTimer* idleTimer = NULL; |
| @@ -92,87 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 2 unmodified lines | |||
| 92 | // Startup optimistically with small jitter buffer that | 82 | // Startup optimistically with small jitter buffer that |
| 93 | // will start playback on the second received audio packet. | 83 | // will start playback on the second received audio packet. |
| 94 | 84 | ||
| 95 | // customized canvas that simply forwards requests/events to the singleton application | ||
| 96 | class GLCanvas : public QGLWidget { | ||
| 97 | public: | ||
| 98 | GLCanvas(); | ||
| 99 | protected: | ||
| 100 | |||
| 101 | virtual void initializeGL(); | ||
| 102 | virtual void paintGL(); | ||
| 103 | virtual void resizeGL(int width, int height); | ||
| 104 | |||
| 105 | virtual void keyPressEvent(QKeyEvent* event); | ||
| 106 | virtual void keyReleaseEvent(QKeyEvent* event); | ||
| 107 | |||
| 108 | virtual void mouseMoveEvent(QMouseEvent* event); | ||
| 109 | virtual void mousePressEvent(QMouseEvent* event); | ||
| 110 | virtual void mouseReleaseEvent(QMouseEvent* event); | ||
| 111 | |||
| 112 | virtual bool event(QEvent* event); | ||
| 113 | |||
| 114 | virtual void wheelEvent(QWheelEvent* event); | ||
| 115 | }; | ||
| 116 | |||
| 117 | GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) { | ||
| 118 | } | ||
| 119 | |||
| 120 | void GLCanvas::initializeGL() { | ||
| 121 | Application::getInstance()->initializeGL(); | ||
| 122 | setAttribute(Qt::WA_AcceptTouchEvents); | ||
| 123 | } | ||
| 124 | |||
| 125 | void GLCanvas::paintGL() { | ||
| 126 | Application::getInstance()->paintGL(); | ||
| 127 | } | ||
| 128 | |||
| 129 | void GLCanvas::resizeGL(int width, int height) { | ||
| 130 | Application::getInstance()->resizeGL(width, height); | ||
| 131 | } | ||
| 132 | |||
| 133 | void GLCanvas::keyPressEvent(QKeyEvent* event) { | ||
| 134 | Application::getInstance()->keyPressEvent(event); | ||
| 135 | } | ||
| 136 | |||
| 137 | void GLCanvas::keyReleaseEvent(QKeyEvent* event) { | ||
| 138 | Application::getInstance()->keyReleaseEvent(event); | ||
| 139 | } | ||
| 140 | |||
| 141 | void GLCanvas::mouseMoveEvent(QMouseEvent* event) { | ||
| 142 | Application::getInstance()->mouseMoveEvent(event); | ||
| 143 | } | ||
| 144 | |||
| 145 | void GLCanvas::mousePressEvent(QMouseEvent* event) { | ||
| 146 | Application::getInstance()->mousePressEvent(event); | ||
| 147 | } | ||
| 148 | |||
| 149 | void GLCanvas::mouseReleaseEvent(QMouseEvent* event) { | ||
| 150 | Application::getInstance()->mouseReleaseEvent(event); | ||
| 151 | } | ||
| 152 | |||
| 153 | int updateTime = 0; | ||
| 154 | bool GLCanvas::event(QEvent* event) { | ||
| 155 | switch (event->type()) { | ||
| 156 | case QEvent::TouchBegin: | ||
| 157 | Application::getInstance()->touchBeginEvent(static_cast<QTouchEvent*>(event)); | ||
| 158 | event->accept(); | ||
| 159 | return true; | ||
| 160 | case QEvent::TouchEnd: | ||
| 161 | Application::getInstance()->touchEndEvent(static_cast<QTouchEvent*>(event)); | ||
| 162 | return true; | ||
| 163 | case QEvent::TouchUpdate: | ||
| 164 | Application::getInstance()->touchUpdateEvent(static_cast<QTouchEvent*>(event)); | ||
| 165 | return true; | ||
| 166 | default: | ||
| 167 | break; | ||
| 168 | } | ||
| 169 | return QGLWidget::event(event); | ||
| 170 | } | ||
| 171 | |||
| 172 | void GLCanvas::wheelEvent(QWheelEvent* event) { | ||
| 173 | Application::getInstance()->wheelEvent(event); | ||
| 174 | } | ||
| 175 | |||
| 176 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { | 85 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 177 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); | 86 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| 178 | LogDisplay::instance.addMessage(message.toLocal8Bit().constData()); | 87 | LogDisplay::instance.addMessage(message.toLocal8Bit().constData()); |
| @@ -182,22 +91,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | |||
| 182 | QApplication(argc, argv), | 91 | QApplication(argc, argv), |
| 183 | _window(new QMainWindow(desktop())), | 92 | _window(new QMainWindow(desktop())), |
| 184 | _glWidget(new GLCanvas()), | 93 | _glWidget(new GLCanvas()), |
| 185 | _bandwidthDialog(NULL), | ||
| 186 | _voxelStatsDialog(NULL), | ||
| 187 | _displayLevels(false), | 94 | _displayLevels(false), |
| 188 | _frameCount(0), | 95 | _frameCount(0), |
| 189 | _fps(120.0f), | 96 | _fps(120.0f), |
| 190 | _justStarted(true), | 97 | _justStarted(true), |
| 191 | _particleSystemInitialized(false), | ||
| 192 | _coolDemoParticleEmitter(-1), | ||
| 193 | _voxelImporter(_window), | 98 | _voxelImporter(_window), |
| 194 | _wantToKillLocalVoxels(false), | 99 | _wantToKillLocalVoxels(false), |
| 195 | _frustumDrawingMode(FRUSTUM_DRAW_MODE_ALL), | ||
| 196 | _viewFrustumOffsetYaw(-135.0), | ||
| 197 | _viewFrustumOffsetPitch(0.0), | ||
| 198 | _viewFrustumOffsetRoll(0.0), | ||
| 199 | _viewFrustumOffsetDistance(25.0), | ||
| 200 | _viewFrustumOffsetUp(0.0), | ||
| 201 | _audioScope(256, 200, true), | 100 | _audioScope(256, 200, true), |
| 202 | _mouseX(0), | 101 | _mouseX(0), |
| 203 | _mouseY(0), | 102 | _mouseY(0), |
| @@ -255,7 +154,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 51 unmodified lines | |||
| 255 | } | 154 | } |
| 256 | 155 | ||
| 257 | // setup QSettings | 156 | // setup QSettings |
| 258 | #ifdef Q_WS_MAC | 157 | #ifdef Q_OS_MAC |
| 259 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; | 158 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; |
| 260 | #else | 159 | #else |
| 261 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; | 160 | QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; |
| @@ -312,13 +211,16 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 50 unmodified lines | |||
| 312 | 211 | ||
| 313 | _window->setCentralWidget(_glWidget); | 212 | _window->setCentralWidget(_glWidget); |
| 314 | 213 | ||
| 315 | #if defined(Q_WS_MAC) && defined(QT_NO_DEBUG) | 214 | #if defined(Q_OS_MAC) && defined(QT_NO_DEBUG) |
| 316 | // if this is a release OS X build use fervor to check for an update | 215 | // if this is a release OS X build use fervor to check for an update |
| 317 | FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); | 216 | FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); |
| 318 | FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); | 217 | FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); |
| 319 | #endif | 218 | #endif |
| 320 | 219 | ||
| 321 | initMenu(); | 220 | // call Menu getInstance static method to set up the menur |
| 221 | Menu::getInstance(); | ||
| 222 | |||
| 223 | _networkAccessManager = new QNetworkAccessManager(this); | ||
| 322 | 224 | ||
| 323 | QRect available = desktop()->availableGeometry(); | 225 | QRect available = desktop()->availableGeometry(); |
| 324 | _window->resize(available.size()); | 226 | _window->resize(available.size()); |
| @@ -454,14 +356,16 @@ void Application::paintGL() { · 129 unmodified lines | |||
| 454 | // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera | 356 | // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera |
| 455 | Camera whichCamera = _myCamera; | 357 | Camera whichCamera = _myCamera; |
| 456 | 358 | ||
| 457 | if (_frustumOn->isChecked()) { | 359 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { |
| 360 | |||
| 361 | ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset(); | ||
| 458 | 362 | ||
| 459 | // set the camera to third-person view but offset so we can see the frustum | 363 | // set the camera to third-person view but offset so we can see the frustum |
| 460 | _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition()); | 364 | _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition()); |
| 461 | _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3( | 365 | _viewFrustumOffsetCamera.setTargetRotation(_myCamera.getTargetRotation() * glm::quat(glm::radians(glm::vec3( |
| 462 | _viewFrustumOffsetPitch, _viewFrustumOffsetYaw, _viewFrustumOffsetRoll)))); | 366 | viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll)))); |
| 463 | _viewFrustumOffsetCamera.setUpShift (_viewFrustumOffsetUp ); | 367 | _viewFrustumOffsetCamera.setUpShift(viewFrustumOffset.up); |
| 464 | _viewFrustumOffsetCamera.setDistance (_viewFrustumOffsetDistance); | 368 | _viewFrustumOffsetCamera.setDistance(viewFrustumOffset.distance); |
| 465 | _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation | 369 | _viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation |
| 466 | _viewFrustumOffsetCamera.update(1.f/_fps); | 370 | _viewFrustumOffsetCamera.update(1.f/_fps); |
| 467 | whichCamera = _viewFrustumOffsetCamera; | 371 | whichCamera = _viewFrustumOffsetCamera; |
| @@ -491,7 +395,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 23 unmodified lines | |||
| 491 | camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); | 395 | camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); |
| 492 | } else { | 396 | } else { |
| 493 | camera.setAspectRatio(aspectRatio); | 397 | camera.setAspectRatio(aspectRatio); |
| 494 | camera.setFieldOfView(_fieldOfView); | 398 | camera.setFieldOfView(Menu::getInstance()->getFieldOfView()); |
| 495 | } | 399 | } |
| 496 | } | 400 | } |
| 497 | 401 | ||
| @@ -521,7 +425,7 @@ void Application::resizeGL(int width, int height) { · 23 unmodified lines | |||
| 521 | 425 | ||
| 522 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the | 426 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the |
| 523 | // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum | 427 | // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum |
| 524 | if (_frustumOn->isChecked()) { | 428 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { |
| 525 | nearVal = _viewFrustumOffsetCamera.getNearClip(); | 429 | nearVal = _viewFrustumOffsetCamera.getNearClip(); |
| 526 | farVal = _viewFrustumOffsetCamera.getFarClip(); | 430 | farVal = _viewFrustumOffsetCamera.getFarClip(); |
| 527 | } | 431 | } |
| @@ -537,7 +441,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 9 unmodified lines | |||
| 537 | for (int i = 0; i < numNodeTypes; ++i) { | 441 | for (int i = 0; i < numNodeTypes; ++i) { |
| 538 | 442 | ||
| 539 | // Intercept data to voxel server when voxels are disabled | 443 | // Intercept data to voxel server when voxels are disabled |
| 540 | if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && ! self->_renderVoxels->isChecked()) { | 444 | if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 541 | continue; | 445 | continue; |
| 542 | } | 446 | } |
| 543 | 447 | ||
| @@ -579,53 +483,25 @@ void Application::keyPressEvent(QKeyEvent* event) { · 35 unmodified lines | |||
| 579 | } | 483 | } |
| 580 | 484 | ||
| 581 | //this is for switching between modes for the leap rave glove test | 485 | //this is for switching between modes for the leap rave glove test |
| 582 | if (_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()) { | 486 | if (Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand) |
| 487 | || Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)) { | ||
| 583 | _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); | 488 | _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); |
| 584 | } | 489 | } |
| 585 | 490 | ||
| 586 | bool isMeta = event->modifiers().testFlag(Qt::MetaModifier); | ||
| 587 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); | 491 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); |
| 588 | switch (event->key()) { | 492 | switch (event->key()) { |
| 589 | case Qt::Key_BracketLeft: | 493 | case Qt::Key_BracketLeft: |
| 590 | _viewFrustumOffsetYaw -= 0.5; | ||
| 591 | break; | ||
| 592 | |||
| 593 | case Qt::Key_BracketRight: | 494 | case Qt::Key_BracketRight: |
| 594 | _viewFrustumOffsetYaw += 0.5; | ||
| 595 | break; | ||
| 596 | |||
| 597 | case Qt::Key_BraceLeft: | 495 | case Qt::Key_BraceLeft: |
| 598 | _viewFrustumOffsetPitch -= 0.5; | ||
| 599 | break; | ||
| 600 | |||
| 601 | case Qt::Key_BraceRight: | 496 | case Qt::Key_BraceRight: |
| 602 | _viewFrustumOffsetPitch += 0.5; | ||
| 603 | break; | ||
| 604 | |||
| 605 | case Qt::Key_ParenLeft: | 497 | case Qt::Key_ParenLeft: |
| 606 | _viewFrustumOffsetRoll -= 0.5; | ||
| 607 | break; | ||
| 608 | |||
| 609 | case Qt::Key_ParenRight: | 498 | case Qt::Key_ParenRight: |
| 610 | _viewFrustumOffsetRoll += 0.5; | ||
| 611 | break; | ||
| 612 | |||
| 613 | case Qt::Key_Less: | 499 | case Qt::Key_Less: |
| 614 | _viewFrustumOffsetDistance -= 0.5; | ||
| 615 | break; | ||
| 616 | |||
| 617 | case Qt::Key_Greater: | 500 | case Qt::Key_Greater: |
| 618 | _viewFrustumOffsetDistance += 0.5; | ||
| 619 | break; | ||
| 620 | |||
| 621 | case Qt::Key_Comma: | 501 | case Qt::Key_Comma: |
| 622 | _viewFrustumOffsetUp -= 0.05; | ||
| 623 | break; | ||
| 624 | |||
| 625 | case Qt::Key_Period: | 502 | case Qt::Key_Period: |
| 626 | _viewFrustumOffsetUp += 0.05; | 503 | Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key()); |
| 627 | break; | 504 | break; |
| 628 | |||
| 629 | case Qt::Key_Semicolon: | 505 | case Qt::Key_Semicolon: |
| 630 | _audio.ping(); | 506 | _audio.ping(); |
| 631 | break; | 507 | break; |
| @@ -645,9 +521,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | |||
| 645 | 521 | ||
| 646 | case Qt::Key_C: | 522 | case Qt::Key_C: |
| 647 | if (isShifted) { | 523 | if (isShifted) { |
| 648 | _occlusionCulling->trigger(); | 524 | Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling); |
| 649 | } else if (isMeta) { | ||
| 650 | chooseVoxelPaintColor(); | ||
| 651 | } else { | 525 | } else { |
| 652 | _myAvatar.setDriveKeys(DOWN, 1); | 526 | _myAvatar.setDriveKeys(DOWN, 1); |
| 653 | } | 527 | } |
| @@ -659,7 +533,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | |||
| 659 | 533 | ||
| 660 | case Qt::Key_S: | 534 | case Qt::Key_S: |
| 661 | if (isShifted) { | 535 | if (isShifted) { |
| 662 | doTreeStats(); | 536 | _voxels.collectStatsForTreesAndVBOs(); |
| 663 | } else { | 537 | } else { |
| 664 | _myAvatar.setDriveKeys(BACK, 1); | 538 | _myAvatar.setDriveKeys(BACK, 1); |
| 665 | } | 539 | } |
| @@ -672,15 +546,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 6 unmodified lines | |||
| 672 | 546 | ||
| 673 | case Qt::Key_G: | 547 | case Qt::Key_G: |
| 674 | if (isShifted) { | 548 | if (isShifted) { |
| 675 | _gravityUse->trigger(); | 549 | Menu::getInstance()->triggerOption(MenuOption::Gravity); |
| 676 | } else { | 550 | } else { |
| 677 | _eyedropperMode->trigger(); | 551 | Menu::getInstance()->triggerOption(MenuOption::VoxelGetColorMode); |
| 678 | } | 552 | } |
| 679 | break; | 553 | break; |
| 680 | 554 | ||
| 681 | case Qt::Key_A: | 555 | case Qt::Key_A: |
| 682 | if (isShifted) { | 556 | if (isShifted) { |
| 683 | _renderAtmosphereOn->trigger(); | 557 | Menu::getInstance()->triggerOption(MenuOption::Atmosphere); |
| 684 | } else { | 558 | } else { |
| 685 | _myAvatar.setDriveKeys(ROT_LEFT, 1); | 559 | _myAvatar.setDriveKeys(ROT_LEFT, 1); |
| 686 | } | 560 | } |
| @@ -773,56 +647,53 @@ void Application::keyPressEvent(QKeyEvent* event) { · 86 unmodified lines | |||
| 773 | } | 647 | } |
| 774 | resizeGL(_glWidget->width(), _glWidget->height()); | 648 | resizeGL(_glWidget->width(), _glWidget->height()); |
| 775 | break; | 649 | break; |
| 776 | case Qt::Key_N: | ||
| 777 | _noise->trigger(); | ||
| 778 | break; | ||
| 779 | case Qt::Key_H: | 650 | case Qt::Key_H: |
| 780 | _lookingInMirror->trigger(); | 651 | Menu::getInstance()->triggerOption(MenuOption::Mirror); |
| 781 | break; | 652 | break; |
| 782 | case Qt::Key_F: | 653 | case Qt::Key_F: |
| 783 | if (isShifted) { | 654 | if (isShifted) { |
| 784 | _frustumOn->trigger(); | 655 | Menu::getInstance()->triggerOption(MenuOption::DisplayFrustum); |
| 785 | } else { | 656 | } else { |
| 786 | _fullScreenMode->trigger(); | 657 | Menu::getInstance()->triggerOption(MenuOption::Fullscreen); |
| 787 | } | 658 | } |
| 788 | break; | 659 | break; |
| 789 | case Qt::Key_V: | 660 | case Qt::Key_V: |
| 790 | if (isShifted) { | 661 | if (isShifted) { |
| 791 | _renderVoxels->trigger(); | 662 | Menu::getInstance()->triggerOption(MenuOption::Voxels); |
| 792 | } else { | 663 | } else { |
| 793 | _addVoxelMode->trigger(); | 664 | Menu::getInstance()->triggerOption(MenuOption::VoxelAddMode); |
| 794 | } | 665 | } |
| 795 | break; | 666 | break; |
| 796 | case Qt::Key_P: | 667 | case Qt::Key_P: |
| 797 | _manualFirstPerson->trigger(); | 668 | Menu::getInstance()->triggerOption(MenuOption::FirstPerson); |
| 798 | break; | 669 | break; |
| 799 | case Qt::Key_R: | 670 | case Qt::Key_R: |
| 800 | if (isShifted) { | 671 | if (isShifted) { |
| 801 | _frustumRenderModeAction->trigger(); | 672 | Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode); |
| 802 | } else { | 673 | } else { |
| 803 | _deleteVoxelMode->trigger(); | 674 | Menu::getInstance()->triggerOption(MenuOption::VoxelDeleteMode); |
| 804 | } | 675 | } |
| 805 | break; | 676 | break; |
| 806 | case Qt::Key_B: | 677 | case Qt::Key_B: |
| 807 | _colorVoxelMode->trigger(); | 678 | Menu::getInstance()->triggerOption(MenuOption::VoxelColorMode); |
| 808 | break; | 679 | break; |
| 809 | case Qt::Key_O: | 680 | case Qt::Key_O: |
| 810 | _selectVoxelMode->trigger(); | 681 | Menu::getInstance()->triggerOption(MenuOption::VoxelSelectMode); |
| 811 | break; | 682 | break; |
| 812 | case Qt::Key_Slash: | 683 | case Qt::Key_Slash: |
| 813 | _renderStatsOn->trigger(); | 684 | Menu::getInstance()->triggerOption(MenuOption::Stats); |
| 814 | break; | 685 | break; |
| 815 | case Qt::Key_Backspace: | 686 | case Qt::Key_Backspace: |
| 816 | case Qt::Key_Delete: | 687 | case Qt::Key_Delete: |
| 817 | if (_selectVoxelMode->isChecked()) { | 688 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { |
| 818 | deleteVoxelUnderCursor(); | 689 | deleteVoxelUnderCursor(); |
| 819 | } | 690 | } |
| 820 | break; | 691 | break; |
| 821 | case Qt::Key_Plus: | 692 | case Qt::Key_Plus: |
| 822 | increaseAvatarSize(); | 693 | _myAvatar.increaseSize(); |
| 823 | break; | 694 | break; |
| 824 | case Qt::Key_Minus: | 695 | case Qt::Key_Minus: |
| 825 | decreaseAvatarSize(); | 696 | _myAvatar.decreaseSize(); |
| 826 | break; | 697 | break; |
| 827 | 698 | ||
| 828 | case Qt::Key_1: | 699 | case Qt::Key_1: |
| @@ -833,7 +704,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines | |||
| 833 | case Qt::Key_6: | 704 | case Qt::Key_6: |
| 834 | case Qt::Key_7: | 705 | case Qt::Key_7: |
| 835 | case Qt::Key_8: | 706 | case Qt::Key_8: |
| 836 | _swatch.handleEvent(event->key(), _eyedropperMode->isChecked()); | 707 | _swatch.handleEvent(event->key(), Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)); |
| 837 | break; | 708 | break; |
| 838 | default: | 709 | default: |
| 839 | event->ignore(); | 710 | event->ignore(); |
| @@ -912,7 +783,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 72 unmodified lines | |||
| 912 | if (event->buttons().testFlag(Qt::LeftButton)) { | 783 | if (event->buttons().testFlag(Qt::LeftButton)) { |
| 913 | maybeEditVoxelUnderCursor(); | 784 | maybeEditVoxelUnderCursor(); |
| 914 | 785 | ||
| 915 | } else if (event->buttons().testFlag(Qt::RightButton) && checkedVoxelModeAction() != 0) { | 786 | } else if (event->buttons().testFlag(Qt::RightButton) && Menu::getInstance()->isVoxelModeActionChecked()) { |
| 916 | deleteVoxelUnderCursor(); | 787 | deleteVoxelUnderCursor(); |
| 917 | } | 788 | } |
| 918 | } | 789 | } |
| @@ -960,7 +831,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 41 unmodified lines | |||
| 960 | _isHoverVoxelSounding = true; | 831 | _isHoverVoxelSounding = true; |
| 961 | } | 832 | } |
| 962 | 833 | ||
| 963 | } else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) { | 834 | } else if (event->button() == Qt::RightButton && Menu::getInstance()->isVoxelModeActionChecked()) { |
| 964 | deleteVoxelUnderCursor(); | 835 | deleteVoxelUnderCursor(); |
| 965 | } | 836 | } |
| 966 | } | 837 | } |
| @@ -1019,7 +890,7 @@ const bool USE_MOUSEWHEEL = false; · 52 unmodified lines | |||
| 1019 | void Application::wheelEvent(QWheelEvent* event) { | 890 | void Application::wheelEvent(QWheelEvent* event) { |
| 1020 | // Wheel Events disabled for now because they are also activated by touch look pitch up/down. | 891 | // Wheel Events disabled for now because they are also activated by touch look pitch up/down. |
| 1021 | if (USE_MOUSEWHEEL && (activeWindow() == _window)) { | 892 | if (USE_MOUSEWHEEL && (activeWindow() == _window)) { |
| 1022 | if (checkedVoxelModeAction() == 0) { | 893 | if (!Menu::getInstance()->isVoxelModeActionChecked()) { |
| 1023 | event->ignore(); | 894 | event->ignore(); |
| 1024 | return; | 895 | return; |
| 1025 | } | 896 | } |
| @@ -1079,7 +950,7 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 53 unmodified lines | |||
| 1079 | void Application::timer() { | 950 | void Application::timer() { |
| 1080 | gettimeofday(&_timerEnd, NULL); | 951 | gettimeofday(&_timerEnd, NULL); |
| 1081 | 952 | ||
| 1082 | if (_testPing->isChecked()) { | 953 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 1083 | sendPingPackets(); | 954 | sendPingPackets(); |
| 1084 | } | 955 | } |
| 1085 | 956 | ||
| @@ -1155,8 +1026,8 @@ void Application::terminate() { · 69 unmodified lines | |||
| 1155 | 1026 | ||
| 1156 | LeapManager::terminate(); | 1027 | LeapManager::terminate(); |
| 1157 | 1028 | ||
| 1158 | if (_settingsAutosave->isChecked()) { | 1029 | if (Menu::getInstance()->isOptionChecked(MenuOption::SettingsAutosave)) { |
| 1159 | saveSettings(); | 1030 | Menu::getInstance()->saveSettings(); |
| 1160 | _settings->sync(); | 1031 | _settings->sync(); |
| 1161 | } | 1032 | } |
| 1162 | 1033 | ||
| @@ -1169,24 +1040,6 @@ void Application::terminate() { · 6 unmodified lines | |||
| 1169 | _voxelEditSender.terminate(); | 1040 | _voxelEditSender.terminate(); |
| 1170 | } | 1041 | } |
| 1171 | 1042 | ||
| 1172 | void Application::sendAvatarVoxelURLMessage(const QUrl& url) { | ||
| 1173 | uint16_t ownerID = NodeList::getInstance()->getOwnerID(); | ||
| 1174 | |||
| 1175 | if (ownerID == UNKNOWN_NODE_ID) { | ||
| 1176 | return; // we don't yet know who we are | ||
| 1177 | } | ||
| 1178 | QByteArray message; | ||
| 1179 | |||
| 1180 | char packetHeader[MAX_PACKET_HEADER_BYTES]; | ||
| 1181 | int numBytesPacketHeader = populateTypeAndVersion((unsigned char*) packetHeader, PACKET_TYPE_AVATAR_VOXEL_URL); | ||
| 1182 | |||
| 1183 | message.append(packetHeader, numBytesPacketHeader); | ||
| 1184 | message.append((const char*)&ownerID, sizeof(ownerID)); | ||
| 1185 | message.append(url.toEncoded()); | ||
| 1186 | |||
| 1187 | controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1); | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1043 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1191 | // record the packet for stats-tracking | 1044 | // record the packet for stats-tracking |
| 1192 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); | 1045 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); |
| @@ -1236,207 +1089,22 @@ void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_ · 43 unmodified lines | |||
| 1236 | void Application::checkBandwidthMeterClick() { | 1089 | void Application::checkBandwidthMeterClick() { |
| 1237 | // ... to be called upon button release | 1090 | // ... to be called upon button release |
| 1238 | 1091 | ||
| 1239 | if (_bandwidthDisplayOn->isChecked() && | 1092 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && |
| 1240 | glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY))) <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH && | 1093 | glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY))) <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH && |
| 1241 | _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) { | 1094 | _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) { |
| 1242 | 1095 | ||
| 1243 | // The bandwidth meter is visible, the click didn't get dragged too far and | 1096 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1244 | // we actually hit the bandwidth meter | 1097 | // we actually hit the bandwidth meter |
| 1245 | bandwidthDetails(); | 1098 | Menu::getInstance()->bandwidthDetails(); |
| 1246 | } | 1099 | } |
| 1247 | } | 1100 | } |
| 1248 | 1101 | ||
| 1249 | void Application::bandwidthDetails() { | ||
| 1250 | |||
| 1251 | if (! _bandwidthDialog) { | ||
| 1252 | _bandwidthDialog = new BandwidthDialog(_glWidget, getBandwidthMeter()); | ||
| 1253 | connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed())); | ||
| 1254 | |||
| 1255 | _bandwidthDialog->show(); | ||
| 1256 | } | ||
| 1257 | _bandwidthDialog->raise(); | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | void Application::bandwidthDetailsClosed() { | ||
| 1261 | |||
| 1262 | QDialog* dlg = _bandwidthDialog; | ||
| 1263 | _bandwidthDialog = NULL; | ||
| 1264 | delete dlg; | ||
| 1265 | } | ||
| 1266 | |||
| 1267 | void Application::voxelStatsDetails() { | ||
| 1268 | if (!_voxelStatsDialog) { | ||
| 1269 | _voxelStatsDialog = new VoxelStatsDialog(_glWidget, &_voxelSceneStats); | ||
| 1270 | connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed())); | ||
| 1271 | _voxelStatsDialog->show(); | ||
| 1272 | } | ||
| 1273 | _voxelStatsDialog->raise(); | ||
| 1274 | } | ||
| 1275 | |||
| 1276 | void Application::voxelStatsDetailsClosed() { | ||
| 1277 | QDialog* dlg = _voxelStatsDialog; | ||
| 1278 | _voxelStatsDialog = NULL; | ||
| 1279 | delete dlg; | ||
| 1280 | } | ||
| 1281 | |||
| 1282 | void Application::editPreferences() { | ||
| 1283 | QDialog dialog(_glWidget); | ||
| 1284 | dialog.setWindowTitle("Interface Preferences"); | ||
| 1285 | QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); | ||
| 1286 | dialog.setLayout(layout); | ||
| 1287 | |||
| 1288 | QFormLayout* form = new QFormLayout(); | ||
| 1289 | layout->addLayout(form, 1); | ||
| 1290 | |||
| 1291 | const int QLINE_MINIMUM_WIDTH = 400; | ||
| 1292 | |||
| 1293 | QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname())); | ||
| 1294 | domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH); | ||
| 1295 | form->addRow("Domain server:", domainServerHostname); | ||
| 1296 | |||
| 1297 | QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString()); | ||
| 1298 | avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH); | ||
| 1299 | form->addRow("Avatar URL:", avatarURL); | ||
| 1300 | |||
| 1301 | QSpinBox* fieldOfView = new QSpinBox(); | ||
| 1302 | fieldOfView->setMaximum(180); | ||
| 1303 | fieldOfView->setMinimum(1); | ||
| 1304 | fieldOfView->setValue(_fieldOfView); | ||
| 1305 | form->addRow("Vertical Field of View (Degrees):", fieldOfView); | ||
| 1306 | |||
| 1307 | QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox(); | ||
| 1308 | gyroCameraSensitivity->setValue(_gyroCameraSensitivity); | ||
| 1309 | form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity); | ||
| 1310 | |||
| 1311 | QDoubleSpinBox* leanScale = new QDoubleSpinBox(); | ||
| 1312 | leanScale->setValue(_myAvatar.getLeanScale()); | ||
| 1313 | form->addRow("Lean Scale:", leanScale); | ||
| 1314 | |||
| 1315 | QSpinBox* audioJitterBufferSamples = new QSpinBox(); | ||
| 1316 | audioJitterBufferSamples->setMaximum(10000); | ||
| 1317 | audioJitterBufferSamples->setMinimum(-10000); | ||
| 1318 | audioJitterBufferSamples->setValue(_audioJitterBufferSamples); | ||
| 1319 | form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples); | ||
| 1320 | |||
| 1321 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
| 1322 | dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); | ||
| 1323 | dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); | ||
| 1324 | layout->addWidget(buttons); | ||
| 1325 | |||
| 1326 | if (dialog.exec() != QDialog::Accepted) { | ||
| 1327 | return; | ||
| 1328 | } | ||
| 1329 | |||
| 1330 | QByteArray newHostname; | ||
| 1331 | |||
| 1332 | if (domainServerHostname->text().size() > 0) { | ||
| 1333 | // the user input a new hostname, use that | ||
| 1334 | newHostname = domainServerHostname->text().toLocal8Bit(); | ||
| 1335 | } else { | ||
| 1336 | // the user left the field blank, use the default hostname | ||
| 1337 | newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | // check if the domain server hostname is new | ||
| 1341 | if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) { | ||
| 1342 | |||
| 1343 | NodeList::getInstance()->clear(); | ||
| 1344 | |||
| 1345 | // kill the local voxels | ||
| 1346 | _voxels.killLocalVoxels(); | ||
| 1347 | |||
| 1348 | // reset the environment to default | ||
| 1349 | _environment.resetToDefault(); | ||
| 1350 | |||
| 1351 | // set the new hostname | ||
| 1352 | NodeList::getInstance()->setDomainHostname(newHostname.constData()); | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | QUrl url(avatarURL->text()); | ||
| 1356 | _myAvatar.getVoxels()->setVoxelURL(url); | ||
| 1357 | sendAvatarVoxelURLMessage(url); | ||
| 1358 | |||
| 1359 | _gyroCameraSensitivity = gyroCameraSensitivity->value(); | ||
| 1360 | _myAvatar.setLeanScale(leanScale->value()); | ||
| 1361 | _audioJitterBufferSamples = audioJitterBufferSamples->value(); | ||
| 1362 | if (!shouldDynamicallySetJitterBuffer()) { | ||
| 1363 | _audio.setJitterBufferSamples(_audioJitterBufferSamples); | ||
| 1364 | } | ||
| 1365 | _fieldOfView = fieldOfView->value(); | ||
| 1366 | resizeGL(_glWidget->width(), _glWidget->height()); | ||
| 1367 | |||
| 1368 | } | ||
| 1369 | |||
| 1370 | void Application::pair() { | ||
| 1371 | PairingHandler::sendPairRequest(); | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | void Application::setRenderMirrored(bool mirrored) { | ||
| 1375 | if (mirrored) { | ||
| 1376 | _manualFirstPerson->setChecked(false); | ||
| 1377 | _manualThirdPerson->setChecked(false); | ||
| 1378 | } | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | void Application::setNoise(bool noise) { | ||
| 1382 | _myAvatar.setNoise(noise); | ||
| 1383 | } | ||
| 1384 | |||
| 1385 | void Application::setFullscreen(bool fullscreen) { | 1102 | void Application::setFullscreen(bool fullscreen) { |
| 1386 | _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) : | 1103 | _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) : |
| 1387 | (_window->windowState() & ~Qt::WindowFullScreen)); | 1104 | (_window->windowState() & ~Qt::WindowFullScreen)); |
| 1388 | updateCursor(); | 1105 | updateCursor(); |
| 1389 | } | 1106 | } |
| 1390 | 1107 | ||
| 1391 | void Application::setRenderFirstPerson(bool firstPerson) { | ||
| 1392 | if (firstPerson) { | ||
| 1393 | _lookingInMirror->setChecked(false); | ||
| 1394 | _manualThirdPerson->setChecked(false); | ||
| 1395 | } else { | ||
| 1396 | _manualThirdPerson->trigger(); | ||
| 1397 | } | ||
| 1398 | } | ||
| 1399 | |||
| 1400 | void Application::setRenderThirdPerson(bool thirdPerson) { | ||
| 1401 | if (thirdPerson) { | ||
| 1402 | _lookingInMirror->setChecked(false); | ||
| 1403 | _manualFirstPerson->setChecked(false); | ||
| 1404 | } | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | void Application::increaseAvatarSize() { | ||
| 1408 | if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) { | ||
| 1409 | _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale()); | ||
| 1410 | qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); | ||
| 1411 | } | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | void Application::decreaseAvatarSize() { | ||
| 1415 | if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) { | ||
| 1416 | _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale()); | ||
| 1417 | qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); | ||
| 1418 | } | ||
| 1419 | } | ||
| 1420 | |||
| 1421 | void Application::resetAvatarSize() { | ||
| 1422 | _myAvatar.setNewScale(1.f); | ||
| 1423 | qDebug("Reseted scale to %f\n", _myAvatar.getNewScale()); | ||
| 1424 | } | ||
| 1425 | |||
| 1426 | void Application::setFrustumOffset(bool frustumOffset) { | ||
| 1427 | // reshape so that OpenGL will get the right lens details for the camera of choice | ||
| 1428 | resizeGL(_glWidget->width(), _glWidget->height()); | ||
| 1429 | } | ||
| 1430 | |||
| 1431 | void Application::cycleFrustumRenderMode() { | ||
| 1432 | _frustumDrawingMode = (FrustumDrawMode)((_frustumDrawingMode + 1) % FRUSTUM_DRAW_MODE_COUNT); | ||
| 1433 | updateFrustumRenderModeAction(); | ||
| 1434 | } | ||
| 1435 | |||
| 1436 | void Application::setRenderWarnings(bool renderWarnings) { | ||
| 1437 | _voxels.setRenderPipelineWarnings(renderWarnings); | ||
| 1438 | } | ||
| 1439 | |||
| 1440 | void Application::setRenderVoxels(bool voxelRender) { | 1108 | void Application::setRenderVoxels(bool voxelRender) { |
| 1441 | if (!voxelRender) { | 1109 | if (!voxelRender) { |
| 1442 | doKillLocalVoxels(); | 1110 | doKillLocalVoxels(); |
| @@ -1447,75 +1115,6 @@ void Application::doKillLocalVoxels() { · 4 unmodified lines | |||
| 1447 | _wantToKillLocalVoxels = true; | 1115 | _wantToKillLocalVoxels = true; |
| 1448 | } | 1116 | } |
| 1449 | 1117 | ||
| 1450 | void Application::doRandomizeVoxelColors() { | ||
| 1451 | _voxels.randomizeVoxelColors(); | ||
| 1452 | } | ||
| 1453 | |||
| 1454 | void Application::doFalseRandomizeVoxelColors() { | ||
| 1455 | _voxels.falseColorizeRandom(); | ||
| 1456 | } | ||
| 1457 | |||
| 1458 | void Application::doFalseRandomizeEveryOtherVoxelColors() { | ||
| 1459 | _voxels.falseColorizeRandomEveryOther(); | ||
| 1460 | } | ||
| 1461 | |||
| 1462 | void Application::doFalseColorizeByDistance() { | ||
| 1463 | loadViewFrustum(_myCamera, _viewFrustum); | ||
| 1464 | _voxels.falseColorizeDistanceFromView(&_viewFrustum); | ||
| 1465 | } | ||
| 1466 | |||
| 1467 | void Application::doFalseColorizeInView() { | ||
| 1468 | loadViewFrustum(_myCamera, _viewFrustum); | ||
| 1469 | // we probably want to make sure the viewFrustum is initialized first | ||
| 1470 | _voxels.falseColorizeInView(&_viewFrustum); | ||
| 1471 | } | ||
| 1472 | |||
| 1473 | void Application::doFalseColorizeOccluded() { | ||
| 1474 | CoverageMap::wantDebugging = true; | ||
| 1475 | _voxels.falseColorizeOccluded(); | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | void Application::doFalseColorizeOccludedV2() { | ||
| 1479 | _voxels.falseColorizeOccludedV2(); | ||
| 1480 | } | ||
| 1481 | |||
| 1482 | void Application::doFalseColorizeBySource() { | ||
| 1483 | _voxels.falseColorizeBySource(); | ||
| 1484 | } | ||
| 1485 | |||
| 1486 | void Application::doTrueVoxelColors() { | ||
| 1487 | _voxels.trueColorize(); | ||
| 1488 | } | ||
| 1489 | |||
| 1490 | void Application::doTreeStats() { | ||
| 1491 | _voxels.collectStatsForTreesAndVBOs(); | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | void Application::disableLowResMoving(bool disableLowResMoving) { | ||
| 1495 | _myAvatar.setWantLowResMoving(!disableLowResMoving); | ||
| 1496 | } | ||
| 1497 | |||
| 1498 | void Application::setWantsMonochrome(bool wantsMonochrome) { | ||
| 1499 | _myAvatar.setWantColor(!wantsMonochrome); | ||
| 1500 | } | ||
| 1501 | |||
| 1502 | void Application::disableDeltaSending(bool disableDeltaSending) { | ||
| 1503 | _myAvatar.setWantDelta(!disableDeltaSending); | ||
| 1504 | } | ||
| 1505 | |||
| 1506 | void Application::disableOcclusionCulling(bool disableOcclusionCulling) { | ||
| 1507 | _myAvatar.setWantOcclusionCulling(!disableOcclusionCulling); | ||
| 1508 | } | ||
| 1509 | |||
| 1510 | void Application::updateVoxelModeActions() { | ||
| 1511 | // only the sender can be checked | ||
| 1512 | foreach (QAction* action, _voxelModeActions->actions()) { | ||
| 1513 | if (action->isChecked() && action != sender()) { | ||
| 1514 | action->setChecked(false); | ||
| 1515 | } | ||
| 1516 | } | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { | 1118 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { |
| 1520 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1119 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1521 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1120 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| @@ -1530,27 +1129,6 @@ void Application::increaseVoxelSize() { · 8 unmodified lines | |||
| 1530 | _mouseVoxelScale *= 2; | 1129 | _mouseVoxelScale *= 2; |
| 1531 | } | 1130 | } |
| 1532 | 1131 | ||
| 1533 | void Application::resetSwatchColors() { | ||
| 1534 | _swatch.reset(); | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | static QIcon createSwatchIcon(const QColor& color) { | ||
| 1538 | QPixmap map(16, 16); | ||
| 1539 | map.fill(color); | ||
| 1540 | return QIcon(map); | ||
| 1541 | } | ||
| 1542 | |||
| 1543 | void Application::chooseVoxelPaintColor() { | ||
| 1544 | QColor selected = QColorDialog::getColor(_voxelPaintColor->data().value<QColor>(), _glWidget, "Voxel Paint Color"); | ||
| 1545 | if (selected.isValid()) { | ||
| 1546 | _voxelPaintColor->setData(selected); | ||
| 1547 | _voxelPaintColor->setIcon(createSwatchIcon(selected)); | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | // restore the main window's active state | ||
| 1551 | _window->activateWindow(); | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; | 1132 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; |
| 1555 | struct SendVoxelsOperationArgs { | 1133 | struct SendVoxelsOperationArgs { |
| 1556 | unsigned char* newBaseOctCode; | 1134 | unsigned char* newBaseOctCode; |
| @@ -1823,196 +1401,6 @@ void Application::pasteVoxels() { · 266 unmodified lines | |||
| 1823 | } | 1401 | } |
| 1824 | } | 1402 | } |
| 1825 | 1403 | ||
| 1826 | void Application::initMenu() { | ||
| 1827 | QMenuBar* menuBar = new QMenuBar(); | ||
| 1828 | _window->setMenuBar(menuBar); | ||
| 1829 | |||
| 1830 | QMenu* fileMenu = menuBar->addMenu("File"); | ||
| 1831 | QAction* quitAction = fileMenu->addAction("Quit", this, SLOT(quit()), Qt::CTRL | Qt::Key_Q); | ||
| 1832 | quitAction->setMenuRole(QAction::QuitRole); | ||
| 1833 | |||
| 1834 | QMenu* editMenu = menuBar->addMenu("Edit"); | ||
| 1835 | QAction* preferencesAction = editMenu->addAction("Preferences...", this, SLOT(editPreferences()), Qt::CTRL | Qt::Key_Comma); | ||
| 1836 | preferencesAction->setMenuRole(QAction::PreferencesRole); | ||
| 1837 | |||
| 1838 | QMenu* pairMenu = menuBar->addMenu("Pair"); | ||
| 1839 | pairMenu->addAction("Pair", this, SLOT(pair())); | ||
| 1840 | |||
| 1841 | QMenu* optionsMenu = menuBar->addMenu("Options"); | ||
| 1842 | (_lookingInMirror = optionsMenu->addAction("Mirror", this, SLOT(setRenderMirrored(bool)), Qt::Key_H))->setCheckable(true); | ||
| 1843 | |||
| 1844 | |||
| 1845 | (_noise = optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N))->setCheckable(true); | ||
| 1846 | (_gyroLook = optionsMenu->addAction("Smooth Gyro Look"))->setCheckable(true); | ||
| 1847 | _gyroLook->setChecked(true); | ||
| 1848 | (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true); | ||
| 1849 | _showHeadMouse->setChecked(false); | ||
| 1850 | (_transmitterDrives = optionsMenu->addAction("Transmitter Drive"))->setCheckable(true); | ||
| 1851 | _transmitterDrives->setChecked(true); | ||
| 1852 | (_gravityUse = optionsMenu->addAction("Use Gravity"))->setCheckable(true); | ||
| 1853 | _gravityUse->setChecked(true); | ||
| 1854 | _gravityUse->setShortcut(Qt::SHIFT | Qt::Key_G); | ||
| 1855 | (_testPing = optionsMenu->addAction("Test Ping"))->setCheckable(true); | ||
| 1856 | _testPing->setChecked(true); | ||
| 1857 | (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); | ||
| 1858 | optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); | ||
| 1859 | optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true); | ||
| 1860 | (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true); | ||
| 1861 | _wantCollisionsOn->setChecked(true); | ||
| 1862 | optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode())); | ||
| 1863 | optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true); | ||
| 1864 | optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G); | ||
| 1865 | |||
| 1866 | QMenu* audioMenu = menuBar->addMenu("Audio"); | ||
| 1867 | (_echoAudioMode = audioMenu->addAction("Echo Audio"))->setCheckable(true); | ||
| 1868 | _rawAudioMicrophoneMix = audioMenu->addAction("Mix RAW Song", this, SLOT(toggleMixedSong())); | ||
| 1869 | |||
| 1870 | QMenu* renderMenu = menuBar->addMenu("Render"); | ||
| 1871 | (_renderVoxels = renderMenu->addAction("Voxels", this, SLOT(setRenderVoxels(bool)), Qt::SHIFT | Qt::Key_V))->setCheckable(true); | ||
| 1872 | _renderVoxels->setChecked(true); | ||
| 1873 | (_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true); | ||
| 1874 | (_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true); | ||
| 1875 | _renderStarsOn->setChecked(true); | ||
| 1876 | _renderStarsOn->setShortcut(Qt::Key_Asterisk); | ||
| 1877 | (_renderAtmosphereOn = renderMenu->addAction("Atmosphere"))->setCheckable(true); | ||
| 1878 | _renderAtmosphereOn->setChecked(true); | ||
| 1879 | _renderAtmosphereOn->setShortcut(Qt::SHIFT | Qt::Key_A); | ||
| 1880 | (_renderGroundPlaneOn = renderMenu->addAction("Ground Plane"))->setCheckable(true); | ||
| 1881 | _renderGroundPlaneOn->setChecked(true); | ||
| 1882 | (_renderAvatarsOn = renderMenu->addAction("Avatars"))->setCheckable(true); | ||
| 1883 | _renderAvatarsOn->setChecked(true); | ||
| 1884 | (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true); | ||
| 1885 | _renderAvatarBalls->setChecked(false); | ||
| 1886 | renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); | ||
| 1887 | renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode())); | ||
| 1888 | renderMenu->addAction("Cycle Glow Mode", &_glowEffect, SLOT(cycleRenderMode())); | ||
| 1889 | (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); | ||
| 1890 | _renderFrameTimerOn->setChecked(false); | ||
| 1891 | (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); | ||
| 1892 | _renderLookatOn->setChecked(false); | ||
| 1893 | (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true); | ||
| 1894 | _renderLookatIndicatorOn->setChecked(true); | ||
| 1895 | (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true); | ||
| 1896 | (_manualFirstPerson = renderMenu->addAction( | ||
| 1897 | "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); | ||
| 1898 | (_manualThirdPerson = renderMenu->addAction( | ||
| 1899 | "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); | ||
| 1900 | renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); | ||
| 1901 | renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); | ||
| 1902 | renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize())); | ||
| 1903 | |||
| 1904 | |||
| 1905 | QMenu* toolsMenu = menuBar->addMenu("Tools"); | ||
| 1906 | (_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true); | ||
| 1907 | _renderStatsOn->setShortcut(Qt::Key_Slash); | ||
| 1908 | (_logOn = toolsMenu->addAction("Log"))->setCheckable(true); | ||
| 1909 | _logOn->setChecked(false); | ||
| 1910 | _logOn->setShortcut(Qt::CTRL | Qt::Key_L); | ||
| 1911 | (_oscilloscopeOn = toolsMenu->addAction("Audio Oscilloscope"))->setCheckable(true); | ||
| 1912 | _oscilloscopeOn->setChecked(true); | ||
| 1913 | (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true); | ||
| 1914 | _bandwidthDisplayOn->setChecked(true); | ||
| 1915 | toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails())); | ||
| 1916 | toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails())); | ||
| 1917 | |||
| 1918 | |||
| 1919 | QMenu* voxelMenu = menuBar->addMenu("Voxels"); | ||
| 1920 | _voxelModeActions = new QActionGroup(this); | ||
| 1921 | _voxelModeActions->setExclusive(false); // exclusivity implies one is always checked | ||
| 1922 | |||
| 1923 | (_addVoxelMode = voxelMenu->addAction( | ||
| 1924 | "Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_V))->setCheckable(true); | ||
| 1925 | _voxelModeActions->addAction(_addVoxelMode); | ||
| 1926 | (_deleteVoxelMode = voxelMenu->addAction( | ||
| 1927 | "Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_R))->setCheckable(true); | ||
| 1928 | _voxelModeActions->addAction(_deleteVoxelMode); | ||
| 1929 | (_colorVoxelMode = voxelMenu->addAction( | ||
| 1930 | "Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_B))->setCheckable(true); | ||
| 1931 | _voxelModeActions->addAction(_colorVoxelMode); | ||
| 1932 | (_selectVoxelMode = voxelMenu->addAction( | ||
| 1933 | "Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_O))->setCheckable(true); | ||
| 1934 | _voxelModeActions->addAction(_selectVoxelMode); | ||
| 1935 | (_eyedropperMode = voxelMenu->addAction( | ||
| 1936 | "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_G))->setCheckable(true); | ||
| 1937 | _voxelModeActions->addAction(_eyedropperMode); | ||
| 1938 | |||
| 1939 | voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut); | ||
| 1940 | voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn); | ||
| 1941 | voxelMenu->addAction("Reset Swatch Colors", this, SLOT(resetSwatchColors())); | ||
| 1942 | |||
| 1943 | _voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this, | ||
| 1944 | SLOT(chooseVoxelPaintColor()), Qt::META | Qt::Key_C); | ||
| 1945 | _swatch.setAction(_voxelPaintColor); | ||
| 1946 | |||
| 1947 | QColor paintColor(128, 128, 128); | ||
| 1948 | _voxelPaintColor->setData(paintColor); | ||
| 1949 | _voxelPaintColor->setIcon(createSwatchIcon(paintColor)); | ||
| 1950 | (_destructiveAddVoxel = voxelMenu->addAction("Create Voxel is Destructive"))->setCheckable(true); | ||
| 1951 | |||
| 1952 | voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); | ||
| 1953 | voxelMenu->addAction("Import Voxels", &_voxelImporter, SLOT(import()), Qt::CTRL | Qt::Key_I); | ||
| 1954 | voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X); | ||
| 1955 | voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); | ||
| 1956 | voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); | ||
| 1957 | |||
| 1958 | QMenu* debugMenu = menuBar->addMenu("Debug"); | ||
| 1959 | |||
| 1960 | QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools"); | ||
| 1961 | (_frustumOn = frustumMenu->addAction("Display Frustum"))->setCheckable(true); | ||
| 1962 | _frustumOn->setShortcut(Qt::SHIFT | Qt::Key_F); | ||
| 1963 | _frustumRenderModeAction = frustumMenu->addAction( | ||
| 1964 | "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R); | ||
| 1965 | updateFrustumRenderModeAction(); | ||
| 1966 | |||
| 1967 | debugMenu->addAction("Run Timing Tests", this, SLOT(runTests())); | ||
| 1968 | debugMenu->addAction("Calculate Tree Stats", this, SLOT(doTreeStats()), Qt::SHIFT | Qt::Key_S); | ||
| 1969 | |||
| 1970 | QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools"); | ||
| 1971 | (_renderPipelineWarnings = renderDebugMenu->addAction("Show Render Pipeline Warnings", | ||
| 1972 | this, SLOT(setRenderWarnings(bool))))->setCheckable(true); | ||
| 1973 | renderDebugMenu->addAction("Kill Local Voxels", this, SLOT(doKillLocalVoxels()), Qt::CTRL | Qt::Key_K); | ||
| 1974 | renderDebugMenu->addAction("Randomize Voxel TRUE Colors", this, SLOT(doRandomizeVoxelColors()), Qt::CTRL | Qt::Key_R); | ||
| 1975 | renderDebugMenu->addAction("FALSE Color Voxels Randomly", this, SLOT(doFalseRandomizeVoxelColors())); | ||
| 1976 | renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors())); | ||
| 1977 | renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance())); | ||
| 1978 | renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView())); | ||
| 1979 | renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O); | ||
| 1980 | renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P); | ||
| 1981 | renderDebugMenu->addAction("FALSE Color By Source", this, SLOT(doFalseColorizeBySource()), Qt::CTRL | Qt::SHIFT | Qt::Key_S); | ||
| 1982 | renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T); | ||
| 1983 | |||
| 1984 | (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true); | ||
| 1985 | |||
| 1986 | debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true); | ||
| 1987 | debugMenu->addAction("Disable Lower Resolution While Moving", this, SLOT(disableLowResMoving(bool)))->setCheckable(true); | ||
| 1988 | debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true); | ||
| 1989 | (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), | ||
| 1990 | Qt::SHIFT | Qt::Key_C))->setCheckable(true); | ||
| 1991 | |||
| 1992 | (_renderCoverageMap = debugMenu->addAction("Render Coverage Map"))->setCheckable(true); | ||
| 1993 | _renderCoverageMap->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_O); | ||
| 1994 | (_renderCoverageMapV2 = debugMenu->addAction("Render Coverage Map V2"))->setCheckable(true); | ||
| 1995 | _renderCoverageMapV2->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_P); | ||
| 1996 | |||
| 1997 | (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true); | ||
| 1998 | (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true); | ||
| 1999 | |||
| 2000 | QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools"); | ||
| 2001 | audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1); | ||
| 2002 | audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2); | ||
| 2003 | audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3); | ||
| 2004 | |||
| 2005 | QMenu* settingsMenu = menuBar->addMenu("Settings"); | ||
| 2006 | (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true); | ||
| 2007 | _settingsAutosave->setChecked(true); | ||
| 2008 | settingsMenu->addAction("Load settings", this, SLOT(loadSettings())); | ||
| 2009 | settingsMenu->addAction("Save settings", this, SLOT(saveSettings())); | ||
| 2010 | settingsMenu->addAction("Import settings", this, SLOT(importSettings())); | ||
| 2011 | settingsMenu->addAction("Export settings", this, SLOT(exportSettings())); | ||
| 2012 | |||
| 2013 | _networkAccessManager = new QNetworkAccessManager(this); | ||
| 2014 | } | ||
| 2015 | |||
| 2016 | void Application::setListenModeNormal() { | 1404 | void Application::setListenModeNormal() { |
| 2017 | _audio.setListenMode(AudioRingBuffer::NORMAL); | 1405 | _audio.setListenMode(AudioRingBuffer::NORMAL); |
| 2018 | } | 1406 | } |
| @@ -2036,63 +1424,6 @@ void Application::setListenModeSingleSource() { · 17 unmodified lines | |||
| 2036 | } | 1424 | } |
| 2037 | } | 1425 | } |
| 2038 | 1426 | ||
| 2039 | void Application::toggleMixedSong() { | ||
| 2040 | if (_audio.getSongFileBytes() == 0) { | ||
| 2041 | QString filename = QFileDialog::getOpenFileName(_glWidget, | ||
| 2042 | tr("Choose RAW Audio file"), | ||
| 2043 | QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), | ||
| 2044 | tr("RAW Audio file (*.raw)")); | ||
| 2045 | |||
| 2046 | QByteArray filenameArray = filename.toLocal8Bit(); | ||
| 2047 | _audio.importSongToMixWithMicrophone(filenameArray.data()); | ||
| 2048 | resetSongMixMenuItem(); | ||
| 2049 | } else { | ||
| 2050 | _audio.stopMixingSongWithMicrophone(); | ||
| 2051 | resetSongMixMenuItem(); | ||
| 2052 | } | ||
| 2053 | } | ||
| 2054 | |||
| 2055 | void Application::toggleWantCollisionsOn() { | ||
| 2056 | _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked()); | ||
| 2057 | } | ||
| 2058 | |||
| 2059 | void Application::resetSongMixMenuItem() { | ||
| 2060 | if (_audio.getSongFileBytes() == 0) { | ||
| 2061 | _rawAudioMicrophoneMix->setText("Mix RAW Song"); | ||
| 2062 | } else { | ||
| 2063 | _rawAudioMicrophoneMix->setText("Stop Mixing Song"); | ||
| 2064 | } | ||
| 2065 | |||
| 2066 | } | ||
| 2067 | |||
| 2068 | void Application::updateFrustumRenderModeAction() { | ||
| 2069 | switch (_frustumDrawingMode) { | ||
| 2070 | default: | ||
| 2071 | case FRUSTUM_DRAW_MODE_ALL: | ||
| 2072 | _frustumRenderModeAction->setText("Render Mode - All"); | ||
| 2073 | break; | ||
| 2074 | case FRUSTUM_DRAW_MODE_VECTORS: | ||
| 2075 | _frustumRenderModeAction->setText("Render Mode - Vectors"); | ||
| 2076 | break; | ||
| 2077 | case FRUSTUM_DRAW_MODE_PLANES: | ||
| 2078 | _frustumRenderModeAction->setText("Render Mode - Planes"); | ||
| 2079 | break; | ||
| 2080 | case FRUSTUM_DRAW_MODE_NEAR_PLANE: | ||
| 2081 | _frustumRenderModeAction->setText("Render Mode - Near"); | ||
| 2082 | break; | ||
| 2083 | case FRUSTUM_DRAW_MODE_FAR_PLANE: | ||
| 2084 | _frustumRenderModeAction->setText("Render Mode - Far"); | ||
| 2085 | break; | ||
| 2086 | case FRUSTUM_DRAW_MODE_KEYHOLE: | ||
| 2087 | _frustumRenderModeAction->setText("Render Mode - Keyhole"); | ||
| 2088 | break; | ||
| 2089 | } | ||
| 2090 | } | ||
| 2091 | |||
| 2092 | void Application::runTests() { | ||
| 2093 | runTimingTests(); | ||
| 2094 | } | ||
| 2095 | |||
| 2096 | void Application::initDisplay() { | 1427 | void Application::initDisplay() { |
| 2097 | glEnable(GL_BLEND); | 1428 | glEnable(GL_BLEND); |
| 2098 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); | 1429 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); |
| @@ -2124,7 +1455,9 @@ void Application::init() { · 25 unmodified lines | |||
| 2124 | 1455 | ||
| 2125 | OculusManager::connect(); | 1456 | OculusManager::connect(); |
| 2126 | if (OculusManager::isConnected()) { | 1457 | if (OculusManager::isConnected()) { |
| 2127 | QMetaObject::invokeMethod(_fullScreenMode, "trigger", Qt::QueuedConnection); | 1458 | QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen), |
| 1459 | "trigger", | ||
| 1460 | Qt::QueuedConnection); | ||
| 2128 | } | 1461 | } |
| 2129 | 1462 | ||
| 2130 | LeapManager::initialize(); | 1463 | LeapManager::initialize(); |
| @@ -2132,22 +1465,22 @@ void Application::init() { · 1 unmodified line | |||
| 2132 | gettimeofday(&_timerStart, NULL); | 1465 | gettimeofday(&_timerStart, NULL); |
| 2133 | gettimeofday(&_lastTimeUpdated, NULL); | 1466 | gettimeofday(&_lastTimeUpdated, NULL); |
| 2134 | 1467 | ||
| 2135 | loadSettings(); | 1468 | Menu::getInstance()->loadSettings(); |
| 2136 | if (!shouldDynamicallySetJitterBuffer()) { | 1469 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { |
| 2137 | _audio.setJitterBufferSamples(_audioJitterBufferSamples); | 1470 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 2138 | } | 1471 | } |
| 2139 | 1472 | ||
| 2140 | qDebug("Loaded settings.\n"); | 1473 | qDebug("Loaded settings.\n"); |
| 2141 | 1474 | ||
| 2142 | sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | 1475 | Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); |
| 2143 | 1476 | ||
| 2144 | _palette.init(_glWidget->width(), _glWidget->height()); | 1477 | _palette.init(_glWidget->width(), _glWidget->height()); |
| 2145 | _palette.addAction(_addVoxelMode, 0, 0); | 1478 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelAddMode), 0, 0); |
| 2146 | _palette.addAction(_deleteVoxelMode, 0, 1); | 1479 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelDeleteMode), 0, 1); |
| 2147 | _palette.addTool(&_swatch); | 1480 | _palette.addTool(&_swatch); |
| 2148 | _palette.addAction(_colorVoxelMode, 0, 2); | 1481 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelColorMode), 0, 2); |
| 2149 | _palette.addAction(_eyedropperMode, 0, 3); | 1482 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelGetColorMode), 0, 3); |
| 2150 | _palette.addAction(_selectVoxelMode, 0, 4); | 1483 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelSelectMode), 0, 4); |
| 2151 | 1484 | ||
| 2152 | _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg", | 1485 | _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg", |
| 2153 | _glWidget->width(), | 1486 | _glWidget->width(), |
| @@ -2374,7 +1707,7 @@ void Application::update(float deltaTime) { · 220 unmodified lines | |||
| 2374 | } | 1707 | } |
| 2375 | 1708 | ||
| 2376 | _mouseVoxel.s = 0.0f; | 1709 | _mouseVoxel.s = 0.0f; |
| 2377 | if (checkedVoxelModeAction() != 0 && | 1710 | if (Menu::getInstance()->isVoxelModeActionChecked() && |
| 2378 | (fabs(_myAvatar.getVelocity().x) + | 1711 | (fabs(_myAvatar.getVelocity().x) + |
| 2379 | fabs(_myAvatar.getVelocity().y) + | 1712 | fabs(_myAvatar.getVelocity().y) + |
| 2380 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { | 1713 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { |
| @@ -2399,7 +1732,7 @@ void Application::update(float deltaTime) { · 18 unmodified lines | |||
| 2399 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale); | 1732 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale); |
| 2400 | _mouseVoxel.s = _mouseVoxelScale; | 1733 | _mouseVoxel.s = _mouseVoxelScale; |
| 2401 | } | 1734 | } |
| 2402 | if (_addVoxelMode->isChecked()) { | 1735 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) { |
| 2403 | // use the face to determine the side on which to create a neighbor | 1736 | // use the face to determine the side on which to create a neighbor |
| 2404 | _mouseVoxel.x += faceVector.x * _mouseVoxel.s; | 1737 | _mouseVoxel.x += faceVector.x * _mouseVoxel.s; |
| 2405 | _mouseVoxel.y += faceVector.y * _mouseVoxel.s; | 1738 | _mouseVoxel.y += faceVector.y * _mouseVoxel.s; |
| @@ -2409,7 +1742,8 @@ void Application::update(float deltaTime) { · 3 unmodified lines | |||
| 2409 | } else { | 1742 | } else { |
| 2410 | _mouseVoxel.s = 0.0f; | 1743 | _mouseVoxel.s = 0.0f; |
| 2411 | } | 1744 | } |
| 2412 | } else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) { | 1745 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) |
| 1746 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { | ||
| 2413 | // place the voxel a fixed distance away | 1747 | // place the voxel a fixed distance away |
| 2414 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; | 1748 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; |
| 2415 | glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); | 1749 | glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); |
| @@ -2419,16 +1753,16 @@ void Application::update(float deltaTime) { · 3 unmodified lines | |||
| 2419 | _mouseVoxel.s = _mouseVoxelScale; | 1753 | _mouseVoxel.s = _mouseVoxelScale; |
| 2420 | } | 1754 | } |
| 2421 | 1755 | ||
| 2422 | if (_deleteVoxelMode->isChecked()) { | 1756 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { |
| 2423 | // red indicates deletion | 1757 | // red indicates deletion |
| 2424 | _mouseVoxel.red = 255; | 1758 | _mouseVoxel.red = 255; |
| 2425 | _mouseVoxel.green = _mouseVoxel.blue = 0; | 1759 | _mouseVoxel.green = _mouseVoxel.blue = 0; |
| 2426 | } else if (_selectVoxelMode->isChecked()) { | 1760 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { |
| 2427 | // yellow indicates deletion | 1761 | // yellow indicates deletion |
| 2428 | _mouseVoxel.red = _mouseVoxel.green = 255; | 1762 | _mouseVoxel.red = _mouseVoxel.green = 255; |
| 2429 | _mouseVoxel.blue = 0; | 1763 | _mouseVoxel.blue = 0; |
| 2430 | } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked() | 1764 | } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked() |
| 2431 | QColor paintColor = _voxelPaintColor->data().value<QColor>(); | 1765 | QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>(); |
| 2432 | _mouseVoxel.red = paintColor.red(); | 1766 | _mouseVoxel.red = paintColor.red(); |
| 2433 | _mouseVoxel.green = paintColor.green(); | 1767 | _mouseVoxel.green = paintColor.green(); |
| 2434 | _mouseVoxel.blue = paintColor.blue(); | 1768 | _mouseVoxel.blue = paintColor.blue(); |
| @@ -2458,8 +1792,8 @@ void Application::update(float deltaTime) { · 23 unmodified lines | |||
| 2458 | } | 1792 | } |
| 2459 | 1793 | ||
| 2460 | // Leap finger-sensing device | 1794 | // Leap finger-sensing device |
| 2461 | LeapManager::enableFakeFingers(_simulateLeapHand->isChecked()); | 1795 | LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)); |
| 2462 | _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked()); | 1796 | _myAvatar.getHand().setRaveGloveActive(Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)); |
| 2463 | LeapManager::nextFrame(_myAvatar); | 1797 | LeapManager::nextFrame(_myAvatar); |
| 2464 | 1798 | ||
| 2465 | // Read serial port interface devices | 1799 | // Read serial port interface devices |
| @@ -2499,60 +1833,47 @@ void Application::update(float deltaTime) { · 33 unmodified lines | |||
| 2499 | } | 1833 | } |
| 2500 | 1834 | ||
| 2501 | // Simulate myself | 1835 | // Simulate myself |
| 2502 | if (_gravityUse->isChecked()) { | 1836 | if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) { |
| 2503 | _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); | 1837 | _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); |
| 2504 | } | 1838 | } |
| 2505 | else { | 1839 | else { |
| 2506 | _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f)); | 1840 | _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f)); |
| 2507 | } | 1841 | } |
| 2508 | 1842 | ||
| 2509 | if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { | 1843 | if (Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) { |
| 2510 | _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity); | 1844 | _myAvatar.simulate(deltaTime, &_myTransmitter, Menu::getInstance()->getGyroCameraSensitivity()); |
| 2511 | } else { | 1845 | } else { |
| 2512 | _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity); | 1846 | _myAvatar.simulate(deltaTime, NULL, Menu::getInstance()->getGyroCameraSensitivity()); |
| 2513 | } | 1847 | } |
| 2514 | 1848 | ||
| 2515 | if (!OculusManager::isConnected()) { | 1849 | if (!OculusManager::isConnected()) { |
| 2516 | if (_lookingInMirror->isChecked()) { | 1850 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 2517 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | 1851 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| 2518 | _myCamera.setMode(CAMERA_MODE_MIRROR); | 1852 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 2519 | _myCamera.setModeShiftRate(100.0f); | 1853 | _myCamera.setModeShiftRate(100.0f); |
| 2520 | } | 1854 | } |
| 2521 | } else if (_manualFirstPerson->isChecked()) { | 1855 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { |
| 2522 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { | 1856 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 2523 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 1857 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2524 | _myCamera.setModeShiftRate(1.0f); | 1858 | _myCamera.setModeShiftRate(1.0f); |
| 2525 | } | 1859 | } |
| 2526 | } else if (_manualThirdPerson->isChecked()) { | 1860 | } else { |
| 2527 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { | 1861 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2528 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | 1862 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2529 | _myCamera.setModeShiftRate(1.0f); | 1863 | _myCamera.setModeShiftRate(1.0f); |
| 2530 | } | 1864 | } |
| 2531 | } else { | ||
| 2532 | const float THIRD_PERSON_SHIFT_VELOCITY = 1000.0f; | ||
| 2533 | const float TIME_BEFORE_SHIFT_INTO_FIRST_PERSON = 0.75f; | ||
| 2534 | const float TIME_BEFORE_SHIFT_INTO_THIRD_PERSON = 0.1f; | ||
| 2535 | |||
| 2536 | if ((_myAvatar.getElapsedTimeStopped() > TIME_BEFORE_SHIFT_INTO_FIRST_PERSON) | ||
| 2537 | && (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON)) { | ||
| 2538 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | ||
| 2539 | _myCamera.setModeShiftRate(1.0f); | ||
| 2540 | } | ||
| 2541 | if ((_myAvatar.getSpeed() > THIRD_PERSON_SHIFT_VELOCITY) | ||
| 2542 | && (_myAvatar.getElapsedTimeMoving() > TIME_BEFORE_SHIFT_INTO_THIRD_PERSON) | ||
| 2543 | && (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON)) { | ||
| 2544 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | ||
| 2545 | _myCamera.setModeShiftRate(1000.0f); | ||
| 2546 | } | ||
| 2547 | } | 1865 | } |
| 2548 | } | 1866 | } |
| 2549 | 1867 | ||
| 2550 | // Update bandwidth dialog, if any | 1868 | // Update bandwidth dialog, if any |
| 2551 | if (_bandwidthDialog) { | 1869 | BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog(); |
| 2552 | _bandwidthDialog->update(); | 1870 | if (bandwidthDialog) { |
| 1871 | bandwidthDialog->update(); | ||
| 2553 | } | 1872 | } |
| 2554 | if (_voxelStatsDialog) { | 1873 | |
| 2555 | _voxelStatsDialog->update(); | 1874 | VoxelStatsDialog* voxelStatsDialog = Menu::getInstance()->getVoxelStatsDialog(); |
| 1875 | if (voxelStatsDialog) { | ||
| 1876 | voxelStatsDialog->update(); | ||
| 2556 | } | 1877 | } |
| 2557 | 1878 | ||
| 2558 | // Update audio stats for procedural sounds | 1879 | // Update audio stats for procedural sounds |
| @@ -2561,10 +1882,6 @@ void Application::update(float deltaTime) { · 2 unmodified lines | |||
| 2561 | _audio.setLastVelocity(_myAvatar.getVelocity()); | 1882 | _audio.setLastVelocity(_myAvatar.getVelocity()); |
| 2562 | _audio.eventuallyAnalyzePing(); | 1883 | _audio.eventuallyAnalyzePing(); |
| 2563 | #endif | 1884 | #endif |
| 2564 | |||
| 2565 | if (_renderParticleSystemOn->isChecked()) { | ||
| 2566 | updateParticleSystem(deltaTime); | ||
| 2567 | } | ||
| 2568 | } | 1885 | } |
| 2569 | 1886 | ||
| 2570 | void Application::updateAvatar(float deltaTime) { | 1887 | void Application::updateAvatar(float deltaTime) { |
| @@ -2575,7 +1892,7 @@ void Application::updateAvatar(float deltaTime) { · 4 unmodified lines | |||
| 2575 | _yawFromTouch = 0.f; | 1892 | _yawFromTouch = 0.f; |
| 2576 | 1893 | ||
| 2577 | // Update my avatar's state from gyros and/or webcam | 1894 | // Update my avatar's state from gyros and/or webcam |
| 2578 | _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), | 1895 | _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::GyroLook), |
| 2579 | _pitchFromTouch); | 1896 | _pitchFromTouch); |
| 2580 | 1897 | ||
| 2581 | if (_serialHeadSensor.isActive()) { | 1898 | if (_serialHeadSensor.isActive()) { |
| @@ -2599,17 +1916,20 @@ void Application::updateAvatar(float deltaTime) { · 17 unmodified lines | |||
| 2599 | _headMouseY = min(_headMouseY, _glWidget->height()); | 1916 | _headMouseY = min(_headMouseY, _glWidget->height()); |
| 2600 | 1917 | ||
| 2601 | const float MIDPOINT_OF_SCREEN = 0.5; | 1918 | const float MIDPOINT_OF_SCREEN = 0.5; |
| 2602 | |||
| 2603 | // Set lookAtPosition if an avatar is at the center of the screen | ||
| 2604 | glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | ||
| 2605 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | ||
| 2606 | |||
| 2607 | glm::vec3 eyePosition; | ||
| 2608 | 1919 | ||
| 2609 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | 1920 | // Only use gyro to set lookAt if mouse hasn't selected an avatar |
| 2610 | if (_isLookingAtOtherAvatar) { | 1921 | if (!_isLookingAtOtherAvatar) { |
| 2611 | glm::vec3 myLookAtFromMouse(eyePosition); | 1922 | |
| 2612 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | 1923 | // Set lookAtPosition if an avatar is at the center of the screen |
| 1924 | glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | ||
| 1925 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | ||
| 1926 | |||
| 1927 | glm::vec3 eyePosition; | ||
| 1928 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | ||
| 1929 | if (_isLookingAtOtherAvatar) { | ||
| 1930 | glm::vec3 myLookAtFromMouse(eyePosition); | ||
| 1931 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | ||
| 1932 | } | ||
| 2613 | } | 1933 | } |
| 2614 | 1934 | ||
| 2615 | } | 1935 | } |
| @@ -2661,7 +1981,7 @@ void Application::updateAvatar(float deltaTime) { · 45 unmodified lines | |||
| 2661 | // once in a while, send my voxel url | 1981 | // once in a while, send my voxel url |
| 2662 | const float AVATAR_VOXEL_URL_SEND_INTERVAL = 1.0f; // seconds | 1982 | const float AVATAR_VOXEL_URL_SEND_INTERVAL = 1.0f; // seconds |
| 2663 | if (shouldDo(AVATAR_VOXEL_URL_SEND_INTERVAL, deltaTime)) { | 1983 | if (shouldDo(AVATAR_VOXEL_URL_SEND_INTERVAL, deltaTime)) { |
| 2664 | sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); | 1984 | Avatar::sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); |
| 2665 | } | 1985 | } |
| 2666 | } | 1986 | } |
| 2667 | } | 1987 | } |
| @@ -2871,7 +2191,7 @@ void Application::displaySide(Camera& whichCamera) { · 203 unmodified lines | |||
| 2871 | // transform by eye offset | 2191 | // transform by eye offset |
| 2872 | 2192 | ||
| 2873 | // flip x if in mirror mode (also requires reversing winding order for backface culling) | 2193 | // flip x if in mirror mode (also requires reversing winding order for backface culling) |
| 2874 | if (_lookingInMirror->isChecked()) { | 2194 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 2875 | glScalef(-1.0f, 1.0f, 1.0f); | 2195 | glScalef(-1.0f, 1.0f, 1.0f); |
| 2876 | glFrontFace(GL_CW); | 2196 | glFrontFace(GL_CW); |
| 2877 | 2197 | ||
| @@ -2901,7 +2221,7 @@ void Application::displaySide(Camera& whichCamera) { · 23 unmodified lines | |||
| 2901 | // prepare the glow effect | 2221 | // prepare the glow effect |
| 2902 | _glowEffect.prepare(); | 2222 | _glowEffect.prepare(); |
| 2903 | 2223 | ||
| 2904 | if (_renderStarsOn->isChecked()) { | 2224 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { |
| 2905 | if (!_stars.getFileLoaded()) { | 2225 | if (!_stars.getFileLoaded()) { |
| 2906 | _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); | 2226 | _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); |
| 2907 | } | 2227 | } |
| @@ -2909,7 +2229,7 @@ void Application::displaySide(Camera& whichCamera) { · 1 unmodified line | |||
| 2909 | 2229 | ||
| 2910 | // compute starfield alpha based on distance from atmosphere | 2230 | // compute starfield alpha based on distance from atmosphere |
| 2911 | float alpha = 1.0f; | 2231 | float alpha = 1.0f; |
| 2912 | if (_renderAtmosphereOn->isChecked()) { | 2232 | if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { |
| 2913 | const EnvironmentData& closestData = _environment.getClosestData(whichCamera.getPosition()); | 2233 | const EnvironmentData& closestData = _environment.getClosestData(whichCamera.getPosition()); |
| 2914 | float height = glm::distance(whichCamera.getPosition(), closestData.getAtmosphereCenter()); | 2234 | float height = glm::distance(whichCamera.getPosition(), closestData.getAtmosphereCenter()); |
| 2915 | if (height < closestData.getAtmosphereInnerRadius()) { | 2235 | if (height < closestData.getAtmosphereInnerRadius()) { |
| @@ -2926,7 +2246,7 @@ void Application::displaySide(Camera& whichCamera) { · 10 unmodified lines | |||
| 2926 | } | 2246 | } |
| 2927 | 2247 | ||
| 2928 | // draw the sky dome | 2248 | // draw the sky dome |
| 2929 | if (_renderAtmosphereOn->isChecked()) { | 2249 | if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { |
| 2930 | _environment.renderAtmospheres(whichCamera); | 2250 | _environment.renderAtmospheres(whichCamera); |
| 2931 | } | 2251 | } |
| 2932 | 2252 | ||
| @@ -2948,7 +2268,7 @@ void Application::displaySide(Camera& whichCamera) { · 15 unmodified lines | |||
| 2948 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); | 2268 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); |
| 2949 | 2269 | ||
| 2950 | //draw a grid ground plane.... | 2270 | //draw a grid ground plane.... |
| 2951 | if (_renderGroundPlaneOn->isChecked()) { | 2271 | if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) { |
| 2952 | // draw grass plane with fog | 2272 | // draw grass plane with fog |
| 2953 | glEnable(GL_FOG); | 2273 | glEnable(GL_FOG); |
| 2954 | glEnable(GL_NORMALIZE); | 2274 | glEnable(GL_NORMALIZE); |
| @@ -2971,8 +2291,8 @@ void Application::displaySide(Camera& whichCamera) { · 16 unmodified lines | |||
| 2971 | //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); | 2291 | //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); |
| 2972 | } | 2292 | } |
| 2973 | // Draw voxels | 2293 | // Draw voxels |
| 2974 | if (_renderVoxels->isChecked()) { | 2294 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 2975 | _voxels.render(_renderVoxelTextures->isChecked()); | 2295 | _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures)); |
| 2976 | } | 2296 | } |
| 2977 | 2297 | ||
| 2978 | // restore default, white specular | 2298 | // restore default, white specular |
| @@ -2984,7 +2304,7 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines | |||
| 2984 | glPushMatrix(); | 2304 | glPushMatrix(); |
| 2985 | glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); | 2305 | glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); |
| 2986 | renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); | 2306 | renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| 2987 | if (_addVoxelMode->isChecked()) { | 2307 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) { |
| 2988 | // use a contrasting color so that we can see what we're doing | 2308 | // use a contrasting color so that we can see what we're doing |
| 2989 | glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128); | 2309 | glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128); |
| 2990 | } else { | 2310 | } else { |
| @@ -3002,7 +2322,7 @@ void Application::displaySide(Camera& whichCamera) { · 11 unmodified lines | |||
| 3002 | 2322 | ||
| 3003 | _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera); | 2323 | _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera); |
| 3004 | 2324 | ||
| 3005 | if (_renderAvatarsOn->isChecked()) { | 2325 | if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) { |
| 3006 | // Render avatars of other nodes | 2326 | // Render avatars of other nodes |
| 3007 | NodeList* nodeList = NodeList::getInstance(); | 2327 | NodeList* nodeList = NodeList::getInstance(); |
| 3008 | 2328 | ||
| @@ -3014,11 +2334,12 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines | |||
| 3014 | if (!avatar->isInitialized()) { | 2334 | if (!avatar->isInitialized()) { |
| 3015 | avatar->init(); | 2335 | avatar->init(); |
| 3016 | } | 2336 | } |
| 2337 | // Set lookAt to myCamera on client side if other avatars are looking at client | ||
| 3017 | if (isLookingAtMyAvatar(avatar)) { | 2338 | if (isLookingAtMyAvatar(avatar)) { |
| 3018 | avatar->getHead().setLookAtPosition(_myCamera.getPosition()); | 2339 | avatar->getHead().setLookAtPosition(_myCamera.getPosition()); |
| 3019 | } | 2340 | } |
| 3020 | avatar->render(false, _renderAvatarBalls->isChecked()); | 2341 | avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); |
| 3021 | avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked()); | 2342 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3022 | } | 2343 | } |
| 3023 | 2344 | ||
| 3024 | node->unlock(); | 2345 | node->unlock(); |
| @@ -3028,28 +2349,26 @@ void Application::displaySide(Camera& whichCamera) { · 3 unmodified lines | |||
| 3028 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 2349 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3029 | _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); | 2350 | _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); |
| 3030 | } | 2351 | } |
| 3031 | _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); | 2352 | _myAvatar.render(Menu::getInstance()->isOptionChecked(MenuOption::Mirror), |
| 3032 | 2353 | Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 3033 | _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); | 2354 | _myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3034 | 2355 | ||
| 3035 | if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) { | 2356 | if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _isLookingAtOtherAvatar) { |
| 3036 | renderLookatIndicator(_lookatOtherPosition, whichCamera); | 2357 | renderLookatIndicator(_lookatOtherPosition, whichCamera); |
| 3037 | } | 2358 | } |
| 3038 | } | 2359 | } |
| 3039 | 2360 | ||
| 3040 | _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); | 2361 | _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); |
| 3041 | 2362 | ||
| 3042 | if (_renderParticleSystemOn->isChecked()) { | ||
| 3043 | if (_particleSystemInitialized) { | ||
| 3044 | _particleSystem.render(); | ||
| 3045 | } | ||
| 3046 | } | ||
| 3047 | |||
| 3048 | // Render the world box | 2363 | // Render the world box |
| 3049 | if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { renderWorldBox(); } | 2364 | if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2365 | renderWorldBox(); | ||
| 2366 | } | ||
| 3050 | 2367 | ||
| 3051 | // brad's frustum for debugging | 2368 | // brad's frustum for debugging |
| 3052 | if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); | 2369 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { |
| 2370 | renderViewFrustum(_viewFrustum); | ||
| 2371 | } | ||
| 3053 | 2372 | ||
| 3054 | // render voxel fades if they exist | 2373 | // render voxel fades if they exist |
| 3055 | if (_voxelFades.size() > 0) { | 2374 | if (_voxelFades.size() > 0) { |
| @@ -3087,14 +2406,16 @@ void Application::displayOverlay() { · 31 unmodified lines | |||
| 3087 | 2406 | ||
| 3088 | #ifndef _WIN32 | 2407 | #ifndef _WIN32 |
| 3089 | _audio.render(_glWidget->width(), _glWidget->height()); | 2408 | _audio.render(_glWidget->width(), _glWidget->height()); |
| 3090 | if (_oscilloscopeOn->isChecked()) { | 2409 | if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) { |
| 3091 | _audioScope.render(20, _glWidget->height() - 200); | 2410 | _audioScope.render(20, _glWidget->height() - 200); |
| 3092 | } | 2411 | } |
| 3093 | #endif | 2412 | #endif |
| 3094 | 2413 | ||
| 3095 | //noiseTest(_glWidget->width(), _glWidget->height()); | 2414 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| 3096 | 2415 | ||
| 3097 | if (_showHeadMouse->isChecked() && !_lookingInMirror->isChecked() && USING_INVENSENSE_MPU9150) { | 2416 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) |
| 2417 | && !Menu::getInstance()->isOptionChecked(MenuOption::Mirror) | ||
| 2418 | && USING_INVENSENSE_MPU9150) { | ||
| 3098 | // Display small target box at center or head mouse target that can also be used to measure LOD | 2419 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| 3099 | glColor3f(1.0, 1.0, 1.0); | 2420 | glColor3f(1.0, 1.0, 1.0); |
| 3100 | glDisable(GL_LINE_SMOOTH); | 2421 | glDisable(GL_LINE_SMOOTH); |
| @@ -3120,14 +2441,26 @@ void Application::displayOverlay() { · 19 unmodified lines | |||
| 3120 | glLineWidth(1.0f); | 2441 | glLineWidth(1.0f); |
| 3121 | glPointSize(1.0f); | 2442 | glPointSize(1.0f); |
| 3122 | 2443 | ||
| 3123 | if (_renderStatsOn->isChecked()) { displayStats(); } | 2444 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2445 | displayStats(); | ||
| 2446 | } | ||
| 3124 | 2447 | ||
| 3125 | // testing rendering coverage map | 2448 | // testing rendering coverage map |
| 3126 | if (_renderCoverageMapV2->isChecked()) { renderCoverageMapV2(); } | 2449 | if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) { |
| 3127 | if (_renderCoverageMap->isChecked()) { renderCoverageMap(); } | 2450 | renderCoverageMapV2(); |
| 3128 | if (_bandwidthDisplayOn->isChecked()) { _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); } | 2451 | } |
| 2452 | |||
| 2453 | if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) { | ||
| 2454 | renderCoverageMap(); | ||
| 2455 | } | ||
| 2456 | |||
| 2457 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) { | ||
| 2458 | _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); | ||
| 2459 | } | ||
| 3129 | 2460 | ||
| 3130 | if (_logOn->isChecked()) { LogDisplay::instance.render(_glWidget->width(), _glWidget->height()); } | 2461 | if (Menu::getInstance()->isOptionChecked(MenuOption::Log)) { |
| 2462 | LogDisplay::instance.render(_glWidget->width(), _glWidget->height()); | ||
| 2463 | } | ||
| 3131 | 2464 | ||
| 3132 | // Show chat entry field | 2465 | // Show chat entry field |
| 3133 | if (_chatEntryOn) { | 2466 | if (_chatEntryOn) { |
| @@ -3135,7 +2468,7 @@ void Application::displayOverlay() { · 1 unmodified line | |||
| 3135 | } | 2468 | } |
| 3136 | 2469 | ||
| 3137 | // Show on-screen msec timer | 2470 | // Show on-screen msec timer |
| 3138 | if (_renderFrameTimerOn->isChecked()) { | 2471 | if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { |
| 3139 | char frameTimer[10]; | 2472 | char frameTimer[10]; |
| 3140 | uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); | 2473 | uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 3141 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); | 2474 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| @@ -3143,7 +2476,6 @@ void Application::displayOverlay() { · 1 unmodified line | |||
| 3143 | drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1); | 2476 | drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1); |
| 3144 | } | 2477 | } |
| 3145 | 2478 | ||
| 3146 | |||
| 3147 | // Stats at upper right of screen about who domain server is telling us about | 2479 | // Stats at upper right of screen about who domain server is telling us about |
| 3148 | glPointSize(1.0f); | 2480 | glPointSize(1.0f); |
| 3149 | char nodes[100]; | 2481 | char nodes[100]; |
| @@ -3163,8 +2495,11 @@ void Application::displayOverlay() { · 13 unmodified lines | |||
| 3163 | 2495 | ||
| 3164 | _palette.render(_glWidget->width(), _glWidget->height()); | 2496 | _palette.render(_glWidget->width(), _glWidget->height()); |
| 3165 | 2497 | ||
| 3166 | if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch.getColor()) { | 2498 | QAction* paintColorAction = NULL; |
| 3167 | QColor color = _voxelPaintColor->data().value<QColor>(); | 2499 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode) |
| 2500 | && (paintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor))->data().value<QColor>() | ||
| 2501 | != _swatch.getColor()) { | ||
| 2502 | QColor color = paintColorAction->data().value<QColor>(); | ||
| 3168 | TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50); | 2503 | TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50); |
| 3169 | const char line1[] = "Assign this color to a swatch"; | 2504 | const char line1[] = "Assign this color to a swatch"; |
| 3170 | const char line2[] = "by choosing a key from 1 to 8."; | 2505 | const char line2[] = "by choosing a key from 1 to 8."; |
| @@ -3221,7 +2556,7 @@ void Application::displayStats() { · 50 unmodified lines | |||
| 3221 | _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); | 2556 | _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); |
| 3222 | drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); | 2557 | drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); |
| 3223 | 2558 | ||
| 3224 | if (_testPing->isChecked()) { | 2559 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 3225 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; | 2560 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3226 | 2561 | ||
| 3227 | NodeList* nodeList = NodeList::getInstance(); | 2562 | NodeList* nodeList = NodeList::getInstance(); |
| @@ -3515,7 +2850,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 287 unmodified lines | |||
| 3515 | glLineWidth(1.0); | 2850 | glLineWidth(1.0); |
| 3516 | glBegin(GL_LINES); | 2851 | glBegin(GL_LINES); |
| 3517 | 2852 | ||
| 3518 | if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_VECTORS) { | 2853 | if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL |
| 2854 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_VECTORS) { | ||
| 3519 | // Calculate the origin direction vectors | 2855 | // Calculate the origin direction vectors |
| 3520 | glm::vec3 lookingAt = position + (direction * 0.2f); | 2856 | glm::vec3 lookingAt = position + (direction * 0.2f); |
| 3521 | glm::vec3 lookingAtUp = position + (up * 0.2f); | 2857 | glm::vec3 lookingAtUp = position + (up * 0.2f); |
| @@ -3537,8 +2873,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 15 unmodified lines | |||
| 3537 | glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z); | 2873 | glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z); |
| 3538 | } | 2874 | } |
| 3539 | 2875 | ||
| 3540 | if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | 2876 | if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL |
| 3541 | || _frustumDrawingMode == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | 2877 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES |
| 2878 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | ||
| 3542 | // Drawing the bounds of the frustum | 2879 | // Drawing the bounds of the frustum |
| 3543 | // viewFrustum.getNear plane - bottom edge | 2880 | // viewFrustum.getNear plane - bottom edge |
| 3544 | glColor3f(1,0,0); | 2881 | glColor3f(1,0,0); |
| @@ -3558,8 +2895,9 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 13 unmodified lines | |||
| 3558 | glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | 2895 | glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); |
| 3559 | } | 2896 | } |
| 3560 | 2897 | ||
| 3561 | if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | 2898 | if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL |
| 3562 | || _frustumDrawingMode == FRUSTUM_DRAW_MODE_FAR_PLANE) { | 2899 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES |
| 2900 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) { | ||
| 3563 | // viewFrustum.getFar plane - bottom edge | 2901 | // viewFrustum.getFar plane - bottom edge |
| 3564 | glColor3f(0,1,0); // GREEN!!! | 2902 | glColor3f(0,1,0); // GREEN!!! |
| 3565 | glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | 2903 | glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); |
| @@ -3578,7 +2916,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 12 unmodified lines | |||
| 3578 | glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | 2916 | glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); |
| 3579 | } | 2917 | } |
| 3580 | 2918 | ||
| 3581 | if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES) { | 2919 | if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL |
| 2920 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES) { | ||
| 3582 | // RIGHT PLANE IS CYAN | 2921 | // RIGHT PLANE IS CYAN |
| 3583 | // right plane - bottom edge - viewFrustum.getNear to distant | 2922 | // right plane - bottom edge - viewFrustum.getNear to distant |
| 3584 | glColor3f(0,1,1); | 2923 | glColor3f(0,1,1); |
| @@ -3602,7 +2941,8 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 17 unmodified lines | |||
| 3602 | glEnd(); | 2941 | glEnd(); |
| 3603 | glEnable(GL_LIGHTING); | 2942 | glEnable(GL_LIGHTING); |
| 3604 | 2943 | ||
| 3605 | if (_frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || _frustumDrawingMode == FRUSTUM_DRAW_MODE_KEYHOLE) { | 2944 | if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL |
| 2945 | || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_KEYHOLE) { | ||
| 3606 | // Draw the keyhole | 2946 | // Draw the keyhole |
| 3607 | float keyholeRadius = viewFrustum.getKeyholeRadius(); | 2947 | float keyholeRadius = viewFrustum.getKeyholeRadius(); |
| 3608 | if (keyholeRadius > 0.0f) { | 2948 | if (keyholeRadius > 0.0f) { |
| @@ -3672,15 +3012,18 @@ void Application::injectVoxelAddedSoundEffect() { · 63 unmodified lines | |||
| 3672 | } | 3012 | } |
| 3673 | 3013 | ||
| 3674 | bool Application::maybeEditVoxelUnderCursor() { | 3014 | bool Application::maybeEditVoxelUnderCursor() { |
| 3675 | if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) { | 3015 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) |
| 3016 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode)) { | ||
| 3676 | if (_mouseVoxel.s != 0) { | 3017 | if (_mouseVoxel.s != 0) { |
| 3677 | PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ? | 3018 | PACKET_TYPE message = Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel) |
| 3678 | PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL); | 3019 | ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE |
| 3020 | : PACKET_TYPE_SET_VOXEL; | ||
| 3679 | _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel); | 3021 | _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel); |
| 3680 | 3022 | ||
| 3681 | // create the voxel locally so it appears immediately | 3023 | // create the voxel locally so it appears immediately |
| 3682 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, | 3024 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, |
| 3683 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked()); | 3025 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, |
| 3026 | Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)); | ||
| 3684 | 3027 | ||
| 3685 | // Implement voxel fade effect | 3028 | // Implement voxel fade effect |
| 3686 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | 3029 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); |
| @@ -3699,7 +3042,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 12 unmodified lines | |||
| 3699 | _justEditedVoxel = true; | 3042 | _justEditedVoxel = true; |
| 3700 | 3043 | ||
| 3701 | } | 3044 | } |
| 3702 | } else if (_deleteVoxelMode->isChecked()) { | 3045 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode)) { |
| 3703 | deleteVoxelUnderCursor(); | 3046 | deleteVoxelUnderCursor(); |
| 3704 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | 3047 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); |
| 3705 | const float VOXEL_BOUNDS_ADJUST = 0.01f; | 3048 | const float VOXEL_BOUNDS_ADJUST = 0.01f; |
| @@ -3710,7 +3053,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines | |||
| 3710 | fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | 3053 | fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; |
| 3711 | _voxelFades.push_back(fade); | 3054 | _voxelFades.push_back(fade); |
| 3712 | 3055 | ||
| 3713 | } else if (_eyedropperMode->isChecked()) { | 3056 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelGetColorMode)) { |
| 3714 | eyedropperVoxelUnderCursor(); | 3057 | eyedropperVoxelUnderCursor(); |
| 3715 | } else { | 3058 | } else { |
| 3716 | return false; | 3059 | return false; |
| @@ -3751,18 +3094,13 @@ void Application::eyedropperVoxelUnderCursor() { · 34 unmodified lines | |||
| 3751 | selectedNode->getColor()[BLUE_INDEX]); | 3094 | selectedNode->getColor()[BLUE_INDEX]); |
| 3752 | 3095 | ||
| 3753 | if (selectedColor.isValid()) { | 3096 | if (selectedColor.isValid()) { |
| 3754 | _voxelPaintColor->setData(selectedColor); | 3097 | QAction* voxelPaintColorAction = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor); |
| 3755 | _voxelPaintColor->setIcon(createSwatchIcon(selectedColor)); | 3098 | voxelPaintColorAction->setData(selectedColor); |
| 3099 | voxelPaintColorAction->setIcon(Swatch::createIcon(selectedColor)); | ||
| 3756 | } | 3100 | } |
| 3757 | } | 3101 | } |
| 3758 | } | 3102 | } |
| 3759 | 3103 | ||
| 3760 | void Application::goHome() { | ||
| 3761 | qDebug("Going Home!\n"); | ||
| 3762 | _myAvatar.setPosition(START_LOCATION); | ||
| 3763 | } | ||
| 3764 | |||
| 3765 | |||
| 3766 | void Application::toggleFollowMode() { | 3104 | void Application::toggleFollowMode() { |
| 3767 | glm::vec3 mouseRayOrigin, mouseRayDirection; | 3105 | glm::vec3 mouseRayOrigin, mouseRayDirection; |
| 3768 | _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), | 3106 | _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), |
| @@ -3817,17 +3155,6 @@ void Application::updateCursor() { · 48 unmodified lines | |||
| 3817 | Qt::BlankCursor : Qt::ArrowCursor); | 3155 | Qt::BlankCursor : Qt::ArrowCursor); |
| 3818 | } | 3156 | } |
| 3819 | 3157 | ||
| 3820 | // when QActionGroup is set to non-exclusive, it doesn't return anything as checked; | ||
| 3821 | // hence, we must check ourselves | ||
| 3822 | QAction* Application::checkedVoxelModeAction() const { | ||
| 3823 | foreach (QAction* action, _voxelModeActions->actions()) { | ||
| 3824 | if (action->isChecked()) { | ||
| 3825 | return action; | ||
| 3826 | } | ||
| 3827 | } | ||
| 3828 | return 0; | ||
| 3829 | } | ||
| 3830 | |||
| 3831 | void Application::attachNewHeadToNode(Node* newNode) { | 3158 | void Application::attachNewHeadToNode(Node* newNode) { |
| 3832 | if (newNode->getLinkedData() == NULL) { | 3159 | if (newNode->getLinkedData() == NULL) { |
| 3833 | newNode->setLinkedData(new Avatar(newNode)); | 3160 | newNode->setLinkedData(new Avatar(newNode)); |
| @@ -3958,190 +3285,3 @@ void* Application::networkReceive(void* args) { · 124 unmodified lines | |||
| 3958 | } | 3285 | } |
| 3959 | return NULL; | 3286 | return NULL; |
| 3960 | } | 3287 | } |
| 3961 | |||
| 3962 | void Application::scanMenuBar(settingsAction modifySetting, QSettings* set) { | ||
| 3963 | if (!_window->menuBar()) { | ||
| 3964 | return; | ||
| 3965 | } | ||
| 3966 | |||
| 3967 | QList<QMenu*> menus = _window->menuBar()->findChildren<QMenu *>(); | ||
| 3968 | |||
| 3969 | for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) { | ||
| 3970 | scanMenu(*it, modifySetting, set); | ||
| 3971 | } | ||
| 3972 | } | ||
| 3973 | |||
| 3974 | void Application::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) { | ||
| 3975 | QList<QAction*> actions = menu->actions(); | ||
| 3976 | |||
| 3977 | set->beginGroup(menu->title()); | ||
| 3978 | for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) { | ||
| 3979 | if ((*it)->menu()) { | ||
| 3980 | scanMenu((*it)->menu(), modifySetting, set); | ||
| 3981 | } | ||
| 3982 | if ((*it)->isCheckable()) { | ||
| 3983 | modifySetting(set, *it); | ||
| 3984 | } | ||
| 3985 | } | ||
| 3986 | set->endGroup(); | ||
| 3987 | } | ||
| 3988 | |||
| 3989 | void Application::loadAction(QSettings* set, QAction* action) { | ||
| 3990 | if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) { | ||
| 3991 | action->trigger(); | ||
| 3992 | } | ||
| 3993 | } | ||
| 3994 | |||
| 3995 | void Application::saveAction(QSettings* set, QAction* action) { | ||
| 3996 | set->setValue(action->text(), action->isChecked()); | ||
| 3997 | } | ||
| 3998 | |||
| 3999 | void Application::loadSettings(QSettings* settings) { | ||
| 4000 | if (!settings) { | ||
| 4001 | settings = getSettings(); | ||
| 4002 | } | ||
| 4003 | |||
| 4004 | _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f); | ||
| 4005 | _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); | ||
| 4006 | _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); | ||
| 4007 | |||
| 4008 | settings->beginGroup("View Frustum Offset Camera"); | ||
| 4009 | // in case settings is corrupt or missing loadSetting() will check for NaN | ||
| 4010 | _viewFrustumOffsetYaw = loadSetting(settings, "viewFrustumOffsetYaw" , 0.0f); | ||
| 4011 | _viewFrustumOffsetPitch = loadSetting(settings, "viewFrustumOffsetPitch" , 0.0f); | ||
| 4012 | _viewFrustumOffsetRoll = loadSetting(settings, "viewFrustumOffsetRoll" , 0.0f); | ||
| 4013 | _viewFrustumOffsetDistance = loadSetting(settings, "viewFrustumOffsetDistance", 0.0f); | ||
| 4014 | _viewFrustumOffsetUp = loadSetting(settings, "viewFrustumOffsetUp" , 0.0f); | ||
| 4015 | settings->endGroup(); | ||
| 4016 | |||
| 4017 | scanMenuBar(&Application::loadAction, settings); | ||
| 4018 | getAvatar()->loadData(settings); | ||
| 4019 | _swatch.loadData(settings); | ||
| 4020 | } | ||
| 4021 | |||
| 4022 | |||
| 4023 | void Application::saveSettings(QSettings* settings) { | ||
| 4024 | if (!settings) { | ||
| 4025 | settings = getSettings(); | ||
| 4026 | } | ||
| 4027 | |||
| 4028 | settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity); | ||
| 4029 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); | ||
| 4030 | settings->setValue("fieldOfView", _fieldOfView); | ||
| 4031 | settings->beginGroup("View Frustum Offset Camera"); | ||
| 4032 | settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffsetYaw); | ||
| 4033 | settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffsetPitch); | ||
| 4034 | settings->setValue("viewFrustumOffsetRoll", _viewFrustumOffsetRoll); | ||
| 4035 | settings->setValue("viewFrustumOffsetDistance", _viewFrustumOffsetDistance); | ||
| 4036 | settings->setValue("viewFrustumOffsetUp", _viewFrustumOffsetUp); | ||
| 4037 | settings->endGroup(); | ||
| 4038 | |||
| 4039 | scanMenuBar(&Application::saveAction, settings); | ||
| 4040 | getAvatar()->saveData(settings); | ||
| 4041 | _swatch.saveData(settings); | ||
| 4042 | |||
| 4043 | // ask the NodeList to save its data | ||
| 4044 | NodeList::getInstance()->saveData(settings); | ||
| 4045 | } | ||
| 4046 | |||
| 4047 | void Application::importSettings() { | ||
| 4048 | QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); | ||
| 4049 | QString fileName = QFileDialog::getOpenFileName(_window, | ||
| 4050 | tr("Open .ini config file"), | ||
| 4051 | locationDir, | ||
| 4052 | tr("Text files (*.ini)")); | ||
| 4053 | if (fileName != "") { | ||
| 4054 | QSettings tmp(fileName, QSettings::IniFormat); | ||
| 4055 | loadSettings(&tmp); | ||
| 4056 | } | ||
| 4057 | } | ||
| 4058 | |||
| 4059 | void Application::exportSettings() { | ||
| 4060 | QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); | ||
| 4061 | QString fileName = QFileDialog::getSaveFileName(_window, | ||
| 4062 | tr("Save .ini config file"), | ||
| 4063 | locationDir, | ||
| 4064 | tr("Text files (*.ini)")); | ||
| 4065 | if (fileName != "") { | ||
| 4066 | QSettings tmp(fileName, QSettings::IniFormat); | ||
| 4067 | saveSettings(&tmp); | ||
| 4068 | tmp.sync(); | ||
| 4069 | } | ||
| 4070 | } | ||
| 4071 | |||
| 4072 | |||
| 4073 | void Application::updateParticleSystem(float deltaTime) { | ||
| 4074 | |||
| 4075 | if (!_particleSystemInitialized) { | ||
| 4076 | |||
| 4077 | const int LIFESPAN_IN_SECONDS = 100000.0f; | ||
| 4078 | const float EMIT_RATE_IN_SECONDS = 10000.0; | ||
| 4079 | // create a stable test emitter and spit out a bunch of particles | ||
| 4080 | _coolDemoParticleEmitter = _particleSystem.addEmitter(); | ||
| 4081 | |||
| 4082 | if (_coolDemoParticleEmitter != -1) { | ||
| 4083 | |||
| 4084 | _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true); | ||
| 4085 | glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f); | ||
| 4086 | |||
| 4087 | _particleSystem.setEmitterPosition (_coolDemoParticleEmitter, particleEmitterPosition); | ||
| 4088 | _particleSystem.setEmitterParticleLifespan(_coolDemoParticleEmitter, LIFESPAN_IN_SECONDS); | ||
| 4089 | _particleSystem.setEmitterThrust (_coolDemoParticleEmitter, 0.0f); | ||
| 4090 | _particleSystem.setEmitterRate (_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // to emit a pile o particles now | ||
| 4091 | } | ||
| 4092 | |||
| 4093 | // signal that the particle system has been initialized | ||
| 4094 | _particleSystemInitialized = true; | ||
| 4095 | } else { | ||
| 4096 | // update the particle system | ||
| 4097 | |||
| 4098 | static bool emitting = true; | ||
| 4099 | static float effectsTimer = 0.0f; | ||
| 4100 | effectsTimer += deltaTime; | ||
| 4101 | |||
| 4102 | if (_coolDemoParticleEmitter != -1) { | ||
| 4103 | |||
| 4104 | _particleSystem.setEmitterDirection(_coolDemoParticleEmitter, glm::vec3(0.0f, 1.0f, 0.0f)); | ||
| 4105 | |||
| 4106 | ParticleSystem::ParticleAttributes attributes; | ||
| 4107 | |||
| 4108 | attributes.radius = 0.01f; | ||
| 4109 | attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); | ||
| 4110 | attributes.gravity = 0.0f + 0.05f * sinf( effectsTimer * 0.52f ); | ||
| 4111 | attributes.airFriction = 2.5 + 2.0f * sinf( effectsTimer * 0.32f ); | ||
| 4112 | attributes.jitter = 0.05f + 0.05f * sinf( effectsTimer * 0.42f ); | ||
| 4113 | attributes.emitterAttraction = 0.015f + 0.015f * cosf( effectsTimer * 0.6f ); | ||
| 4114 | attributes.tornadoForce = 0.0f + 0.03f * sinf( effectsTimer * 0.7f ); | ||
| 4115 | attributes.neighborAttraction = 0.1f + 0.1f * cosf( effectsTimer * 0.8f ); | ||
| 4116 | attributes.neighborRepulsion = 0.2f + 0.2f * sinf( effectsTimer * 0.4f ); | ||
| 4117 | attributes.bounce = 1.0f; | ||
| 4118 | attributes.usingCollisionSphere = true; | ||
| 4119 | attributes.collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f ); | ||
| 4120 | attributes.collisionSphereRadius = 0.5f; | ||
| 4121 | attributes.usingCollisionPlane = true; | ||
| 4122 | attributes.collisionPlanePosition = glm::vec3( 5.0f, 0.0f, 5.0f ); | ||
| 4123 | attributes.collisionPlaneNormal = glm::vec3( 0.0f, 1.0f, 0.0f ); | ||
| 4124 | |||
| 4125 | if (attributes.gravity < 0.0f) { | ||
| 4126 | attributes.gravity = 0.0f; | ||
| 4127 | } | ||
| 4128 | |||
| 4129 | _particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes); | ||
| 4130 | } | ||
| 4131 | |||
| 4132 | _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); | ||
| 4133 | _particleSystem.simulate(deltaTime); | ||
| 4134 | |||
| 4135 | const float EMIT_RATE_IN_SECONDS = 0.0; | ||
| 4136 | |||
| 4137 | if (_coolDemoParticleEmitter != -1) { | ||
| 4138 | if (emitting) { | ||
| 4139 | _particleSystem.setEmitterRate(_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // stop emitter | ||
| 4140 | emitting = false; | ||
| 4141 | } | ||
| 4142 | } | ||
| 4143 | } | ||
| 4144 | } | ||
| 4145 | |||
| 4146 | |||
| 4147 | |||