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