Showing the changes to interface/src/Application.cpp (1 of 26 files). Show all
Unified · Split
| @@ -164,9 +164,9 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { · 163 unmodified lines | |||
| 164 | Application::getInstance()->wheelEvent(event); | 164 | Application::getInstance()->wheelEvent(event); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | void messageHandler(QtMsgType type, const char* message) { | 167 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 168 | fprintf(stdout, "%s", message); | 168 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| 169 | LogDisplay::instance.addMessage(message); | 169 | LogDisplay::instance.addMessage(message.toLocal8Bit().constData()); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | Application::Application(int& argc, char** argv, timeval &startup_time) : | 172 | Application::Application(int& argc, char** argv, timeval &startup_time) : |
| @@ -224,7 +224,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 51 unmodified lines | |||
| 224 | _applicationStartupTime = startup_time; | 224 | _applicationStartupTime = startup_time; |
| 225 | _window->setWindowTitle("Interface"); | 225 | _window->setWindowTitle("Interface"); |
| 226 | 226 | ||
| 227 | qInstallMsgHandler(messageHandler); | 227 | qInstallMessageHandler(messageHandler); |
| 228 | 228 | ||
| 229 | unsigned int listenPort = 0; // bind to an ephemeral port by default | 229 | unsigned int listenPort = 0; // bind to an ephemeral port by default |
| 230 | const char** constArgv = const_cast<const char**>(argv); | 230 | const char** constArgv = const_cast<const char**>(argv); |
| @@ -566,6 +566,11 @@ void Application::keyPressEvent(QKeyEvent* event) { · 335 unmodified lines | |||
| 566 | } | 566 | } |
| 567 | return; | 567 | return; |
| 568 | } | 568 | } |
| 569 | |||
| 570 | //this is for switching between modes for the leap rave glove test | ||
| 571 | if (_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()) { | ||
| 572 | _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); | ||
| 573 | } | ||
| 569 | 574 | ||
| 570 | bool shifted = event->modifiers().testFlag(Qt::ShiftModifier); | 575 | bool shifted = event->modifiers().testFlag(Qt::ShiftModifier); |
| 571 | switch (event->key()) { | 576 | switch (event->key()) { |
| @@ -1226,7 +1231,7 @@ void Application::editPreferences() { · 654 unmodified lines | |||
| 1226 | 1231 | ||
| 1227 | if (domainServerHostname->text().size() > 0) { | 1232 | if (domainServerHostname->text().size() > 0) { |
| 1228 | // the user input a new hostname, use that | 1233 | // the user input a new hostname, use that |
| 1229 | newHostname = domainServerHostname->text().toAscii(); | 1234 | newHostname = domainServerHostname->text().toLocal8Bit(); |
| 1230 | } else { | 1235 | } else { |
| 1231 | // the user left the field blank, use the default hostname | 1236 | // the user left the field blank, use the default hostname |
| 1232 | newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); | 1237 | newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); |
| @@ -1522,12 +1527,12 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 289 unmodified lines | |||
| 1522 | } | 1527 | } |
| 1523 | 1528 | ||
| 1524 | void Application::exportVoxels() { | 1529 | void Application::exportVoxels() { |
| 1525 | QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); | 1530 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1526 | QString suggestedName = desktopLocation.append("/voxels.svo"); | 1531 | QString suggestedName = desktopLocation.append("/voxels.svo"); |
| 1527 | 1532 | ||
| 1528 | QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName, | 1533 | QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName, |
| 1529 | tr("Sparse Voxel Octree Files (*.svo)")); | 1534 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1530 | QByteArray fileNameAscii = fileNameString.toAscii(); | 1535 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1531 | const char* fileName = fileNameAscii.data(); | 1536 | const char* fileName = fileNameAscii.data(); |
| 1532 | VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); | 1537 | VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| 1533 | if (selectedNode) { | 1538 | if (selectedNode) { |
| @@ -1542,11 +1547,11 @@ void Application::exportVoxels() { · 8 unmodified lines | |||
| 1542 | 1547 | ||
| 1543 | const char* IMPORT_FILE_TYPES = "Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)"; | 1548 | const char* IMPORT_FILE_TYPES = "Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)"; |
| 1544 | void Application::importVoxelsToClipboard() { | 1549 | void Application::importVoxelsToClipboard() { |
| 1545 | QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); | 1550 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1546 | QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation, | 1551 | QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation, |
| 1547 | tr(IMPORT_FILE_TYPES)); | 1552 | tr(IMPORT_FILE_TYPES)); |
| 1548 | 1553 | ||
| 1549 | QByteArray fileNameAscii = fileNameString.toAscii(); | 1554 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1550 | const char* fileName = fileNameAscii.data(); | 1555 | const char* fileName = fileNameAscii.data(); |
| 1551 | 1556 | ||
| 1552 | _clipboardTree.eraseAllVoxels(); | 1557 | _clipboardTree.eraseAllVoxels(); |
| @@ -1576,11 +1581,11 @@ void Application::importVoxelsToClipboard() { · 23 unmodified lines | |||
| 1576 | } | 1581 | } |
| 1577 | 1582 | ||
| 1578 | void Application::importVoxels() { | 1583 | void Application::importVoxels() { |
| 1579 | QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); | 1584 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1580 | QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation, | 1585 | QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation, |
| 1581 | tr(IMPORT_FILE_TYPES)); | 1586 | tr(IMPORT_FILE_TYPES)); |
| 1582 | 1587 | ||
| 1583 | QByteArray fileNameAscii = fileNameString.toAscii(); | 1588 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1584 | const char* fileName = fileNameAscii.data(); | 1589 | const char* fileName = fileNameAscii.data(); |
| 1585 | 1590 | ||
| 1586 | VoxelTree importVoxels; | 1591 | VoxelTree importVoxels; |
| @@ -1994,8 +1999,11 @@ const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; · 407 unmodified lines | |||
| 1994 | const float HEAD_SPHERE_RADIUS = 0.07; | 1999 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1995 | 2000 | ||
| 1996 | 2001 | ||
| 2002 | static uint16_t DEFAULT_NODE_ID_REF = 1; | ||
| 2003 | |||
| 2004 | |||
| 1997 | bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | 2005 | bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, |
| 1998 | glm::vec3& eyePosition, uint16_t& nodeID) { | 2006 | glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) { |
| 1999 | 2007 | ||
| 2000 | NodeList* nodeList = NodeList::getInstance(); | 2008 | NodeList* nodeList = NodeList::getInstance(); |
| 2001 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2009 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| @@ -2052,8 +2060,8 @@ void Application::update(float deltaTime) { · 50 unmodified lines | |||
| 2052 | 2060 | ||
| 2053 | // Set where I am looking based on my mouse ray (so that other people can see) | 2061 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 2054 | glm::vec3 eyePosition; | 2062 | glm::vec3 eyePosition; |
| 2055 | uint16_t ignored; | 2063 | |
| 2056 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, ignored); | 2064 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition); |
| 2057 | if (_isLookingAtOtherAvatar) { | 2065 | if (_isLookingAtOtherAvatar) { |
| 2058 | // If the mouse is over another avatar's head... | 2066 | // If the mouse is over another avatar's head... |
| 2059 | glm::vec3 myLookAtFromMouse(eyePosition); | 2067 | glm::vec3 myLookAtFromMouse(eyePosition); |
| @@ -2353,8 +2361,8 @@ void Application::updateAvatar(float deltaTime) { · 293 unmodified lines | |||
| 2353 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | 2361 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); |
| 2354 | 2362 | ||
| 2355 | glm::vec3 eyePosition; | 2363 | glm::vec3 eyePosition; |
| 2356 | uint16_t ignored; | 2364 | |
| 2357 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition, ignored); | 2365 | _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); |
| 2358 | if (_isLookingAtOtherAvatar) { | 2366 | if (_isLookingAtOtherAvatar) { |
| 2359 | glm::vec3 myLookAtFromMouse(eyePosition); | 2367 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2360 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | 2368 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| @@ -2393,7 +2401,7 @@ void Application::updateAvatar(float deltaTime) { · 32 unmodified lines | |||
| 2393 | NodeList* nodeList = NodeList::getInstance(); | 2401 | NodeList* nodeList = NodeList::getInstance(); |
| 2394 | if (nodeList->getOwnerID() != UNKNOWN_NODE_ID) { | 2402 | if (nodeList->getOwnerID() != UNKNOWN_NODE_ID) { |
| 2395 | // if I know my ID, send head/hand data to the avatar mixer and voxel server | 2403 | // if I know my ID, send head/hand data to the avatar mixer and voxel server |
| 2396 | unsigned char broadcastString[200]; | 2404 | unsigned char broadcastString[MAX_PACKET_SIZE]; |
| 2397 | unsigned char* endOfBroadcastStringWrite = broadcastString; | 2405 | unsigned char* endOfBroadcastStringWrite = broadcastString; |
| 2398 | 2406 | ||
| 2399 | endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); | 2407 | endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); |
| @@ -2764,13 +2772,12 @@ void Application::displaySide(Camera& whichCamera) { · 364 unmodified lines | |||
| 2764 | _particleSystem.render(); | 2772 | _particleSystem.render(); |
| 2765 | } | 2773 | } |
| 2766 | } | 2774 | } |
| 2767 | 2775 | ||
| 2768 | // Render the world box | 2776 | // Render the world box |
| 2769 | if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); } | 2777 | if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); } |
| 2770 | 2778 | ||
| 2771 | // brad's frustum for debugging | 2779 | // brad's frustum for debugging |
| 2772 | if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); | 2780 | if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); |
| 2773 | |||
| 2774 | } | 2781 | } |
| 2775 | 2782 | ||
| 2776 | void Application::displayOverlay() { | 2783 | void Application::displayOverlay() { |
| @@ -3668,7 +3675,7 @@ void Application::saveSettings(QSettings* settings) { · 891 unmodified lines | |||
| 3668 | } | 3675 | } |
| 3669 | 3676 | ||
| 3670 | void Application::importSettings() { | 3677 | void Application::importSettings() { |
| 3671 | QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation)); | 3678 | QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); |
| 3672 | QString fileName = QFileDialog::getOpenFileName(_window, | 3679 | QString fileName = QFileDialog::getOpenFileName(_window, |
| 3673 | tr("Open .ini config file"), | 3680 | tr("Open .ini config file"), |
| 3674 | locationDir, | 3681 | locationDir, |
| @@ -3680,7 +3687,7 @@ void Application::importSettings() { · 5 unmodified lines | |||
| 3680 | } | 3687 | } |
| 3681 | 3688 | ||
| 3682 | void Application::exportSettings() { | 3689 | void Application::exportSettings() { |
| 3683 | QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation)); | 3690 | QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); |
| 3684 | QString fileName = QFileDialog::getSaveFileName(_window, | 3691 | QString fileName = QFileDialog::getSaveFileName(_window, |
| 3685 | tr("Save .ini config file"), | 3692 | tr("Save .ini config file"), |
| 3686 | locationDir, | 3693 | locationDir, |
| @@ -3693,56 +3700,57 @@ void Application::exportSettings() { · 6 unmodified lines | |||
| 3693 | } | 3700 | } |
| 3694 | 3701 | ||
| 3695 | 3702 | ||
| 3696 | |||
| 3697 | void Application::updateParticleSystem(float deltaTime) { | 3703 | void Application::updateParticleSystem(float deltaTime) { |
| 3698 | 3704 | ||
| 3699 | if (!_particleSystemInitialized) { | 3705 | if (!_particleSystemInitialized) { |
| 3706 | |||
| 3707 | const int LIFESPAN_IN_SECONDS = 100000.0f; | ||
| 3708 | const float EMIT_RATE_IN_SECONDS = 10000.0; | ||
| 3700 | // create a stable test emitter and spit out a bunch of particles | 3709 | // create a stable test emitter and spit out a bunch of particles |
| 3701 | _coolDemoParticleEmitter = _particleSystem.addEmitter(); | 3710 | _coolDemoParticleEmitter = _particleSystem.addEmitter(); |
| 3702 | 3711 | ||
| 3703 | if (_coolDemoParticleEmitter != -1) { | 3712 | if (_coolDemoParticleEmitter != -1) { |
| 3713 | |||
| 3704 | _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true); | 3714 | _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true); |
| 3705 | glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f); | 3715 | glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f); |
| 3706 | _particleSystem.setEmitterPosition(_coolDemoParticleEmitter, particleEmitterPosition); | 3716 | |
| 3707 | glm::vec3 velocity(0.0f, 0.1f, 0.0f); | 3717 | _particleSystem.setEmitterPosition (_coolDemoParticleEmitter, particleEmitterPosition); |
| 3708 | float lifespan = 100000.0f; | 3718 | _particleSystem.setEmitterParticleLifespan(_coolDemoParticleEmitter, LIFESPAN_IN_SECONDS); |
| 3709 | _particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, velocity, lifespan); | 3719 | _particleSystem.setEmitterThrust (_coolDemoParticleEmitter, 0.0f); |
| 3720 | _particleSystem.setEmitterRate (_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // to emit a pile o particles now | ||
| 3710 | } | 3721 | } |
| 3711 | 3722 | ||
| 3712 | // signal that the particle system has been initialized | 3723 | // signal that the particle system has been initialized |
| 3713 | _particleSystemInitialized = true; | 3724 | _particleSystemInitialized = true; |
| 3714 | } else { | 3725 | } else { |
| 3715 | // update the particle system | 3726 | // update the particle system |
| 3716 | 3727 | ||
| 3717 | static float t = 0.0f; | 3728 | static bool emitting = true; |
| 3718 | t += deltaTime; | 3729 | static float effectsTimer = 0.0f; |
| 3730 | effectsTimer += deltaTime; | ||
| 3719 | 3731 | ||
| 3720 | if (_coolDemoParticleEmitter != -1) { | 3732 | if (_coolDemoParticleEmitter != -1) { |
| 3721 | 3733 | ||
| 3722 | glm::vec3 tilt = glm::vec3 | 3734 | _particleSystem.setEmitterDirection(_coolDemoParticleEmitter, glm::vec3(0.0f, 1.0f, 0.0f)); |
| 3723 | ( | ||
| 3724 | 30.0f * sinf( t * 0.55f ), | ||
| 3725 | 0.0f, | ||
| 3726 | 30.0f * cosf( t * 0.75f ) | ||
| 3727 | ); | ||
| 3728 | |||
| 3729 | _particleSystem.setEmitterRotation(_coolDemoParticleEmitter, glm::quat(glm::radians(tilt))); | ||
| 3730 | 3735 | ||
| 3731 | ParticleSystem::ParticleAttributes attributes; | 3736 | ParticleSystem::ParticleAttributes attributes; |
| 3732 | 3737 | ||
| 3733 | attributes.radius = 0.01f; | 3738 | attributes.radius = 0.01f; |
| 3734 | attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); | 3739 | attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); |
| 3735 | attributes.gravity = 0.0f + 0.05f * sinf( t * 0.52f ); | 3740 | attributes.gravity = 0.0f + 0.05f * sinf( effectsTimer * 0.52f ); |
| 3736 | attributes.airFriction = 2.5 + 2.0f * sinf( t * 0.32f ); | 3741 | attributes.airFriction = 2.5 + 2.0f * sinf( effectsTimer * 0.32f ); |
| 3737 | attributes.jitter = 0.05f + 0.05f * sinf( t * 0.42f ); | 3742 | attributes.jitter = 0.05f + 0.05f * sinf( effectsTimer * 0.42f ); |
| 3738 | attributes.emitterAttraction = 0.015f + 0.015f * cosf( t * 0.6f ); | 3743 | attributes.emitterAttraction = 0.015f + 0.015f * cosf( effectsTimer * 0.6f ); |
| 3739 | attributes.tornadoForce = 0.0f + 0.03f * sinf( t * 0.7f ); | 3744 | attributes.tornadoForce = 0.0f + 0.03f * sinf( effectsTimer * 0.7f ); |
| 3740 | attributes.neighborAttraction = 0.1f + 0.1f * cosf( t * 0.8f ); | 3745 | attributes.neighborAttraction = 0.1f + 0.1f * cosf( effectsTimer * 0.8f ); |
| 3741 | attributes.neighborRepulsion = 0.2f + 0.2f * sinf( t * 0.4f ); | 3746 | attributes.neighborRepulsion = 0.2f + 0.2f * sinf( effectsTimer * 0.4f ); |
| 3742 | attributes.bounce = 1.0f; | 3747 | attributes.bounce = 1.0f; |
| 3743 | attributes.usingCollisionSphere = true; | 3748 | attributes.usingCollisionSphere = true; |
| 3744 | attributes.collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f ); | 3749 | attributes.collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f ); |
| 3745 | attributes.collisionSphereRadius = 0.5f; | 3750 | attributes.collisionSphereRadius = 0.5f; |
| 3751 | attributes.usingCollisionPlane = true; | ||
| 3752 | attributes.collisionPlanePosition = glm::vec3( 5.0f, 0.0f, 5.0f ); | ||
| 3753 | attributes.collisionPlaneNormal = glm::vec3( 0.0f, 1.0f, 0.0f ); | ||
| 3746 | 3754 | ||
| 3747 | if (attributes.gravity < 0.0f) { | 3755 | if (attributes.gravity < 0.0f) { |
| 3748 | attributes.gravity = 0.0f; | 3756 | attributes.gravity = 0.0f; |
| @@ -3753,6 +3761,15 @@ void Application::updateParticleSystem(float deltaTime) { · 4 unmodified lines | |||
| 3753 | 3761 | ||
| 3754 | _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); | 3762 | _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); |
| 3755 | _particleSystem.simulate(deltaTime); | 3763 | _particleSystem.simulate(deltaTime); |
| 3764 | |||
| 3765 | const float EMIT_RATE_IN_SECONDS = 0.0; | ||
| 3766 | |||
| 3767 | if (_coolDemoParticleEmitter != -1) { | ||
| 3768 | if (emitting) { | ||
| 3769 | _particleSystem.setEmitterRate(_coolDemoParticleEmitter, EMIT_RATE_IN_SECONDS); // stop emitter | ||
| 3770 | emitting = false; | ||
| 3771 | } | ||
| 3772 | } | ||
| 3756 | } | 3773 | } |
| 3757 | } | 3774 | } |
| 3758 | 3775 | ||