Showing the changes to interface/src/Application.cpp (1 of 26 files). Show all
Unified · Split
| @@ -234,6 +234,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 233 unmodified lines | ||
| 234 | 234 | |
| 235 | 235 | NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 236 | 236 | |
| 237 | + NodeList::getInstance()->addHook(&_voxels); | |
| 238 | + NodeList::getInstance()->addHook(this); | |
| 239 | + | |
| 240 | + | |
| 237 | 241 | _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); |
| 238 | 242 | if (!_enableNetworkThread) { |
| 239 | 243 | NodeList::getInstance()->getNodeSocket()->setBlocking(false); |
| @@ -317,6 +321,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 77 unmodified lines | ||
| 317 | 321 | // initialization continues in initializeGL when OpenGL context is ready |
| 318 | 322 | } |
| 319 | 323 | |
| 324 | +Application::~Application() { | |
| 325 | + NodeList::getInstance()->removeHook(&_voxels); | |
| 326 | + NodeList::getInstance()->removeHook(this); | |
| 327 | +} | |
| 328 | + | |
| 320 | 329 | void Application::initializeGL() { |
| 321 | 330 | qDebug( "Created Display Window.\n" ); |
| 322 | 331 | |
| @@ -1290,9 +1299,9 @@ void Application::editPreferences() { · 967 unmodified lines | ||
| 1290 | 1299 | horizontalFieldOfView->setValue(_horizontalFieldOfView); |
| 1291 | 1300 | form->addRow("Horizontal field of view (degrees):", horizontalFieldOfView); |
| 1292 | 1301 | |
| 1293 | − QDoubleSpinBox* headCameraPitchYawScale = new QDoubleSpinBox(); | |
| 1294 | − headCameraPitchYawScale->setValue(_headCameraPitchYawScale); | |
| 1295 | − form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale); | |
| 1302 | + QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox(); | |
| 1303 | + gyroCameraSensitivity->setValue(_gyroCameraSensitivity); | |
| 1304 | + form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity); | |
| 1296 | 1305 | |
| 1297 | 1306 | QDoubleSpinBox* leanScale = new QDoubleSpinBox(); |
| 1298 | 1307 | leanScale->setValue(_myAvatar.getLeanScale()); |
| @@ -1342,7 +1351,7 @@ void Application::editPreferences() { · 43 unmodified lines | ||
| 1342 | 1351 | _myAvatar.getVoxels()->setVoxelURL(url); |
| 1343 | 1352 | sendAvatarVoxelURLMessage(url); |
| 1344 | 1353 | |
| 1345 | − _headCameraPitchYawScale = headCameraPitchYawScale->value(); | |
| 1354 | + _gyroCameraSensitivity = gyroCameraSensitivity->value(); | |
| 1346 | 1355 | _myAvatar.setLeanScale(leanScale->value()); |
| 1347 | 1356 | _audioJitterBufferSamples = audioJitterBufferSamples->value(); |
| 1348 | 1357 | if (!shouldDynamicallySetJitterBuffer()) { |
| @@ -1944,6 +1953,7 @@ void Application::initMenu() { · 595 unmodified lines | ||
| 1944 | 1953 | (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); |
| 1945 | 1954 | optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); |
| 1946 | 1955 | optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true); |
| 1956 | + (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true); | |
| 1947 | 1957 | optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode())); |
| 1948 | 1958 | optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true); |
| 1949 | 1959 | optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G); |
| @@ -2138,6 +2148,10 @@ void Application::toggleMixedSong() { · 188 unmodified lines | ||
| 2138 | 2148 | } |
| 2139 | 2149 | } |
| 2140 | 2150 | |
| 2151 | +void Application::toggleWantCollisionsOn() { | |
| 2152 | + _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked()); | |
| 2153 | +} | |
| 2154 | + | |
| 2141 | 2155 | void Application::resetSongMixMenuItem() { |
| 2142 | 2156 | if (_audio.getSongFileBytes() == 0) { |
| 2143 | 2157 | _rawAudioMicrophoneMix->setText("Mix RAW Song"); |
| @@ -2288,6 +2302,56 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which · 144 unmodified lines | ||
| 2288 | 2302 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); |
| 2289 | 2303 | } |
| 2290 | 2304 | |
| 2305 | +void Application::renderFollowIndicator() { | |
| 2306 | + NodeList* nodeList = NodeList::getInstance(); | |
| 2307 | + | |
| 2308 | + glLineWidth(5); | |
| 2309 | + glBegin(GL_LINES); | |
| 2310 | + for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) { | |
| 2311 | + if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | |
| 2312 | + Avatar* avatar = (Avatar *) node->getLinkedData(); | |
| 2313 | + Avatar* leader = NULL; | |
| 2314 | + | |
| 2315 | + if (avatar->getLeaderID() != UNKNOWN_NODE_ID) { | |
| 2316 | + if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) { | |
| 2317 | + leader = &_myAvatar; | |
| 2318 | + } else { | |
| 2319 | + for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | |
| 2320 | + if(it->getNodeID() == avatar->getLeaderID() | |
| 2321 | + && it->getType() == NODE_TYPE_AGENT) { | |
| 2322 | + leader = (Avatar*) it->getLinkedData(); | |
| 2323 | + } | |
| 2324 | + } | |
| 2325 | + } | |
| 2326 | + | |
| 2327 | + if (leader != NULL) { | |
| 2328 | + glColor3f(1.f, 0.f, 0.f); | |
| 2329 | + glVertex3f(avatar->getPosition().x, | |
| 2330 | + avatar->getPosition().y, | |
| 2331 | + avatar->getPosition().z); | |
| 2332 | + glColor3f(0.f, 1.f, 0.f); | |
| 2333 | + glVertex3f(leader->getPosition().x, | |
| 2334 | + leader->getPosition().y, | |
| 2335 | + leader->getPosition().z); | |
| 2336 | + } | |
| 2337 | + } | |
| 2338 | + } | |
| 2339 | + } | |
| 2340 | + | |
| 2341 | + if (_myAvatar.getLeadingAvatar() != NULL) { | |
| 2342 | + glColor3f(1.f, 0.f, 0.f); | |
| 2343 | + glVertex3f(_myAvatar.getPosition().x, | |
| 2344 | + _myAvatar.getPosition().y, | |
| 2345 | + _myAvatar.getPosition().z); | |
| 2346 | + glColor3f(0.f, 1.f, 0.f); | |
| 2347 | + glVertex3f(_myAvatar.getLeadingAvatar()->getPosition().x, | |
| 2348 | + _myAvatar.getLeadingAvatar()->getPosition().y, | |
| 2349 | + _myAvatar.getLeadingAvatar()->getPosition().z); | |
| 2350 | + } | |
| 2351 | + | |
| 2352 | + glEnd(); | |
| 2353 | +} | |
| 2354 | + | |
| 2291 | 2355 | void Application::update(float deltaTime) { |
| 2292 | 2356 | |
| 2293 | 2357 | // Use Transmitter Hand to move hand if connected, else use mouse |
| @@ -2501,7 +2565,7 @@ void Application::update(float deltaTime) { · 207 unmodified lines | ||
| 2501 | 2565 | if (!avatar->isInitialized()) { |
| 2502 | 2566 | avatar->init(); |
| 2503 | 2567 | } |
| 2504 | − avatar->simulate(deltaTime, NULL); | |
| 2568 | + avatar->simulate(deltaTime, NULL, 0.f); | |
| 2505 | 2569 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); |
| 2506 | 2570 | } |
| 2507 | 2571 | node->unlock(); |
| @@ -2516,9 +2580,9 @@ void Application::update(float deltaTime) { · 8 unmodified lines | ||
| 2516 | 2580 | } |
| 2517 | 2581 | |
| 2518 | 2582 | if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { |
| 2519 | − _myAvatar.simulate(deltaTime, &_myTransmitter); | |
| 2583 | + _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity); | |
| 2520 | 2584 | } else { |
| 2521 | − _myAvatar.simulate(deltaTime, NULL); | |
| 2585 | + _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity); | |
| 2522 | 2586 | } |
| 2523 | 2587 | |
| 2524 | 2588 | if (!OculusManager::isConnected()) { |
| @@ -2585,10 +2649,6 @@ void Application::updateAvatar(float deltaTime) { · 60 unmodified lines | ||
| 2585 | 2649 | |
| 2586 | 2650 | // Update my avatar's state from gyros and/or webcam |
| 2587 | 2651 | _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), |
| 2588 | − glm::vec3(_headCameraPitchYawScale, | |
| 2589 | − _headCameraPitchYawScale, | |
| 2590 | − _headCameraPitchYawScale), | |
| 2591 | − 0.f, | |
| 2592 | 2652 | _pitchFromTouch); |
| 2593 | 2653 | |
| 2594 | 2654 | if (_serialHeadSensor.isActive()) { |
| @@ -3014,6 +3074,8 @@ void Application::displaySide(Camera& whichCamera) { · 419 unmodified lines | ||
| 3014 | 3074 | glEnable(GL_LIGHTING); |
| 3015 | 3075 | } |
| 3016 | 3076 | |
| 3077 | + _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS); | |
| 3078 | + | |
| 3017 | 3079 | if (_renderAvatarsOn->isChecked()) { |
| 3018 | 3080 | // Render avatars of other nodes |
| 3019 | 3081 | NodeList* nodeList = NodeList::getInstance(); |
| @@ -3059,6 +3121,20 @@ void Application::displaySide(Camera& whichCamera) { · 39 unmodified lines | ||
| 3059 | 3121 | |
| 3060 | 3122 | // brad's frustum for debugging |
| 3061 | 3123 | if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); |
| 3124 | + | |
| 3125 | + // render voxel fades if they exist | |
| 3126 | + if (_voxelFades.size() > 0) { | |
| 3127 | + for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) { | |
| 3128 | + fade->render(); | |
| 3129 | + if(fade->isDone()) { | |
| 3130 | + fade = _voxelFades.erase(fade); | |
| 3131 | + } else { | |
| 3132 | + ++fade; | |
| 3133 | + } | |
| 3134 | + } | |
| 3135 | + } | |
| 3136 | + | |
| 3137 | + renderFollowIndicator(); | |
| 3062 | 3138 | } |
| 3063 | 3139 | |
| 3064 | 3140 | void Application::displayOverlay() { |
| @@ -3626,6 +3702,62 @@ void Application::shiftPaintingColor() { · 561 unmodified lines | ||
| 3626 | 3702 | } |
| 3627 | 3703 | |
| 3628 | 3704 | |
| 3705 | +void Application::injectVoxelAddedSoundEffect() { | |
| 3706 | + AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); | |
| 3707 | + | |
| 3708 | + if (voxelInjector) { | |
| 3709 | + voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3710 | + //voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw()); | |
| 3711 | + voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value | |
| 3712 | + | |
| 3713 | + /* for (int i = 0; i | |
| 3714 | + < 22050; i++) { | |
| 3715 | + if (i % 4 == 0) { | |
| 3716 | + voxelInjector->addSample(4000); | |
| 3717 | + } else if (i % 4 == 1) { | |
| 3718 | + voxelInjector->addSample(0); | |
| 3719 | + } else if (i % 4 == 2) { | |
| 3720 | + voxelInjector->addSample(-4000); | |
| 3721 | + } else { | |
| 3722 | + voxelInjector->addSample(0); | |
| 3723 | + } | |
| 3724 | + */ | |
| 3725 | + | |
| 3726 | + const float BIG_VOXEL_MIN_SIZE = .01f; | |
| 3727 | + | |
| 3728 | + for (int i = 0; i < 11025; i++) { | |
| 3729 | + | |
| 3730 | + /* | |
| 3731 | + A440 square wave | |
| 3732 | + if (sin(i * 2 * PIE / 50)>=0) { | |
| 3733 | + voxelInjector->addSample(4000); | |
| 3734 | + } else { | |
| 3735 | + voxelInjector->addSample(-4000); | |
| 3736 | + } | |
| 3737 | + */ | |
| 3738 | + | |
| 3739 | + if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) { | |
| 3740 | + voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200)))); | |
| 3741 | + } else { | |
| 3742 | + voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808 | |
| 3743 | + } | |
| 3744 | + } | |
| 3745 | + | |
| 3746 | + //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80 | |
| 3747 | + //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808 | |
| 3748 | + //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808 | |
| 3749 | + //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave | |
| 3750 | + //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation | |
| 3751 | + | |
| 3752 | + //FM library | |
| 3753 | + //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep | |
| 3754 | + //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep | |
| 3755 | + //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse | |
| 3756 | + | |
| 3757 | + AudioInjectionManager::threadInjector(voxelInjector); | |
| 3758 | + } | |
| 3759 | +} | |
| 3760 | + | |
| 3629 | 3761 | bool Application::maybeEditVoxelUnderCursor() { |
| 3630 | 3762 | if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) { |
| 3631 | 3763 | if (_mouseVoxel.s != 0) { |
| @@ -3636,65 +3768,35 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines | ||
| 3636 | 3768 | // create the voxel locally so it appears immediately |
| 3637 | 3769 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, |
| 3638 | 3770 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked()); |
| 3771 | + | |
| 3772 | + // Implement voxel fade effect | |
| 3773 | + VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | |
| 3774 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 3775 | + float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST; | |
| 3776 | + fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger; | |
| 3777 | + fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger; | |
| 3778 | + fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger; | |
| 3779 | + fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | |
| 3780 | + _voxelFades.push_back(fade); | |
| 3781 | + | |
| 3782 | + // inject a sound effect | |
| 3783 | + injectVoxelAddedSoundEffect(); | |
| 3639 | 3784 | |
| 3640 | 3785 | // remember the position for drag detection |
| 3641 | 3786 | _justEditedVoxel = true; |
| 3642 | 3787 | |
| 3643 | − AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); | |
| 3644 | − voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3645 | − //_myAvatar.getPosition() | |
| 3646 | −// voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw()); | |
| 3647 | − voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value | |
| 3648 | − | |
| 3649 | − /* for (int i = 0; i | |
| 3650 | − < 22050; i++) { | |
| 3651 | − if (i % 4 == 0) { | |
| 3652 | − voxelInjector->addSample(4000); | |
| 3653 | − } else if (i % 4 == 1) { | |
| 3654 | − voxelInjector->addSample(0); | |
| 3655 | − } else if (i % 4 == 2) { | |
| 3656 | − voxelInjector->addSample(-4000); | |
| 3657 | − } else { | |
| 3658 | − voxelInjector->addSample(0); | |
| 3659 | − } | |
| 3660 | − */ | |
| 3661 | − | |
| 3662 | − | |
| 3663 | − const float BIG_VOXEL_MIN_SIZE = .01f; | |
| 3664 | − | |
| 3665 | − for (int i = 0; i < 11025; i++) { | |
| 3666 | − | |
| 3667 | − /* | |
| 3668 | − A440 square wave | |
| 3669 | − if (sin(i * 2 * PIE / 50)>=0) { | |
| 3670 | − voxelInjector->addSample(4000); | |
| 3671 | − } else { | |
| 3672 | − voxelInjector->addSample(-4000); | |
| 3673 | − } | |
| 3674 | − */ | |
| 3675 | − | |
| 3676 | − if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) { | |
| 3677 | − voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200)))); | |
| 3678 | − } else { | |
| 3679 | − voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808 | |
| 3680 | − } | |
| 3681 | − } | |
| 3682 | − | |
| 3683 | − //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80 | |
| 3684 | − //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808 | |
| 3685 | − //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808 | |
| 3686 | − //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave | |
| 3687 | − //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation | |
| 3688 | − | |
| 3689 | − //FM library | |
| 3690 | − //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep | |
| 3691 | − //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep | |
| 3692 | − //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse | |
| 3693 | − | |
| 3694 | − AudioInjectionManager::threadInjector(voxelInjector); | |
| 3695 | 3788 | } |
| 3696 | 3789 | } else if (_deleteVoxelMode->isChecked()) { |
| 3697 | 3790 | deleteVoxelUnderCursor(); |
| 3791 | + VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | |
| 3792 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 3793 | + float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST; | |
| 3794 | + fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger; | |
| 3795 | + fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger; | |
| 3796 | + fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger; | |
| 3797 | + fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | |
| 3798 | + _voxelFades.push_back(fade); | |
| 3799 | + | |
| 3698 | 3800 | } else if (_eyedropperMode->isChecked()) { |
| 3699 | 3801 | eyedropperVoxelUnderCursor(); |
| 3700 | 3802 | } else { |
| @@ -3709,17 +3811,20 @@ void Application::deleteVoxelUnderCursor() { · 8 unmodified lines | ||
| 3709 | 3811 | // sending delete to the server is sufficient, server will send new version so we see updates soon enough |
| 3710 | 3812 | sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel); |
| 3711 | 3813 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000); |
| 3712 | − voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3713 | −// voxelInjector->setBearing(0); //straight down the z axis | |
| 3714 | − voxelInjector->setVolume (255); //255 is max, and also default value | |
| 3715 | − | |
| 3716 | 3814 | |
| 3717 | − for (int i = 0; i < 5000; i++) { | |
| 3718 | − voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse | |
| 3719 | − //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter | |
| 3815 | + if (voxelInjector) { | |
| 3816 | + voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3817 | + //voxelInjector->setBearing(0); //straight down the z axis | |
| 3818 | + voxelInjector->setVolume (255); //255 is max, and also default value | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + for (int i = 0; i < 5000; i++) { | |
| 3822 | + voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse | |
| 3823 | + //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter | |
| 3824 | + } | |
| 3825 | + | |
| 3826 | + AudioInjectionManager::threadInjector(voxelInjector); | |
| 3720 | 3827 | } |
| 3721 | − | |
| 3722 | − AudioInjectionManager::threadInjector(voxelInjector); | |
| 3723 | 3828 | } |
| 3724 | 3829 | // remember the position for drag detection |
| 3725 | 3830 | _justEditedVoxel = true; |
| @@ -3816,6 +3921,57 @@ void Application::attachNewHeadToNode(Node* newNode) { · 90 unmodified lines | ||
| 3816 | 3921 | } |
| 3817 | 3922 | } |
| 3818 | 3923 | |
| 3924 | +void Application::nodeAdded(Node* node) { | |
| 3925 | +} | |
| 3926 | + | |
| 3927 | +void Application::nodeKilled(Node* node) { | |
| 3928 | + if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 3929 | + uint16_t nodeID = node->getNodeID(); | |
| 3930 | + // see if this is the first we've heard of this node... | |
| 3931 | + if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { | |
| 3932 | + VoxelPositionSize jurisditionDetails; | |
| 3933 | + jurisditionDetails = _voxelServerJurisdictions[nodeID]; | |
| 3934 | + | |
| 3935 | + printf("voxel server going away...... v[%f, %f, %f, %f]\n", | |
| 3936 | + jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | |
| 3937 | + | |
| 3938 | + // Add the jurisditionDetails object to the list of "fade outs" | |
| 3939 | + VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | |
| 3940 | + fade.voxelDetails = jurisditionDetails; | |
| 3941 | + _voxelFades.push_back(fade); | |
| 3942 | + } | |
| 3943 | + } | |
| 3944 | +} | |
| 3945 | + | |
| 3946 | +int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress) { | |
| 3947 | + | |
| 3948 | + // parse the incoming stats data, and stick it into our averaging stats object for now... even though this | |
| 3949 | + // means mixing in stats from potentially multiple servers. | |
| 3950 | + int statsMessageLength = _voxelSceneStats.unpackFromMessage(messageData, messageLength); | |
| 3951 | + | |
| 3952 | + // But, also identify the sender, and keep track of the contained jurisdiction root for this server | |
| 3953 | + Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); | |
| 3954 | + uint16_t nodeID = voxelServer->getNodeID(); | |
| 3955 | + | |
| 3956 | + VoxelPositionSize jurisditionDetails; | |
| 3957 | + voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails); | |
| 3958 | + | |
| 3959 | + // see if this is the first we've heard of this node... | |
| 3960 | + if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { | |
| 3961 | + printf("stats from new voxel server... v[%f, %f, %f, %f]\n", | |
| 3962 | + jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | |
| 3963 | + | |
| 3964 | + // Add the jurisditionDetails object to the list of "fade outs" | |
| 3965 | + VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); | |
| 3966 | + fade.voxelDetails = jurisditionDetails; | |
| 3967 | + _voxelFades.push_back(fade); | |
| 3968 | + } | |
| 3969 | + // store jurisdiction details for later use | |
| 3970 | + _voxelServerJurisdictions[nodeID] = jurisditionDetails; | |
| 3971 | + | |
| 3972 | + return statsMessageLength; | |
| 3973 | +} | |
| 3974 | + | |
| 3819 | 3975 | // Receive packets from other nodes/servers and decide what to do with them! |
| 3820 | 3976 | void* Application::networkReceive(void* args) { |
| 3821 | 3977 | sockaddr senderAddress; |
| @@ -3859,7 +4015,8 @@ void* Application::networkReceive(void* args) { · 37 unmodified lines | ||
| 3859 | 4015 | // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first |
| 3860 | 4016 | // then process any remaining bytes as if it was another packet |
| 3861 | 4017 | if (messageData[0] == PACKET_TYPE_VOXEL_STATS) { |
| 3862 | − int statsMessageLength = app->_voxelSceneStats.unpackFromMessage(messageData, messageLength); | |
| 4018 | + | |
| 4019 | + int statsMessageLength = app->parseVoxelStats(messageData, messageLength, senderAddress); | |
| 3863 | 4020 | if (messageLength > statsMessageLength) { |
| 3864 | 4021 | messageData += statsMessageLength; |
| 3865 | 4022 | messageLength -= statsMessageLength; |
| @@ -3953,11 +4110,11 @@ void Application::saveAction(QSettings* set, QAction* action) { · 87 unmodified lines | ||
| 3953 | 4110 | } |
| 3954 | 4111 | |
| 3955 | 4112 | void Application::loadSettings(QSettings* settings) { |
| 3956 | − if (!settings) { | |
| 4113 | + if (!settings) { | |
| 3957 | 4114 | settings = getSettings(); |
| 3958 | 4115 | } |
| 3959 | 4116 | |
| 3960 | − _headCameraPitchYawScale = loadSetting(settings, "headCameraPitchYawScale", 0.0f); | |
| 4117 | + _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f); | |
| 3961 | 4118 | _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); |
| 3962 | 4119 | _horizontalFieldOfView = loadSetting(settings, "horizontalFieldOfView", HORIZONTAL_FIELD_OF_VIEW_DEGREES); |
| 3963 | 4120 | |
| @@ -3981,7 +4138,7 @@ void Application::saveSettings(QSettings* settings) { · 17 unmodified lines | ||
| 3981 | 4138 | settings = getSettings(); |
| 3982 | 4139 | } |
| 3983 | 4140 | |
| 3984 | − settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale); | |
| 4141 | + settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity); | |
| 3985 | 4142 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); |
| 3986 | 4143 | settings->setValue("horizontalFieldOfView", _horizontalFieldOfView); |
| 3987 | 4144 | settings->beginGroup("View Frustum Offset Camera"); |