Showing the changes to interface/src/main.cpp (1 of 19 files). Show all
Unified · Split
| @@ -70,7 +70,6 @@ · 69 unmodified lines | ||
| 70 | 70 | #include "Oscilloscope.h" |
| 71 | 71 | #include "UDPSocket.h" |
| 72 | 72 | #include "SerialInterface.h" |
| 73 | −#include <SharedUtil.h> | |
| 74 | 73 | #include <PacketHeaders.h> |
| 75 | 74 | #include <AvatarData.h> |
| 76 | 75 | #include <PerfStat.h> |
| @@ -148,15 +147,15 @@ bool renderStarsOn = true; // Whether to display the stars · 71 unmodified lines | ||
| 148 | 147 | bool renderAtmosphereOn = true; // Whether to display the atmosphere |
| 149 | 148 | bool renderAvatarsOn = true; // Whether to render avatars |
| 150 | 149 | bool paintOn = false; // Whether to paint voxels as you fly around |
| 151 | −VoxelDetail paintingVoxel; // The voxel we're painting if we're painting | |
| 152 | −unsigned char dominantColor = 0; // The dominant color of the voxel we're painting | |
| 153 | −bool perfStatsOn = false; // Do we want to display perfStats? | |
| 150 | +VoxelDetail paintingVoxel; // The voxel we're painting if we're painting | |
| 151 | +unsigned char dominantColor = 0; // The dominant color of the voxel we're painting | |
| 152 | +bool perfStatsOn = false; // Do we want to display perfStats? | |
| 154 | 153 | |
| 155 | 154 | bool logOn = true; // Whether to show on-screen log |
| 156 | 155 | |
| 157 | 156 | bool wantToKillLocalVoxels = false; |
| 158 | 157 | |
| 159 | −int noiseOn = 0; // Whether to add random noise | |
| 158 | +int noiseOn = 0; // Whether to add random noise | |
| 160 | 159 | float noise = 1.0; // Overall magnitude scaling for random noise levels |
| 161 | 160 | |
| 162 | 161 | bool gyroLook = true; // Whether to allow the gyro data from head to move your view |
| @@ -211,11 +210,11 @@ void Timer(int extra) { · 48 unmodified lines | ||
| 211 | 210 | FPS = (float)frameCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f); |
| 212 | 211 | packetsPerSecond = (float)packetCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f); |
| 213 | 212 | bytesPerSecond = (float)bytesCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f); |
| 214 | − frameCount = 0; | |
| 213 | + frameCount = 0; | |
| 215 | 214 | packetCount = 0; |
| 216 | 215 | bytesCount = 0; |
| 217 | 216 | |
| 218 | − glutTimerFunc(1000,Timer,0); | |
| 217 | + glutTimerFunc(1000,Timer,0); | |
| 219 | 218 | gettimeofday(&timerStart, NULL); |
| 220 | 219 | |
| 221 | 220 | // if we haven't detected gyros, check for them now |
| @@ -240,27 +239,27 @@ void displayStats(void) { · 18 unmodified lines | ||
| 240 | 239 | voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered() / 1000.f << "K Updated: " << voxels.getVoxelsUpdated()/1000.f << "K"; |
| 241 | 240 | drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 242 | 241 | |
| 243 | − voxelStats.str(""); | |
| 244 | − voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() / 1000.f << "K (" << voxels.getVoxelsCreatedPerSecondAverage() / 1000.f | |
| 242 | + voxelStats.str(""); | |
| 243 | + voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() / 1000.f << "K (" << voxels.getVoxelsCreatedPerSecondAverage() / 1000.f | |
| 245 | 244 | << "Kps) "; |
| 246 | 245 | drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 247 | 246 | |
| 248 | − voxelStats.str(""); | |
| 249 | − voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() / 1000.f << "K (" << voxels.getVoxelsColoredPerSecondAverage() / 1000.f | |
| 247 | + voxelStats.str(""); | |
| 248 | + voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() / 1000.f << "K (" << voxels.getVoxelsColoredPerSecondAverage() / 1000.f | |
| 250 | 249 | << "Kps) "; |
| 251 | 250 | drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 252 | 251 | |
| 253 | − voxelStats.str(""); | |
| 254 | − voxelStats << "Voxel Bits Read: " << voxels.getVoxelsBytesRead() * 8.f / 1000000.f | |
| 252 | + voxelStats.str(""); | |
| 253 | + voxelStats << "Voxel Bits Read: " << voxels.getVoxelsBytesRead() * 8.f / 1000000.f | |
| 255 | 254 | << "M (" << voxels.getVoxelsBytesReadPerSecondAverage() * 8.f / 1000000.f << " Mbps)"; |
| 256 | 255 | drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 257 | 256 | |
| 258 | − voxelStats.str(""); | |
| 259 | − float voxelsBytesPerColored = voxels.getVoxelsColored() | |
| 257 | + voxelStats.str(""); | |
| 258 | + float voxelsBytesPerColored = voxels.getVoxelsColored() | |
| 260 | 259 | ? ((float) voxels.getVoxelsBytesRead() / voxels.getVoxelsColored()) |
| 261 | 260 | : 0; |
| 262 | 261 | |
| 263 | − voxelStats << "Voxels Bits per Colored: " << voxelsBytesPerColored * 8; | |
| 262 | + voxelStats << "Voxels Bits per Colored: " << voxelsBytesPerColored * 8; | |
| 264 | 263 | drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 265 | 264 | |
| 266 | 265 | Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER); |
| @@ -276,19 +275,19 @@ void displayStats(void) { · 9 unmodified lines | ||
| 276 | 275 | |
| 277 | 276 | drawtext(10, statsVerticalOffset + 330, 0.10f, 0, 1.0, 0, avatarMixerStats); |
| 278 | 277 | |
| 279 | − if (::perfStatsOn) { | |
| 280 | − // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | |
| 281 | − char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | |
| 282 | − int lines = PerfStat::DumpStats(perfStatLinesArray); | |
| 283 | − int atZ = 150; // arbitrary place on screen that looks good | |
| 284 | − for (int line=0; line < lines; line++) { | |
| 285 | − drawtext(10, statsVerticalOffset + atZ, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]); | |
| 286 | − delete perfStatLinesArray[line]; // we're responsible for cleanup | |
| 287 | − perfStatLinesArray[line]=NULL; | |
| 288 | − atZ+=20; // height of a line | |
| 289 | − } | |
| 290 | − delete []perfStatLinesArray; // we're responsible for cleanup | |
| 291 | − } | |
| 278 | + if (::perfStatsOn) { | |
| 279 | + // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | |
| 280 | + char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | |
| 281 | + int lines = PerfStat::DumpStats(perfStatLinesArray); | |
| 282 | + int atZ = 150; // arbitrary place on screen that looks good | |
| 283 | + for (int line=0; line < lines; line++) { | |
| 284 | + drawtext(10, statsVerticalOffset + atZ, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]); | |
| 285 | + delete perfStatLinesArray[line]; // we're responsible for cleanup | |
| 286 | + perfStatLinesArray[line]=NULL; | |
| 287 | + atZ+=20; // height of a line | |
| 288 | + } | |
| 289 | + delete []perfStatLinesArray; // we're responsible for cleanup | |
| 290 | + } | |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | 293 | void initDisplay(void) { |
| @@ -321,9 +320,9 @@ void init(void) { · 26 unmodified lines | ||
| 321 | 320 | myAvatar.setNoise(noise); |
| 322 | 321 | } |
| 323 | 322 | myAvatar.setPosition(start_location); |
| 324 | − myCamera.setPosition(start_location); | |
| 323 | + myCamera.setPosition(start_location); | |
| 324 | + | |
| 325 | 325 | |
| 326 | − | |
| 327 | 326 | #ifdef MARKER_CAPTURE |
| 328 | 327 | if(marker_capture_enabled){ |
| 329 | 328 | marker_capturer.position_updated(&position_updated); |
| @@ -472,25 +471,25 @@ void updateAvatar(float deltaTime) { · 142 unmodified lines | ||
| 472 | 471 | // If I'm in paint mode, send a voxel out to VOXEL server agents. |
| 473 | 472 | if (::paintOn) { |
| 474 | 473 | |
| 475 | − glm::vec3 avatarPos = myAvatar.getPosition(); | |
| 476 | − | |
| 477 | − // For some reason, we don't want to flip X and Z here. | |
| 478 | − ::paintingVoxel.x = avatarPos.x / 10.0; | |
| 479 | − ::paintingVoxel.y = avatarPos.y / 10.0; | |
| 480 | − ::paintingVoxel.z = avatarPos.z / 10.0; | |
| 481 | − | |
| 482 | − unsigned char* bufferOut; | |
| 483 | − int sizeOut; | |
| 484 | − | |
| 485 | − if (::paintingVoxel.x >= 0.0 && ::paintingVoxel.x <= 1.0 && | |
| 486 | − ::paintingVoxel.y >= 0.0 && ::paintingVoxel.y <= 1.0 && | |
| 487 | − ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { | |
| 488 | − | |
| 489 | − if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){ | |
| 474 | + glm::vec3 avatarPos = myAvatar.getPosition(); | |
| 475 | + | |
| 476 | + // For some reason, we don't want to flip X and Z here. | |
| 477 | + ::paintingVoxel.x = avatarPos.x / 10.0; | |
| 478 | + ::paintingVoxel.y = avatarPos.y / 10.0; | |
| 479 | + ::paintingVoxel.z = avatarPos.z / 10.0; | |
| 480 | + | |
| 481 | + unsigned char* bufferOut; | |
| 482 | + int sizeOut; | |
| 483 | + | |
| 484 | + if (::paintingVoxel.x >= 0.0 && ::paintingVoxel.x <= 1.0 && | |
| 485 | + ::paintingVoxel.y >= 0.0 && ::paintingVoxel.y <= 1.0 && | |
| 486 | + ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { | |
| 487 | + | |
| 488 | + if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){ | |
| 490 | 489 | AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); |
| 491 | − delete bufferOut; | |
| 492 | − } | |
| 493 | − } | |
| 490 | + delete bufferOut; | |
| 491 | + } | |
| 492 | + } | |
| 494 | 493 | } |
| 495 | 494 | } |
| 496 | 495 | |
| @@ -498,7 +497,7 @@ void updateAvatar(float deltaTime) { · 1 unmodified line | ||
| 498 | 497 | // loadViewFrustum() |
| 499 | 498 | // |
| 500 | 499 | // Description: this will load the view frustum bounds for EITHER the head |
| 501 | −// or the "myCamera". | |
| 500 | +// or the "myCamera". | |
| 502 | 501 | // |
| 503 | 502 | |
| 504 | 503 | // These global scoped variables are used by our loadViewFrustum() and renderViewFrustum functions below, but are also |
| @@ -515,19 +514,19 @@ float viewFrustumOffsetDistance = 25.0; · 10 unmodified lines | ||
| 515 | 514 | float viewFrustumOffsetUp = 0.0; |
| 516 | 515 | |
| 517 | 516 | void loadViewFrustum(ViewFrustum& viewFrustum) { |
| 518 | − // We will use these below, from either the camera or head vectors calculated above | |
| 519 | − glm::vec3 position; | |
| 520 | − glm::vec3 direction; | |
| 521 | − glm::vec3 up; | |
| 522 | − glm::vec3 right; | |
| 523 | − float fov, nearClip, farClip; | |
| 524 | − | |
| 525 | − // Camera or Head? | |
| 526 | − if (::cameraFrustum) { | |
| 527 | − position = ::myCamera.getPosition(); | |
| 528 | − } else { | |
| 529 | − position = ::myAvatar.getHeadPosition(); | |
| 530 | − } | |
| 517 | + // We will use these below, from either the camera or head vectors calculated above | |
| 518 | + glm::vec3 position; | |
| 519 | + glm::vec3 direction; | |
| 520 | + glm::vec3 up; | |
| 521 | + glm::vec3 right; | |
| 522 | + float fov, nearClip, farClip; | |
| 523 | + | |
| 524 | + // Camera or Head? | |
| 525 | + if (::cameraFrustum) { | |
| 526 | + position = ::myCamera.getPosition(); | |
| 527 | + } else { | |
| 528 | + position = ::myAvatar.getHeadPosition(); | |
| 529 | + } | |
| 531 | 530 | |
| 532 | 531 | fov = ::myCamera.getFieldOfView(); |
| 533 | 532 | nearClip = ::myCamera.getNearClip(); |
| @@ -550,7 +549,7 @@ void loadViewFrustum(ViewFrustum& viewFrustum) { · 16 unmodified lines | ||
| 550 | 549 | printf("farClip=%f\n", farClip); |
| 551 | 550 | */ |
| 552 | 551 | |
| 553 | − // Set the viewFrustum up with the correct position and orientation of the camera | |
| 552 | + // Set the viewFrustum up with the correct position and orientation of the camera | |
| 554 | 553 | viewFrustum.setPosition(position); |
| 555 | 554 | viewFrustum.setOrientation(direction,up,right); |
| 556 | 555 | |
| @@ -567,7 +566,7 @@ void loadViewFrustum(ViewFrustum& viewFrustum) { · 10 unmodified lines | ||
| 567 | 566 | // renderViewFrustum() |
| 568 | 567 | // |
| 569 | 568 | // Description: this will render the view frustum bounds for EITHER the head |
| 570 | −// or the "myCamera". | |
| 569 | +// or the "myCamera". | |
| 571 | 570 | // |
| 572 | 571 | // Frustum rendering mode. For debug purposes, we allow drawing the frustum in a couple of different ways. |
| 573 | 572 | // We can draw it with each of these parts: |
| @@ -594,102 +593,102 @@ void renderViewFrustum(ViewFrustum& viewFrustum) { · 20 unmodified lines | ||
| 594 | 593 | |
| 595 | 594 | // Load it with the latest details! |
| 596 | 595 | loadViewFrustum(viewFrustum); |
| 597 | − | |
| 596 | + | |
| 598 | 597 | glm::vec3 position = viewFrustum.getPosition(); |
| 599 | 598 | glm::vec3 direction = viewFrustum.getDirection(); |
| 600 | 599 | glm::vec3 up = viewFrustum.getUp(); |
| 601 | 600 | glm::vec3 right = viewFrustum.getRight(); |
| 602 | − | |
| 601 | + | |
| 603 | 602 | // Get ready to draw some lines |
| 604 | 603 | glDisable(GL_LIGHTING); |
| 605 | 604 | glColor4f(1.0, 1.0, 1.0, 1.0); |
| 606 | 605 | glLineWidth(1.0); |
| 607 | 606 | glBegin(GL_LINES); |
| 608 | 607 | |
| 609 | − if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_VECTORS) { | |
| 610 | − // Calculate the origin direction vectors | |
| 611 | − glm::vec3 lookingAt = position + (direction * 0.2f); | |
| 612 | − glm::vec3 lookingAtUp = position + (up * 0.2f); | |
| 613 | − glm::vec3 lookingAtRight = position + (right * 0.2f); | |
| 614 | − | |
| 615 | − // Looking At = white | |
| 616 | − glColor3f(1,1,1); | |
| 617 | − glVertex3f(position.x, position.y, position.z); | |
| 618 | − glVertex3f(lookingAt.x, lookingAt.y, lookingAt.z); | |
| 619 | − | |
| 620 | − // Looking At Up = purple | |
| 621 | − glColor3f(1,0,1); | |
| 622 | − glVertex3f(position.x, position.y, position.z); | |
| 623 | − glVertex3f(lookingAtUp.x, lookingAtUp.y, lookingAtUp.z); | |
| 624 | − | |
| 625 | − // Looking At Right = cyan | |
| 626 | − glColor3f(0,1,1); | |
| 627 | − glVertex3f(position.x, position.y, position.z); | |
| 628 | − glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z); | |
| 629 | − } | |
| 630 | − | |
| 631 | − if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 632 | − || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | |
| 633 | − // Drawing the bounds of the frustum | |
| 634 | − // viewFrustum.getNear plane - bottom edge | |
| 635 | − glColor3f(1,0,0); | |
| 636 | − glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 637 | − glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 638 | − | |
| 639 | − // viewFrustum.getNear plane - top edge | |
| 640 | − glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 641 | − glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 642 | − | |
| 643 | − // viewFrustum.getNear plane - right edge | |
| 644 | − glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 645 | − glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 646 | − | |
| 647 | − // viewFrustum.getNear plane - left edge | |
| 648 | − glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 649 | − glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 650 | − } | |
| 651 | − | |
| 652 | − if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 653 | − || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_FAR_PLANE) { | |
| 654 | − // viewFrustum.getFar plane - bottom edge | |
| 655 | − glColor3f(0,1,0); // GREEN!!! | |
| 656 | − glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 657 | − glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 658 | − | |
| 659 | − // viewFrustum.getFar plane - top edge | |
| 660 | − glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 661 | − glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 662 | − | |
| 663 | − // viewFrustum.getFar plane - right edge | |
| 664 | − glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 665 | − glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 666 | − | |
| 667 | − // viewFrustum.getFar plane - left edge | |
| 668 | − glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 669 | − glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 670 | − } | |
| 671 | − | |
| 672 | − if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES) { | |
| 673 | − // RIGHT PLANE IS CYAN | |
| 674 | − // right plane - bottom edge - viewFrustum.getNear to distant | |
| 675 | − glColor3f(0,1,1); | |
| 676 | − glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 677 | − glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 678 | − | |
| 679 | − // right plane - top edge - viewFrustum.getNear to distant | |
| 680 | − glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 681 | − glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 682 | − | |
| 683 | − // LEFT PLANE IS BLUE | |
| 684 | − // left plane - bottom edge - viewFrustum.getNear to distant | |
| 685 | − glColor3f(0,0,1); | |
| 686 | − glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 687 | − glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 688 | − | |
| 689 | − // left plane - top edge - viewFrustum.getNear to distant | |
| 690 | − glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 691 | − glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 692 | − } | |
| 608 | + if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_VECTORS) { | |
| 609 | + // Calculate the origin direction vectors | |
| 610 | + glm::vec3 lookingAt = position + (direction * 0.2f); | |
| 611 | + glm::vec3 lookingAtUp = position + (up * 0.2f); | |
| 612 | + glm::vec3 lookingAtRight = position + (right * 0.2f); | |
| 613 | + | |
| 614 | + // Looking At = white | |
| 615 | + glColor3f(1,1,1); | |
| 616 | + glVertex3f(position.x, position.y, position.z); | |
| 617 | + glVertex3f(lookingAt.x, lookingAt.y, lookingAt.z); | |
| 618 | + | |
| 619 | + // Looking At Up = purple | |
| 620 | + glColor3f(1,0,1); | |
| 621 | + glVertex3f(position.x, position.y, position.z); | |
| 622 | + glVertex3f(lookingAtUp.x, lookingAtUp.y, lookingAtUp.z); | |
| 623 | + | |
| 624 | + // Looking At Right = cyan | |
| 625 | + glColor3f(0,1,1); | |
| 626 | + glVertex3f(position.x, position.y, position.z); | |
| 627 | + glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z); | |
| 628 | + } | |
| 629 | + | |
| 630 | + if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 631 | + || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_NEAR_PLANE) { | |
| 632 | + // Drawing the bounds of the frustum | |
| 633 | + // viewFrustum.getNear plane - bottom edge | |
| 634 | + glColor3f(1,0,0); | |
| 635 | + glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 636 | + glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 637 | + | |
| 638 | + // viewFrustum.getNear plane - top edge | |
| 639 | + glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 640 | + glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 641 | + | |
| 642 | + // viewFrustum.getNear plane - right edge | |
| 643 | + glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 644 | + glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 645 | + | |
| 646 | + // viewFrustum.getNear plane - left edge | |
| 647 | + glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 648 | + glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 649 | + } | |
| 650 | + | |
| 651 | + if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES | |
| 652 | + || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_FAR_PLANE) { | |
| 653 | + // viewFrustum.getFar plane - bottom edge | |
| 654 | + glColor3f(0,1,0); // GREEN!!! | |
| 655 | + glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 656 | + glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 657 | + | |
| 658 | + // viewFrustum.getFar plane - top edge | |
| 659 | + glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 660 | + glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 661 | + | |
| 662 | + // viewFrustum.getFar plane - right edge | |
| 663 | + glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 664 | + glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 665 | + | |
| 666 | + // viewFrustum.getFar plane - left edge | |
| 667 | + glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 668 | + glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 669 | + } | |
| 670 | + | |
| 671 | + if (::frustumDrawingMode == FRUSTUM_DRAW_MODE_ALL || ::frustumDrawingMode == FRUSTUM_DRAW_MODE_PLANES) { | |
| 672 | + // RIGHT PLANE IS CYAN | |
| 673 | + // right plane - bottom edge - viewFrustum.getNear to distant | |
| 674 | + glColor3f(0,1,1); | |
| 675 | + glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z); | |
| 676 | + glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z); | |
| 677 | + | |
| 678 | + // right plane - top edge - viewFrustum.getNear to distant | |
| 679 | + glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z); | |
| 680 | + glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z); | |
| 681 | + | |
| 682 | + // LEFT PLANE IS BLUE | |
| 683 | + // left plane - bottom edge - viewFrustum.getNear to distant | |
| 684 | + glColor3f(0,0,1); | |
| 685 | + glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z); | |
| 686 | + glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z); | |
| 687 | + | |
| 688 | + // left plane - top edge - viewFrustum.getNear to distant | |
| 689 | + glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); | |
| 690 | + glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); | |
| 691 | + } | |
| 693 | 692 | |
| 694 | 693 | glEnd(); |
| 695 | 694 | glEnable(GL_LIGHTING); |
| @@ -716,7 +715,7 @@ void displaySide(Camera& whichCamera) { · 20 unmodified lines | ||
| 716 | 715 | } |
| 717 | 716 | |
| 718 | 717 | // finally render the starfield |
| 719 | − stars.render(whichCamera.getFieldOfView(), aspectRatio, whichCamera.getNearClip(), alpha); | |
| 718 | + stars.render(whichCamera.getFieldOfView(), aspectRatio, whichCamera.getNearClip(), alpha); | |
| 720 | 719 | } |
| 721 | 720 | |
| 722 | 721 | // draw the sky dome |
| @@ -727,8 +726,8 @@ void displaySide(Camera& whichCamera) { · 4 unmodified lines | ||
| 727 | 726 | glEnable(GL_LIGHTING); |
| 728 | 727 | glEnable(GL_DEPTH_TEST); |
| 729 | 728 | |
| 730 | − // draw a red sphere | |
| 731 | − float sphereRadius = 0.25f; | |
| 729 | + // draw a red sphere | |
| 730 | + float sphereRadius = 0.25f; | |
| 732 | 731 | glColor3f(1,0,0); |
| 733 | 732 | glPushMatrix(); |
| 734 | 733 | glutSolidSphere(sphereRadius, 15, 15); |
| @@ -736,12 +735,12 @@ void displaySide(Camera& whichCamera) { · 1 unmodified line | ||
| 736 | 735 | |
| 737 | 736 | //draw a grid ground plane.... |
| 738 | 737 | drawGroundPlaneGrid(10.f); |
| 739 | − | |
| 738 | + | |
| 740 | 739 | // Draw voxels |
| 741 | 740 | if (renderVoxels) { |
| 742 | 741 | voxels.render(); |
| 743 | 742 | } |
| 744 | − | |
| 743 | + | |
| 745 | 744 | if (::renderAvatarsOn) { |
| 746 | 745 | // Render avatars of other agents |
| 747 | 746 | AgentList* agentList = AgentList::getInstance(); |
| @@ -763,8 +762,8 @@ void displaySide(Camera& whichCamera) { · 15 unmodified lines | ||
| 763 | 762 | |
| 764 | 763 | // brad's frustum for debugging |
| 765 | 764 | if (::frustumOn) renderViewFrustum(::viewFrustum); |
| 766 | − | |
| 767 | − glPopMatrix(); | |
| 765 | + | |
| 766 | + glPopMatrix(); | |
| 768 | 767 | } |
| 769 | 768 | |
| 770 | 769 | // this shader is an adaptation (HLSL -> GLSL, removed conditional) of the one in the Oculus sample |
| @@ -986,11 +985,11 @@ void displayOverlay() { · 215 unmodified lines | ||
| 986 | 985 | |
| 987 | 986 | if (::paintOn) { |
| 988 | 987 | |
| 989 | − char paintMessage[100]; | |
| 990 | − sprintf(paintMessage,"Painting (%.3f,%.3f,%.3f/%.3f/%d,%d,%d)", | |
| 991 | − ::paintingVoxel.x,::paintingVoxel.y,::paintingVoxel.z,::paintingVoxel.s, | |
| 992 | − (unsigned int)::paintingVoxel.red,(unsigned int)::paintingVoxel.green,(unsigned int)::paintingVoxel.blue); | |
| 993 | − drawtext(WIDTH-350,50, 0.10, 0, 1.0, 0, paintMessage, 1, 1, 0); | |
| 988 | + char paintMessage[100]; | |
| 989 | + sprintf(paintMessage,"Painting (%.3f,%.3f,%.3f/%.3f/%d,%d,%d)", | |
| 990 | + ::paintingVoxel.x,::paintingVoxel.y,::paintingVoxel.z,::paintingVoxel.s, | |
| 991 | + (unsigned int)::paintingVoxel.red,(unsigned int)::paintingVoxel.green,(unsigned int)::paintingVoxel.blue); | |
| 992 | + drawtext(WIDTH-350,50, 0.10, 0, 1.0, 0, paintMessage, 1, 1, 0); | |
| 994 | 993 | } |
| 995 | 994 | |
| 996 | 995 | glPopMatrix(); |
| @@ -998,7 +997,7 @@ void displayOverlay() { · 1 unmodified line | ||
| 998 | 997 | |
| 999 | 998 | void display(void) |
| 1000 | 999 | { |
| 1001 | − PerfStat("display"); | |
| 1000 | + PerfStat("display"); | |
| 1002 | 1001 | |
| 1003 | 1002 | glEnable(GL_LINE_SMOOTH); |
| 1004 | 1003 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| @@ -1007,22 +1006,6 @@ void display(void) · 2 unmodified lines | ||
| 1007 | 1006 | glPushMatrix(); { |
| 1008 | 1007 | glLoadIdentity(); |
| 1009 | 1008 | |
| 1010 | − // Setup 3D lights | |
| 1011 | − glEnable(GL_COLOR_MATERIAL); | |
| 1012 | − glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); | |
| 1013 | − | |
| 1014 | − GLfloat light_position0[] = { 1.0, 1.0, 0.0, 0.0 }; | |
| 1015 | − glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | |
| 1016 | − GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; | |
| 1017 | − glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | |
| 1018 | − GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; | |
| 1019 | − glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | |
| 1020 | − GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0}; | |
| 1021 | − glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color); | |
| 1022 | − | |
| 1023 | − glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); | |
| 1024 | − glMateriali(GL_FRONT, GL_SHININESS, 96); | |
| 1025 | − | |
| 1026 | 1009 | // camera settings |
| 1027 | 1010 | if (::lookingInMirror) { |
| 1028 | 1011 | // set the camera to looking at my own face |
| @@ -1030,10 +1013,10 @@ void display(void) · 1 unmodified line | ||
| 1030 | 1013 | myCamera.setTargetYaw (myAvatar.getBodyYaw() - 180.0f); // 180 degrees from body yaw |
| 1031 | 1014 | myCamera.setPitch (0.0); |
| 1032 | 1015 | myCamera.setRoll (0.0); |
| 1033 | − myCamera.setUpShift (0.0); | |
| 1016 | + myCamera.setUpShift (0.0); | |
| 1034 | 1017 | myCamera.setDistance (0.2); |
| 1035 | 1018 | myCamera.setTightness (100.0f); |
| 1036 | − } else { | |
| 1019 | + } else { | |
| 1037 | 1020 | |
| 1038 | 1021 | //float firstPersonPitch = 20.0f; |
| 1039 | 1022 | //float firstPersonUpShift = 0.0f; |
| @@ -1063,7 +1046,7 @@ void display(void) · 23 unmodified lines | ||
| 1063 | 1046 | } |
| 1064 | 1047 | } |
| 1065 | 1048 | |
| 1066 | − myCamera.setPitch (thirdPersonPitch + ff * (firstPersonPitch - thirdPersonPitch )); | |
| 1049 | + myCamera.setPitch (thirdPersonPitch + ff * (firstPersonPitch - thirdPersonPitch )); | |
| 1067 | 1050 | myCamera.setUpShift (thirdPersonUpShift + ff * (firstPersonUpShift - thirdPersonUpShift )); |
| 1068 | 1051 | myCamera.setDistance (thirdPersonDistance + ff * (firstPersonDistance - thirdPersonDistance )); |
| 1069 | 1052 | myCamera.setTightness (thirdPersonTightness + ff * (firstPersonTightness - thirdPersonTightness)); |
| @@ -1077,7 +1060,7 @@ void display(void) · 7 unmodified lines | ||
| 1077 | 1060 | } |
| 1078 | 1061 | |
| 1079 | 1062 | //printf("myCamera.getModeShift() = %f\n", myCamera.getModeShift()); |
| 1080 | − myCamera.setPitch (thirdPersonPitch + myCamera.getModeShift() * (firstPersonPitch - thirdPersonPitch )); | |
| 1063 | + myCamera.setPitch (thirdPersonPitch + myCamera.getModeShift() * (firstPersonPitch - thirdPersonPitch )); | |
| 1081 | 1064 | myCamera.setUpShift (thirdPersonUpShift + myCamera.getModeShift() * (firstPersonUpShift - thirdPersonUpShift )); |
| 1082 | 1065 | myCamera.setDistance (thirdPersonDistance + myCamera.getModeShift() * (firstPersonDistance - thirdPersonDistance )); |
| 1083 | 1066 | myCamera.setTightness (thirdPersonTightness + myCamera.getModeShift() * (firstPersonTightness - thirdPersonTightness)); |
| @@ -1087,7 +1070,7 @@ void display(void) · 3 unmodified lines | ||
| 1087 | 1070 | } |
| 1088 | 1071 | |
| 1089 | 1072 | //printf("myCamera.getModeShift() = %f\n", myCamera.getModeShift()); |
| 1090 | − myCamera.setPitch (firstPersonPitch + myCamera.getModeShift() * (thirdPersonPitch - firstPersonPitch )); | |
| 1073 | + myCamera.setPitch (firstPersonPitch + myCamera.getModeShift() * (thirdPersonPitch - firstPersonPitch )); | |
| 1091 | 1074 | myCamera.setUpShift (firstPersonUpShift + myCamera.getModeShift() * (thirdPersonUpShift - firstPersonUpShift )); |
| 1092 | 1075 | myCamera.setDistance (firstPersonDistance + myCamera.getModeShift() * (thirdPersonDistance - firstPersonDistance )); |
| 1093 | 1076 | myCamera.setTightness (firstPersonTightness + myCamera.getModeShift() * (thirdPersonTightness - firstPersonTightness)); |
| @@ -1104,7 +1087,7 @@ void display(void) · 10 unmodified lines | ||
| 1104 | 1087 | myCamera.setTargetPosition(myAvatar.getHeadPosition()); |
| 1105 | 1088 | myCamera.setTargetYaw (myAvatar.getBodyYaw()); |
| 1106 | 1089 | myCamera.setRoll (0.0); |
| 1107 | − } | |
| 1090 | + } | |
| 1108 | 1091 | |
| 1109 | 1092 | // important... |
| 1110 | 1093 | |
| @@ -1120,19 +1103,19 @@ void display(void) · 9 unmodified lines | ||
| 1120 | 1103 | glPopMatrix(); |
| 1121 | 1104 | */ |
| 1122 | 1105 | |
| 1123 | − | |
| 1124 | − // Note: whichCamera is used to pick between the normal camera myCamera for our | |
| 1125 | − // main camera, vs, an alternate camera. The alternate camera we support right now | |
| 1126 | − // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism | |
| 1127 | − // to add other cameras. | |
| 1128 | − // | |
| 1129 | − // Why have two cameras? Well, one reason is that because in the case of the renderViewFrustum() | |
| 1130 | − // code, we want to keep the state of "myCamera" intact, so we can render what the view frustum of | |
| 1131 | − // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera | |
| 1132 | − Camera whichCamera = myCamera; | |
| 1133 | − Camera viewFrustumOffsetCamera = myCamera; | |
| 1134 | − | |
| 1135 | − if (::viewFrustumFromOffset && ::frustumOn) { | |
| 1106 | + | |
| 1107 | + // Note: whichCamera is used to pick between the normal camera myCamera for our | |
| 1108 | + // main camera, vs, an alternate camera. The alternate camera we support right now | |
| 1109 | + // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism | |
| 1110 | + // to add other cameras. | |
| 1111 | + // | |
| 1112 | + // Why have two cameras? Well, one reason is that because in the case of the renderViewFrustum() | |
| 1113 | + // code, we want to keep the state of "myCamera" intact, so we can render what the view frustum of | |
| 1114 | + // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera | |
| 1115 | + Camera whichCamera = myCamera; | |
| 1116 | + Camera viewFrustumOffsetCamera = myCamera; | |
| 1117 | + | |
| 1118 | + if (::viewFrustumFromOffset && ::frustumOn) { | |
| 1136 | 1119 | |
| 1137 | 1120 | // set the camera to third-person view but offset so we can see the frustum |
| 1138 | 1121 | viewFrustumOffsetCamera.setTargetYaw(::viewFrustumOffsetYaw + myAvatar.getBodyYaw()); |
| @@ -1142,19 +1125,35 @@ void display(void) · 3 unmodified lines | ||
| 1142 | 1125 | viewFrustumOffsetCamera.setDistance (::viewFrustumOffsetDistance); |
| 1143 | 1126 | viewFrustumOffsetCamera.update(1.f/FPS); |
| 1144 | 1127 | whichCamera = viewFrustumOffsetCamera; |
| 1145 | − } | |
| 1128 | + } | |
| 1146 | 1129 | |
| 1147 | − // transform view according to whichCamera | |
| 1148 | − // could be myCamera (if in normal mode) | |
| 1149 | − // or could be viewFrustumOffsetCamera if in offset mode | |
| 1150 | − // I changed the ordering here - roll is FIRST (JJV) | |
| 1130 | + // transform view according to whichCamera | |
| 1131 | + // could be myCamera (if in normal mode) | |
| 1132 | + // or could be viewFrustumOffsetCamera if in offset mode | |
| 1133 | + // I changed the ordering here - roll is FIRST (JJV) | |
| 1151 | 1134 | |
| 1152 | 1135 | glRotatef ( whichCamera.getRoll(), IDENTITY_FRONT.x, IDENTITY_FRONT.y, IDENTITY_FRONT.z); |
| 1153 | 1136 | glRotatef ( whichCamera.getPitch(), IDENTITY_RIGHT.x, IDENTITY_RIGHT.y, IDENTITY_RIGHT.z); |
| 1154 | − glRotatef (180.0 - whichCamera.getYaw(), IDENTITY_UP.x, IDENTITY_UP.y, IDENTITY_UP.z ); | |
| 1137 | + glRotatef (180.0 - whichCamera.getYaw(), IDENTITY_UP.x, IDENTITY_UP.y, IDENTITY_UP.z ); | |
| 1155 | 1138 | |
| 1156 | 1139 | glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z); |
| 1157 | − | |
| 1140 | + | |
| 1141 | + // Setup 3D lights (after the camera transform, so that they are positioned in world space) | |
| 1142 | + glEnable(GL_COLOR_MATERIAL); | |
| 1143 | + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); | |
| 1144 | + | |
| 1145 | + GLfloat light_position0[] = { 1.0, 1.0, 0.0, 0.0 }; | |
| 1146 | + glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | |
| 1147 | + GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; | |
| 1148 | + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | |
| 1149 | + GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; | |
| 1150 | + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | |
| 1151 | + GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0}; | |
| 1152 | + glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color); | |
| 1153 | + | |
| 1154 | + glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); | |
| 1155 | + glMateriali(GL_FRONT, GL_SHININESS, 96); | |
| 1156 | + | |
| 1158 | 1157 | if (::oculusOn) { |
| 1159 | 1158 | displayOculus(whichCamera); |
| 1160 | 1159 | |
| @@ -1312,7 +1311,7 @@ int quitApp(int state) { · 151 unmodified lines | ||
| 1312 | 1311 | |
| 1313 | 1312 | int setFrustumRenderMode(int state) { |
| 1314 | 1313 | if (state == MENU_ROW_PICKED) { |
| 1315 | − ::frustumDrawingMode = (::frustumDrawingMode+1)%FRUSTUM_DRAW_MODE_COUNT; | |
| 1314 | + ::frustumDrawingMode = (::frustumDrawingMode+1)%FRUSTUM_DRAW_MODE_COUNT; | |
| 1316 | 1315 | } |
| 1317 | 1316 | return ::frustumDrawingMode; |
| 1318 | 1317 | } |
| @@ -1376,25 +1375,25 @@ const char* modeNear = " - Near "; · 57 unmodified lines | ||
| 1376 | 1375 | const char* modeFar = " - Far "; |
| 1377 | 1376 | |
| 1378 | 1377 | const char* getFrustumRenderModeName(int state) { |
| 1379 | − const char * mode; | |
| 1380 | − switch (state) { | |
| 1381 | − case FRUSTUM_DRAW_MODE_ALL: | |
| 1382 | − mode = modeAll; | |
| 1383 | − break; | |
| 1384 | − case FRUSTUM_DRAW_MODE_VECTORS: | |
| 1385 | − mode = modeVectors; | |
| 1386 | − break; | |
| 1387 | − case FRUSTUM_DRAW_MODE_PLANES: | |
| 1388 | − mode = modePlanes; | |
| 1389 | − break; | |
| 1390 | − case FRUSTUM_DRAW_MODE_NEAR_PLANE: | |
| 1391 | − mode = modeNear; | |
| 1392 | − break; | |
| 1393 | − case FRUSTUM_DRAW_MODE_FAR_PLANE: | |
| 1394 | − mode = modeFar; | |
| 1395 | − break; | |
| 1396 | − } | |
| 1397 | − return mode; | |
| 1378 | + const char * mode; | |
| 1379 | + switch (state) { | |
| 1380 | + case FRUSTUM_DRAW_MODE_ALL: | |
| 1381 | + mode = modeAll; | |
| 1382 | + break; | |
| 1383 | + case FRUSTUM_DRAW_MODE_VECTORS: | |
| 1384 | + mode = modeVectors; | |
| 1385 | + break; | |
| 1386 | + case FRUSTUM_DRAW_MODE_PLANES: | |
| 1387 | + mode = modePlanes; | |
| 1388 | + break; | |
| 1389 | + case FRUSTUM_DRAW_MODE_NEAR_PLANE: | |
| 1390 | + mode = modeNear; | |
| 1391 | + break; | |
| 1392 | + case FRUSTUM_DRAW_MODE_FAR_PLANE: | |
| 1393 | + mode = modeFar; | |
| 1394 | + break; | |
| 1395 | + } | |
| 1396 | + return mode; | |
| 1398 | 1397 | } |
| 1399 | 1398 | |
| 1400 | 1399 | void initMenu() { |
| @@ -1441,55 +1440,117 @@ void initMenu() { · 40 unmodified lines | ||
| 1441 | 1440 | } |
| 1442 | 1441 | |
| 1443 | 1442 | void testPointToVoxel() { |
| 1444 | − float y=0; | |
| 1445 | − float z=0; | |
| 1446 | − float s=0.1; | |
| 1447 | − for (float x=0; x<=1; x+= 0.05) { | |
| 1448 | − printLog(" x=%f"); | |
| 1449 | − | |
| 1450 | − unsigned char red = 200; //randomColorValue(65); | |
| 1451 | − unsigned char green = 200; //randomColorValue(65); | |
| 1452 | − unsigned char blue = 200; //randomColorValue(65); | |
| 1453 | − | |
| 1454 | − unsigned char* voxelCode = pointToVoxel(x, y, z, s,red,green,blue); | |
| 1455 | − printVoxelCode(voxelCode); | |
| 1456 | − delete voxelCode; | |
| 1457 | − printLog("\n"); | |
| 1458 | − } | |
| 1443 | + float y=0; | |
| 1444 | + float z=0; | |
| 1445 | + float s=0.1; | |
| 1446 | + for (float x=0; x<=1; x+= 0.05) { | |
| 1447 | + printLog(" x=%f"); | |
| 1448 | + | |
| 1449 | + unsigned char red = 200; //randomColorValue(65); | |
| 1450 | + unsigned char green = 200; //randomColorValue(65); | |
| 1451 | + unsigned char blue = 200; //randomColorValue(65); | |
| 1452 | + | |
| 1453 | + unsigned char* voxelCode = pointToVoxel(x, y, z, s,red,green,blue); | |
| 1454 | + printVoxelCode(voxelCode); | |
| 1455 | + delete voxelCode; | |
| 1456 | + printLog("\n"); | |
| 1457 | + } | |
| 1459 | 1458 | } |
| 1460 | 1459 | |
| 1461 | 1460 | void sendVoxelServerEraseAll() { |
| 1462 | − char message[100]; | |
| 1461 | + char message[100]; | |
| 1463 | 1462 | sprintf(message,"%c%s",'Z',"erase all"); |
| 1464 | − int messageSize = strlen(message) + 1; | |
| 1465 | − AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1); | |
| 1463 | + int messageSize = strlen(message) + 1; | |
| 1464 | + AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1); | |
| 1466 | 1465 | } |
| 1467 | 1466 | |
| 1468 | 1467 | void sendVoxelServerAddScene() { |
| 1469 | − char message[100]; | |
| 1468 | + char message[100]; | |
| 1470 | 1469 | sprintf(message,"%c%s",'Z',"add scene"); |
| 1471 | − int messageSize = strlen(message) + 1; | |
| 1472 | − AgentList::getInstance()->broadcastToAgents((unsigned char*)message, messageSize, &AGENT_TYPE_VOXEL, 1); | |
| 1470 | + int messageSize = strlen(message) + 1; | |
| 1471 | + AgentList::getInstance()->broadcastToAgents((unsigned char*)message, messageSize, &AGENT_TYPE_VOXEL, 1); | |
| 1473 | 1472 | } |
| 1474 | 1473 | |
| 1475 | 1474 | void shiftPaintingColor() |
| 1476 | 1475 | { |
| 1477 | 1476 | // About the color of the paintbrush... first determine the dominant color |
| 1478 | 1477 | ::dominantColor = (::dominantColor+1)%3; // 0=red,1=green,2=blue |
| 1479 | − ::paintingVoxel.red = (::dominantColor==0)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1480 | − ::paintingVoxel.green = (::dominantColor==1)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1481 | − ::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1478 | + ::paintingVoxel.red = (::dominantColor==0)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1479 | + ::paintingVoxel.green = (::dominantColor==1)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1480 | + ::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100); | |
| 1482 | 1481 | } |
| 1483 | 1482 | |
| 1484 | 1483 | void setupPaintingVoxel() { |
| 1485 | − glm::vec3 avatarPos = myAvatar.getPosition(); | |
| 1486 | − | |
| 1487 | − ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space | |
| 1488 | − ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space | |
| 1489 | − ::paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space | |
| 1490 | − ::paintingVoxel.s = 1.0/256; | |
| 1491 | − | |
| 1492 | − shiftPaintingColor(); | |
| 1484 | + glm::vec3 avatarPos = myAvatar.getPosition(); | |
| 1485 | + | |
| 1486 | + ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space | |
| 1487 | + ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space | |
| 1488 | + ::paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space | |
| 1489 | + ::paintingVoxel.s = 1.0/256; | |
| 1490 | + | |
| 1491 | + shiftPaintingColor(); | |
| 1492 | +} | |
| 1493 | + | |
| 1494 | +void addVoxelUnderCursor() { | |
| 1495 | + glm::vec3 origin, direction; | |
| 1496 | + viewFrustum.computePickRay(mouseX / (float)WIDTH, mouseY / (float)HEIGHT, origin, direction); | |
| 1497 | + | |
| 1498 | + VoxelDetail detail; | |
| 1499 | + float distance; | |
| 1500 | + BoxFace face; | |
| 1501 | + if (voxels.findRayIntersection(origin, direction, detail, distance, face)) { | |
| 1502 | + // use the face to determine the side on which to create a neighbor | |
| 1503 | + switch (face) { | |
| 1504 | + case MIN_X_FACE: | |
| 1505 | + detail.x -= detail.s; | |
| 1506 | + break; | |
| 1507 | + | |
| 1508 | + case MAX_X_FACE: | |
| 1509 | + detail.x += detail.s; | |
| 1510 | + break; | |
| 1511 | + | |
| 1512 | + case MIN_Y_FACE: | |
| 1513 | + detail.y -= detail.s; | |
| 1514 | + break; | |
| 1515 | + | |
| 1516 | + case MAX_Y_FACE: | |
| 1517 | + detail.y += detail.s; | |
| 1518 | + break; | |
| 1519 | + | |
| 1520 | + case MIN_Z_FACE: | |
| 1521 | + detail.z -= detail.s; | |
| 1522 | + break; | |
| 1523 | + | |
| 1524 | + case MAX_Z_FACE: | |
| 1525 | + detail.z += detail.s; | |
| 1526 | + break; | |
| 1527 | + } | |
| 1528 | + unsigned char* bufferOut; | |
| 1529 | + int sizeOut; | |
| 1530 | + | |
| 1531 | + if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &detail, bufferOut, sizeOut)){ | |
| 1532 | + AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); | |
| 1533 | + delete bufferOut; | |
| 1534 | + } | |
| 1535 | + } | |
| 1536 | +} | |
| 1537 | + | |
| 1538 | +void deleteVoxelUnderCursor() { | |
| 1539 | + glm::vec3 origin, direction; | |
| 1540 | + viewFrustum.computePickRay(mouseX / (float)WIDTH, mouseY / (float)HEIGHT, origin, direction); | |
| 1541 | + | |
| 1542 | + VoxelDetail detail; | |
| 1543 | + float distance; | |
| 1544 | + BoxFace face; | |
| 1545 | + if (voxels.findRayIntersection(origin, direction, detail, distance, face)) { | |
| 1546 | + unsigned char* bufferOut; | |
| 1547 | + int sizeOut; | |
| 1548 | + | |
| 1549 | + if (createVoxelEditMessage(PACKET_HEADER_ERASE_VOXEL, 0, 1, &detail, bufferOut, sizeOut)){ | |
| 1550 | + AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); | |
| 1551 | + delete bufferOut; | |
| 1552 | + } | |
| 1553 | + } | |
| 1493 | 1554 | } |
| 1494 | 1555 | |
| 1495 | 1556 | const float KEYBOARD_YAW_RATE = 0.8; |
| @@ -1574,42 +1635,44 @@ void key(unsigned char k, int x, int y) { · 78 unmodified lines | ||
| 1574 | 1635 | return; |
| 1575 | 1636 | } |
| 1576 | 1637 | |
| 1577 | − // Process keypresses | |
| 1578 | − if (k == 'q' || k == 'Q') ::terminate(); | |
| 1579 | − if (k == '/') ::renderStatsOn = !::renderStatsOn; // toggle stats | |
| 1580 | − if (k == '*') ::renderStarsOn = !::renderStarsOn; // toggle stars | |
| 1581 | − if (k == 'V' || k == 'v') ::renderVoxels = !::renderVoxels; // toggle voxels | |
| 1638 | + // Process keypresses | |
| 1639 | + if (k == 'q' || k == 'Q') ::terminate(); | |
| 1640 | + if (k == '/') ::renderStatsOn = !::renderStatsOn; // toggle stats | |
| 1641 | + if (k == '*') ::renderStarsOn = !::renderStarsOn; // toggle stars | |
| 1642 | + if (k == 'V' || k == 'v') ::renderVoxels = !::renderVoxels; // toggle voxels | |
| 1582 | 1643 | if (k == 'A') ::renderAtmosphereOn = !::renderAtmosphereOn; |
| 1583 | − if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging | |
| 1584 | − if (k == 'C') ::cameraFrustum = !::cameraFrustum; // toggle which frustum to look at | |
| 1644 | + if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging | |
| 1645 | + if (k == 'C') ::cameraFrustum = !::cameraFrustum; // toggle which frustum to look at | |
| 1585 | 1646 | if (k == 'O' || k == 'G') setFrustumOffset(MENU_ROW_PICKED); // toggle view frustum offset debugging |
| 1586 | 1647 | if (k == 'f') setFullscreen(!::fullscreen); |
| 1587 | 1648 | if (k == 'o') setOculus(!::oculusOn); |
| 1588 | 1649 | |
| 1589 | − if (k == '[') ::viewFrustumOffsetYaw -= 0.5; | |
| 1590 | − if (k == ']') ::viewFrustumOffsetYaw += 0.5; | |
| 1591 | − if (k == '{') ::viewFrustumOffsetPitch -= 0.5; | |
| 1592 | − if (k == '}') ::viewFrustumOffsetPitch += 0.5; | |
| 1593 | − if (k == '(') ::viewFrustumOffsetRoll -= 0.5; | |
| 1594 | − if (k == ')') ::viewFrustumOffsetRoll += 0.5; | |
| 1595 | − if (k == '<') ::viewFrustumOffsetDistance -= 0.5; | |
| 1596 | − if (k == '>') ::viewFrustumOffsetDistance += 0.5; | |
| 1597 | − if (k == ',') ::viewFrustumOffsetUp -= 0.05; | |
| 1598 | − if (k == '.') ::viewFrustumOffsetUp += 0.05; | |
| 1650 | + if (k == '[') ::viewFrustumOffsetYaw -= 0.5; | |
| 1651 | + if (k == ']') ::viewFrustumOffsetYaw += 0.5; | |
| 1652 | + if (k == '{') ::viewFrustumOffsetPitch -= 0.5; | |
| 1653 | + if (k == '}') ::viewFrustumOffsetPitch += 0.5; | |
| 1654 | + if (k == '(') ::viewFrustumOffsetRoll -= 0.5; | |
| 1655 | + if (k == ')') ::viewFrustumOffsetRoll += 0.5; | |
| 1656 | + if (k == '<') ::viewFrustumOffsetDistance -= 0.5; | |
| 1657 | + if (k == '>') ::viewFrustumOffsetDistance += 0.5; | |
| 1658 | + if (k == ',') ::viewFrustumOffsetUp -= 0.05; | |
| 1659 | + if (k == '.') ::viewFrustumOffsetUp += 0.05; | |
| 1599 | 1660 | |
| 1600 | −// if (k == '|') ViewFrustum::fovAngleAdust -= 0.05; | |
| 1601 | −// if (k == '\\') ViewFrustum::fovAngleAdust += 0.05; | |
| 1661 | +// if (k == '|') ViewFrustum::fovAngleAdust -= 0.05; | |
| 1662 | +// if (k == '\\') ViewFrustum::fovAngleAdust += 0.05; | |
| 1602 | 1663 | |
| 1603 | − if (k == 'R') setFrustumRenderMode(MENU_ROW_PICKED); | |
| 1664 | + if (k == 'R') setFrustumRenderMode(MENU_ROW_PICKED); | |
| 1604 | 1665 | |
| 1605 | 1666 | if (k == '&') { |
| 1606 | − ::paintOn = !::paintOn; // toggle paint | |
| 1607 | − ::setupPaintingVoxel(); // also randomizes colors | |
| 1667 | + ::paintOn = !::paintOn; // toggle paint | |
| 1668 | + ::setupPaintingVoxel(); // also randomizes colors | |
| 1608 | 1669 | } |
| 1609 | − if (k == '^') ::shiftPaintingColor(); // shifts randomize color between R,G,B dominant | |
| 1610 | − if (k == '-') ::sendVoxelServerEraseAll(); // sends erase all command to voxel server | |
| 1611 | − if (k == '%') ::sendVoxelServerAddScene(); // sends add scene command to voxel server | |
| 1612 | − if (k == 'n' || k == 'N') | |
| 1670 | + if (k == '^') ::shiftPaintingColor(); // shifts randomize color between R,G,B dominant | |
| 1671 | + if (k == '-') ::sendVoxelServerEraseAll(); // sends erase all command to voxel server | |
| 1672 | + if (k == '%') ::sendVoxelServerAddScene(); // sends add scene command to voxel server | |
| 1673 | + if (k == '1') ::addVoxelUnderCursor(); | |
| 1674 | + if (k == '2') ::deleteVoxelUnderCursor(); | |
| 1675 | + if (k == 'n' || k == 'N') | |
| 1613 | 1676 | { |
| 1614 | 1677 | noiseOn = !noiseOn; // Toggle noise |
| 1615 | 1678 | if (noiseOn) |
| @@ -1703,23 +1766,21 @@ void idle(void) { · 87 unmodified lines | ||
| 1703 | 1766 | // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time |
| 1704 | 1767 | |
| 1705 | 1768 | if (diffclock(&lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) { |
| 1706 | − | |
| 1769 | + | |
| 1707 | 1770 | float deltaTime = 1.f/FPS; |
| 1708 | 1771 | |
| 1709 | 1772 | // update behaviors for avatar hand movement: handControl takes mouse values as input, |
| 1710 | 1773 | // and gives back 3D values modulated for smooth transitioning between interaction modes. |
| 1711 | 1774 | handControl.update(mouseX, mouseY); |
| 1712 | − myAvatar.setHandMovementValues(handControl.getValues()); | |
| 1775 | + myAvatar.setHandMovementValues(handControl.getValues()); | |
| 1713 | 1776 | |
| 1714 | − // tell my avatar if the mouse is being pressed... | |
| 1715 | − if (mousePressed) { | |
| 1716 | − myAvatar.setMousePressed(mousePressed); | |
| 1717 | − } | |
| 1777 | + // tell my avatar if the mouse is being pressed... | |
| 1778 | + myAvatar.setMousePressed(mousePressed); | |
| 1718 | 1779 | |
| 1719 | 1780 | // walking triggers the handControl to stop |
| 1720 | 1781 | if (myAvatar.getMode() == AVATAR_MODE_WALKING) { |
| 1721 | 1782 | handControl.stop(); |
| 1722 | − } | |
| 1783 | + } | |
| 1723 | 1784 | |
| 1724 | 1785 | // Read serial port interface devices |
| 1725 | 1786 | if (serialPort.active && USING_INVENSENSE_MPU9150) { |
| @@ -1732,8 +1793,8 @@ void idle(void) { · 6 unmodified lines | ||
| 1732 | 1793 | // read incoming packets from network |
| 1733 | 1794 | if (!enableNetworkThread) { |
| 1734 | 1795 | networkReceive(0); |
| 1735 | − } | |
| 1736 | − | |
| 1796 | + } | |
| 1797 | + | |
| 1737 | 1798 | //loop through all the remote avatars and simulate them... |
| 1738 | 1799 | AgentList* agentList = AgentList::getInstance(); |
| 1739 | 1800 | agentList->lock(); |
| @@ -1834,29 +1895,30 @@ glm::vec3 getGravity(glm::vec3 pos) { · 94 unmodified lines | ||
| 1834 | 1895 | } |
| 1835 | 1896 | |
| 1836 | 1897 | void mouseFunc(int button, int state, int x, int y) { |
| 1837 | − if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { | |
| 1838 | − if (state == GLUT_DOWN && !menu.mouseClick(x, y)) { | |
| 1839 | − mouseX = x; | |
| 1840 | − mouseY = y; | |
| 1841 | − mousePressed = 1; | |
| 1842 | − } else if (state == GLUT_UP) { | |
| 1898 | + if ( !menu.mouseClick(x, y)) { // if a menu item was not clicked or unclicked... | |
| 1899 | + if ( button == GLUT_LEFT_BUTTON ) { | |
| 1843 | 1900 | mouseX = x; |
| 1844 | 1901 | mouseY = y; |
| 1845 | − mousePressed = 0; | |
| 1902 | + if (state == GLUT_DOWN ) { | |
| 1903 | + mousePressed = 1; | |
| 1904 | + } else if (state == GLUT_UP ) { | |
| 1905 | + mousePressed = 0; | |
| 1906 | + } | |
| 1846 | 1907 | } |
| 1847 | − } | |
| 1908 | + } | |
| 1848 | 1909 | } |
| 1849 | 1910 | |
| 1911 | + | |
| 1850 | 1912 | void motionFunc(int x, int y) { |
| 1851 | − mouseX = x; | |
| 1852 | − mouseY = y; | |
| 1913 | + mouseX = x; | |
| 1914 | + mouseY = y; | |
| 1853 | 1915 | } |
| 1854 | 1916 | |
| 1855 | 1917 | void mouseoverFunc(int x, int y){ |
| 1856 | 1918 | menu.mouseOver(x, y); |
| 1857 | 1919 | |
| 1858 | − mouseX = x; | |
| 1859 | − mouseY = y; | |
| 1920 | + mouseX = x; | |
| 1921 | + mouseY = y; | |
| 1860 | 1922 | } |
| 1861 | 1923 | |
| 1862 | 1924 | void attachNewHeadToAgent(Agent *newAgent) { |
| @@ -1892,14 +1954,14 @@ int main(int argc, const char * argv[]) { · 29 unmodified lines | ||
| 1892 | 1954 | gettimeofday(&applicationStartupTime, NULL); |
| 1893 | 1955 | const char* domainIP = getCmdOption(argc, argv, "--domain"); |
| 1894 | 1956 | if (domainIP) { |
| 1895 | − strcpy(DOMAIN_IP,domainIP); | |
| 1896 | − } | |
| 1957 | + strcpy(DOMAIN_IP,domainIP); | |
| 1958 | + } | |
| 1897 | 1959 | |
| 1898 | 1960 | // Handle Local Domain testing with the --local command line |
| 1899 | 1961 | if (cmdOptionExists(argc, argv, "--local")) { |
| 1900 | − printLog("Local Domain MODE!\n"); | |
| 1901 | − int ip = getLocalAddress(); | |
| 1902 | − sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF)); | |
| 1962 | + printLog("Local Domain MODE!\n"); | |
| 1963 | + int ip = getLocalAddress(); | |
| 1964 | + sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF)); | |
| 1903 | 1965 | } |
| 1904 | 1966 | |
| 1905 | 1967 | // the callback for our instance of AgentList is attachNewHeadToAgent |
| @@ -1948,30 +2010,30 @@ int main(int argc, const char * argv[]) { · 42 unmodified lines | ||
| 1948 | 2010 | |
| 1949 | 2011 | glutDisplayFunc(display); |
| 1950 | 2012 | glutReshapeFunc(reshape); |
| 1951 | − glutKeyboardFunc(key); | |
| 2013 | + glutKeyboardFunc(key); | |
| 1952 | 2014 | glutKeyboardUpFunc(keyUp); |
| 1953 | 2015 | glutSpecialFunc(specialkey); |
| 1954 | 2016 | glutSpecialUpFunc(specialkeyUp); |
| 1955 | − glutMotionFunc(motionFunc); | |
| 2017 | + glutMotionFunc(motionFunc); | |
| 1956 | 2018 | glutPassiveMotionFunc(mouseoverFunc); |
| 1957 | − glutMouseFunc(mouseFunc); | |
| 2019 | + glutMouseFunc(mouseFunc); | |
| 1958 | 2020 | glutIdleFunc(idle); |
| 1959 | − | |
| 2021 | + | |
| 1960 | 2022 | init(); |
| 1961 | 2023 | printLog( "Init() complete.\n" ); |
| 1962 | 2024 | |
| 1963 | − // Check to see if the user passed in a command line option for randomizing colors | |
| 1964 | − if (cmdOptionExists(argc, argv, "--NoColorRandomizer")) { | |
| 1965 | − wantColorRandomizer = false; | |
| 1966 | − } | |
| 1967 | − | |
| 1968 | − // Check to see if the user passed in a command line option for loading a local | |
| 1969 | − // Voxel File. If so, load it now. | |
| 2025 | + // Check to see if the user passed in a command line option for randomizing colors | |
| 2026 | + if (cmdOptionExists(argc, argv, "--NoColorRandomizer")) { | |
| 2027 | + wantColorRandomizer = false; | |
| 2028 | + } | |
| 2029 | + | |
| 2030 | + // Check to see if the user passed in a command line option for loading a local | |
| 2031 | + // Voxel File. If so, load it now. | |
| 1970 | 2032 | const char* voxelsFilename = getCmdOption(argc, argv, "-i"); |
| 1971 | 2033 | if (voxelsFilename) { |
| 1972 | − voxels.loadVoxelsFile(voxelsFilename,wantColorRandomizer); | |
| 2034 | + voxels.loadVoxelsFile(voxelsFilename,wantColorRandomizer); | |
| 1973 | 2035 | printLog("Local Voxel File loaded.\n"); |
| 1974 | − } | |
| 2036 | + } | |
| 1975 | 2037 | |
| 1976 | 2038 | // create thread for receipt of data via UDP |
| 1977 | 2039 | if (enableNetworkThread) { |