History

Merge remote-tracking branch 'upstream/master' into particles

Jeffrey Ventrella committed 13 years ago

Commit b007ab12 parents 253154c cdfabd736 files · +1394 −482Browse files

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

Unified · Split

interface/src/Application.cpp+265−98
@@ -77,8 +77,10 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; · 76 unmodified lines
7777
7878 static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
7979
80−const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world
81− // (will be overwritten if avatar data file is found)
80+// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found)
81+// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by
82+// Grayson as he's building a street around here for demo dinner 2
83+const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE);
8284
8385 const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
8486 // in the idle loop? (60 FPS is default)
@@ -234,6 +236,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 149 unmodified lines
234236
235237 NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
236238
239+ NodeList::getInstance()->addHook(&_voxels);
240+ NodeList::getInstance()->addHook(this);
241+
242+
237243 _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking");
238244 if (!_enableNetworkThread) {
239245 NodeList::getInstance()->getNodeSocket()->setBlocking(false);
@@ -317,6 +323,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 77 unmodified lines
317323 // initialization continues in initializeGL when OpenGL context is ready
318324 }
319325
326+Application::~Application() {
327+ NodeList::getInstance()->removeHook(&_voxels);
328+ NodeList::getInstance()->removeHook(this);
329+}
330+
320331 void Application::initializeGL() {
321332 qDebug( "Created Display Window.\n" );
322333
@@ -1290,9 +1301,9 @@ void Application::editPreferences() { · 967 unmodified lines
12901301 horizontalFieldOfView->setValue(_horizontalFieldOfView);
12911302 form->addRow("Horizontal field of view (degrees):", horizontalFieldOfView);
12921303
1293− QDoubleSpinBox* headCameraPitchYawScale = new QDoubleSpinBox();
1294− headCameraPitchYawScale->setValue(_headCameraPitchYawScale);
1295− form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale);
1304+ QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox();
1305+ gyroCameraSensitivity->setValue(_gyroCameraSensitivity);
1306+ form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity);
12961307
12971308 QDoubleSpinBox* leanScale = new QDoubleSpinBox();
12981309 leanScale->setValue(_myAvatar.getLeanScale());
@@ -1342,7 +1353,7 @@ void Application::editPreferences() { · 43 unmodified lines
13421353 _myAvatar.getVoxels()->setVoxelURL(url);
13431354 sendAvatarVoxelURLMessage(url);
13441355
1345− _headCameraPitchYawScale = headCameraPitchYawScale->value();
1356+ _gyroCameraSensitivity = gyroCameraSensitivity->value();
13461357 _myAvatar.setLeanScale(leanScale->value());
13471358 _audioJitterBufferSamples = audioJitterBufferSamples->value();
13481359 if (!shouldDynamicallySetJitterBuffer()) {
@@ -1943,8 +1954,11 @@ void Application::initMenu() { · 594 unmodified lines
19431954 _testPing->setChecked(true);
19441955 (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true);
19451956 optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);
1946− optionsMenu->addAction("Toggle Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
1957+ optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
1958+ (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true);
1959+ _wantCollisionsOn->setChecked(true);
19471960 optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));
1961+ optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true);
19481962 optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G);
19491963
19501964 QMenu* audioMenu = menuBar->addMenu("Audio");
@@ -2137,6 +2151,10 @@ void Application::toggleMixedSong() { · 186 unmodified lines
21372151 }
21382152 }
21392153
2154+void Application::toggleWantCollisionsOn() {
2155+ _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked());
2156+}
2157+
21402158 void Application::resetSongMixMenuItem() {
21412159 if (_audio.getSongFileBytes() == 0) {
21422160 _rawAudioMicrophoneMix->setText("Mix RAW Song");
@@ -2287,6 +2305,56 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which · 144 unmodified lines
22872305 renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
22882306 }
22892307
2308+void Application::renderFollowIndicator() {
2309+ NodeList* nodeList = NodeList::getInstance();
2310+
2311+ glLineWidth(5);
2312+ glBegin(GL_LINES);
2313+ for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
2314+ if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
2315+ Avatar* avatar = (Avatar *) node->getLinkedData();
2316+ Avatar* leader = NULL;
2317+
2318+ if (avatar->getLeaderID() != UNKNOWN_NODE_ID) {
2319+ if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) {
2320+ leader = &_myAvatar;
2321+ } else {
2322+ for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) {
2323+ if(it->getNodeID() == avatar->getLeaderID()
2324+ && it->getType() == NODE_TYPE_AGENT) {
2325+ leader = (Avatar*) it->getLinkedData();
2326+ }
2327+ }
2328+ }
2329+
2330+ if (leader != NULL) {
2331+ glColor3f(1.f, 0.f, 0.f);
2332+ glVertex3f(avatar->getPosition().x,
2333+ avatar->getPosition().y,
2334+ avatar->getPosition().z);
2335+ glColor3f(0.f, 1.f, 0.f);
2336+ glVertex3f(leader->getPosition().x,
2337+ leader->getPosition().y,
2338+ leader->getPosition().z);
2339+ }
2340+ }
2341+ }
2342+ }
2343+
2344+ if (_myAvatar.getLeadingAvatar() != NULL) {
2345+ glColor3f(1.f, 0.f, 0.f);
2346+ glVertex3f(_myAvatar.getPosition().x,
2347+ _myAvatar.getPosition().y,
2348+ _myAvatar.getPosition().z);
2349+ glColor3f(0.f, 1.f, 0.f);
2350+ glVertex3f(_myAvatar.getLeadingAvatar()->getPosition().x,
2351+ _myAvatar.getLeadingAvatar()->getPosition().y,
2352+ _myAvatar.getLeadingAvatar()->getPosition().z);
2353+ }
2354+
2355+ glEnd();
2356+}
2357+
22902358 void Application::update(float deltaTime) {
22912359
22922360 // Use Transmitter Hand to move hand if connected, else use mouse
@@ -2500,7 +2568,7 @@ void Application::update(float deltaTime) { · 207 unmodified lines
25002568 if (!avatar->isInitialized()) {
25012569 avatar->init();
25022570 }
2503− avatar->simulate(deltaTime, NULL);
2571+ avatar->simulate(deltaTime, NULL, 0.f);
25042572 avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
25052573 }
25062574 node->unlock();
@@ -2515,13 +2583,11 @@ void Application::update(float deltaTime) { · 8 unmodified lines
25152583 }
25162584
25172585 if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) {
2518− _myAvatar.simulate(deltaTime, &_myTransmitter);
2586+ _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity);
25192587 } else {
2520− _myAvatar.simulate(deltaTime, NULL);
2588+ _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity);
25212589 }
25222590
2523− _myAvatar.getHand().simulate(deltaTime, true);
2524−
25252591 if (!OculusManager::isConnected()) {
25262592 if (_lookingInMirror->isChecked()) {
25272593 if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
@@ -2586,10 +2652,6 @@ void Application::updateAvatar(float deltaTime) { · 58 unmodified lines
25862652
25872653 // Update my avatar's state from gyros and/or webcam
25882654 _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
2589− glm::vec3(_headCameraPitchYawScale,
2590− _headCameraPitchYawScale,
2591− _headCameraPitchYawScale),
2592− 0.f,
25932655 _pitchFromTouch);
25942656
25952657 if (_serialHeadSensor.isActive()) {
@@ -2876,6 +2938,27 @@ void Application::displayOculus(Camera& whichCamera) { · 280 unmodified lines
28762938 glPopMatrix();
28772939 }
28782940
2941+void Application::setupWorldLight(Camera& whichCamera) {
2942+
2943+ // Setup 3D lights (after the camera transform, so that they are positioned in world space)
2944+ glEnable(GL_COLOR_MATERIAL);
2945+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
2946+
2947+ glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
2948+ whichCamera.getPosition());
2949+ GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
2950+ glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
2951+ GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
2952+ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
2953+ GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
2954+ glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
2955+ GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
2956+ glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
2957+
2958+ glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
2959+ glMateriali(GL_FRONT, GL_SHININESS, 96);
2960+}
2961+
28792962 void Application::displaySide(Camera& whichCamera) {
28802963 // transform by eye offset
28812964
@@ -2905,22 +2988,7 @@ void Application::displaySide(Camera& whichCamera) { · 23 unmodified lines
29052988 glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
29062989
29072990 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
2908− glEnable(GL_COLOR_MATERIAL);
2909− glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
2910−
2911− glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
2912− whichCamera.getPosition());
2913− GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
2914− glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
2915− GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
2916− glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
2917− GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
2918− glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
2919− GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
2920− glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
2921−
2922− glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
2923− glMateriali(GL_FRONT, GL_SHININESS, 96);
2991+ setupWorldLight(whichCamera);
29242992
29252993 if (_renderStarsOn->isChecked()) {
29262994 if (!_stars.getFileLoaded()) {
@@ -2986,7 +3054,7 @@ void Application::displaySide(Camera& whichCamera) { · 59 unmodified lines
29863054 glDisable(GL_FOG);
29873055 glDisable(GL_NORMALIZE);
29883056
2989− renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
3057+ //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
29903058 }
29913059 // Draw voxels
29923060 if (_renderVoxels->isChecked()) {
@@ -3015,6 +3083,8 @@ void Application::displaySide(Camera& whichCamera) { · 22 unmodified lines
30153083 glEnable(GL_LIGHTING);
30163084 }
30173085
3086+ _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
3087+
30183088 if (_renderAvatarsOn->isChecked()) {
30193089 // Render avatars of other nodes
30203090 NodeList* nodeList = NodeList::getInstance();
@@ -3049,6 +3119,8 @@ void Application::displaySide(Camera& whichCamera) { · 28 unmodified lines
30493119 }
30503120 }
30513121
3122+ _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera);
3123+
30523124 if (_renderParticleSystemOn->isChecked()) {
30533125 if (_particleSystemInitialized) {
30543126 _particleSystem.render();
@@ -3060,6 +3132,20 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines
30603132
30613133 // brad's frustum for debugging
30623134 if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum);
3135+
3136+ // render voxel fades if they exist
3137+ if (_voxelFades.size() > 0) {
3138+ for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) {
3139+ fade->render();
3140+ if(fade->isDone()) {
3141+ fade = _voxelFades.erase(fade);
3142+ } else {
3143+ ++fade;
3144+ }
3145+ }
3146+ }
3147+
3148+ renderFollowIndicator();
30633149 }
30643150
30653151 void Application::displayOverlay() {
@@ -3627,6 +3713,62 @@ void Application::shiftPaintingColor() { · 561 unmodified lines
36273713 }
36283714
36293715
3716+void Application::injectVoxelAddedSoundEffect() {
3717+ AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025);
3718+
3719+ if (voxelInjector) {
3720+ voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
3721+ //voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw());
3722+ voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value
3723+
3724+ /* for (int i = 0; i
3725+ < 22050; i++) {
3726+ if (i % 4 == 0) {
3727+ voxelInjector->addSample(4000);
3728+ } else if (i % 4 == 1) {
3729+ voxelInjector->addSample(0);
3730+ } else if (i % 4 == 2) {
3731+ voxelInjector->addSample(-4000);
3732+ } else {
3733+ voxelInjector->addSample(0);
3734+ }
3735+ */
3736+
3737+ const float BIG_VOXEL_MIN_SIZE = .01f;
3738+
3739+ for (int i = 0; i < 11025; i++) {
3740+
3741+ /*
3742+ A440 square wave
3743+ if (sin(i * 2 * PIE / 50)>=0) {
3744+ voxelInjector->addSample(4000);
3745+ } else {
3746+ voxelInjector->addSample(-4000);
3747+ }
3748+ */
3749+
3750+ if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) {
3751+ voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200))));
3752+ } else {
3753+ voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808
3754+ }
3755+ }
3756+
3757+ //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80
3758+ //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808
3759+ //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808
3760+ //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave
3761+ //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation
3762+
3763+ //FM library
3764+ //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep
3765+ //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep
3766+ //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse
3767+
3768+ AudioInjectionManager::threadInjector(voxelInjector);
3769+ }
3770+}
3771+
36303772 bool Application::maybeEditVoxelUnderCursor() {
36313773 if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
36323774 if (_mouseVoxel.s != 0) {
@@ -3637,65 +3779,35 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines
36373779 // create the voxel locally so it appears immediately
36383780 _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s,
36393781 _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked());
3782+
3783+ // Implement voxel fade effect
3784+ VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
3785+ const float VOXEL_BOUNDS_ADJUST = 0.01f;
3786+ float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST;
3787+ fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger;
3788+ fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger;
3789+ fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger;
3790+ fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger;
3791+ _voxelFades.push_back(fade);
3792+
3793+ // inject a sound effect
3794+ injectVoxelAddedSoundEffect();
36403795
36413796 // remember the position for drag detection
36423797 _justEditedVoxel = true;
36433798
3644− AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025);
3645− voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
3646− //_myAvatar.getPosition()
3647−// voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw());
3648− voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value
3649−
3650− /* for (int i = 0; i
3651− < 22050; i++) {
3652− if (i % 4 == 0) {
3653− voxelInjector->addSample(4000);
3654− } else if (i % 4 == 1) {
3655− voxelInjector->addSample(0);
3656− } else if (i % 4 == 2) {
3657− voxelInjector->addSample(-4000);
3658− } else {
3659− voxelInjector->addSample(0);
3660− }
3661− */
3662−
3663−
3664− const float BIG_VOXEL_MIN_SIZE = .01f;
3665−
3666− for (int i = 0; i < 11025; i++) {
3667−
3668− /*
3669− A440 square wave
3670− if (sin(i * 2 * PIE / 50)>=0) {
3671− voxelInjector->addSample(4000);
3672− } else {
3673− voxelInjector->addSample(-4000);
3674− }
3675− */
3676−
3677− if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) {
3678− voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200))));
3679− } else {
3680− voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808
3681− }
3682− }
3683−
3684− //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80
3685− //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808
3686− //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808
3687− //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave
3688− //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation
3689−
3690− //FM library
3691− //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep
3692− //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep
3693− //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse
3694−
3695− AudioInjectionManager::threadInjector(voxelInjector);
36963799 }
36973800 } else if (_deleteVoxelMode->isChecked()) {
36983801 deleteVoxelUnderCursor();
3802+ VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
3803+ const float VOXEL_BOUNDS_ADJUST = 0.01f;
3804+ float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST;
3805+ fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger;
3806+ fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger;
3807+ fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger;
3808+ fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger;
3809+ _voxelFades.push_back(fade);
3810+
36993811 } else if (_eyedropperMode->isChecked()) {
37003812 eyedropperVoxelUnderCursor();
37013813 } else {
@@ -3710,17 +3822,20 @@ void Application::deleteVoxelUnderCursor() { · 8 unmodified lines
37103822 // sending delete to the server is sufficient, server will send new version so we see updates soon enough
37113823 sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel);
37123824 AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000);
3713− voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
3714−// voxelInjector->setBearing(0); //straight down the z axis
3715− voxelInjector->setVolume (255); //255 is max, and also default value
3716−
37173825
3718− for (int i = 0; i < 5000; i++) {
3719− voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse
3720− //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter
3826+ if (voxelInjector) {
3827+ voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
3828+ //voxelInjector->setBearing(0); //straight down the z axis
3829+ voxelInjector->setVolume (255); //255 is max, and also default value
3830+
3831+
3832+ for (int i = 0; i < 5000; i++) {
3833+ voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse
3834+ //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter
3835+ }
3836+
3837+ AudioInjectionManager::threadInjector(voxelInjector);
37213838 }
3722−
3723− AudioInjectionManager::threadInjector(voxelInjector);
37243839 }
37253840 // remember the position for drag detection
37263841 _justEditedVoxel = true;
@@ -3817,6 +3932,57 @@ void Application::attachNewHeadToNode(Node* newNode) { · 90 unmodified lines
38173932 }
38183933 }
38193934
3935+void Application::nodeAdded(Node* node) {
3936+}
3937+
3938+void Application::nodeKilled(Node* node) {
3939+ if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
3940+ uint16_t nodeID = node->getNodeID();
3941+ // see if this is the first we've heard of this node...
3942+ if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) {
3943+ VoxelPositionSize jurisditionDetails;
3944+ jurisditionDetails = _voxelServerJurisdictions[nodeID];
3945+
3946+ printf("voxel server going away...... v[%f, %f, %f, %f]\n",
3947+ jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
3948+
3949+ // Add the jurisditionDetails object to the list of "fade outs"
3950+ VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
3951+ fade.voxelDetails = jurisditionDetails;
3952+ _voxelFades.push_back(fade);
3953+ }
3954+ }
3955+}
3956+
3957+int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress) {
3958+
3959+ // parse the incoming stats data, and stick it into our averaging stats object for now... even though this
3960+ // means mixing in stats from potentially multiple servers.
3961+ int statsMessageLength = _voxelSceneStats.unpackFromMessage(messageData, messageLength);
3962+
3963+ // But, also identify the sender, and keep track of the contained jurisdiction root for this server
3964+ Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
3965+ uint16_t nodeID = voxelServer->getNodeID();
3966+
3967+ VoxelPositionSize jurisditionDetails;
3968+ voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails);
3969+
3970+ // see if this is the first we've heard of this node...
3971+ if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) {
3972+ printf("stats from new voxel server... v[%f, %f, %f, %f]\n",
3973+ jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
3974+
3975+ // Add the jurisditionDetails object to the list of "fade outs"
3976+ VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
3977+ fade.voxelDetails = jurisditionDetails;
3978+ _voxelFades.push_back(fade);
3979+ }
3980+ // store jurisdiction details for later use
3981+ _voxelServerJurisdictions[nodeID] = jurisditionDetails;
3982+
3983+ return statsMessageLength;
3984+}
3985+
38203986 // Receive packets from other nodes/servers and decide what to do with them!
38213987 void* Application::networkReceive(void* args) {
38223988 sockaddr senderAddress;
@@ -3860,7 +4026,8 @@ void* Application::networkReceive(void* args) { · 37 unmodified lines
38604026 // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first
38614027 // then process any remaining bytes as if it was another packet
38624028 if (messageData[0] == PACKET_TYPE_VOXEL_STATS) {
3863− int statsMessageLength = app->_voxelSceneStats.unpackFromMessage(messageData, messageLength);
4029+
4030+ int statsMessageLength = app->parseVoxelStats(messageData, messageLength, senderAddress);
38644031 if (messageLength > statsMessageLength) {
38654032 messageData += statsMessageLength;
38664033 messageLength -= statsMessageLength;
@@ -3954,11 +4121,11 @@ void Application::saveAction(QSettings* set, QAction* action) { · 87 unmodified lines
39544121 }
39554122
39564123 void Application::loadSettings(QSettings* settings) {
3957− if (!settings) {
4124+ if (!settings) {
39584125 settings = getSettings();
39594126 }
39604127
3961− _headCameraPitchYawScale = loadSetting(settings, "headCameraPitchYawScale", 0.0f);
4128+ _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f);
39624129 _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
39634130 _horizontalFieldOfView = loadSetting(settings, "horizontalFieldOfView", HORIZONTAL_FIELD_OF_VIEW_DEGREES);
39644131
@@ -3982,7 +4149,7 @@ void Application::saveSettings(QSettings* settings) { · 17 unmodified lines
39824149 settings = getSettings();
39834150 }
39844151
3985− settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale);
4152+ settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity);
39864153 settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
39874154 settings->setValue("horizontalFieldOfView", _horizontalFieldOfView);
39884155 settings->beginGroup("View Frustum Offset Camera");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t