Showing the changes to interface/src/main.cpp (1 of 9 files). Show all
Unified · Split
| @@ -99,7 +99,7 @@ bool wantColorRandomizer = true; // for addSphere and load file · 98 unmodified lines | |||
| 99 | 99 | ||
| 100 | Oscilloscope audioScope(256,200,true); | 100 | Oscilloscope audioScope(256,200,true); |
| 101 | 101 | ||
| 102 | Head myHead; // The rendered head of oneself | 102 | Head myAvatar; // The rendered avatar of oneself |
| 103 | Camera myCamera; // My view onto the world (sometimes on myself :) | 103 | Camera myCamera; // My view onto the world (sometimes on myself :) |
| 104 | 104 | ||
| 105 | // Starfield information | 105 | // Starfield information |
| @@ -123,7 +123,7 @@ ParticleSystem balls(0, · 17 unmodified lines | |||
| 123 | 0.0 // Gravity | 123 | 0.0 // Gravity |
| 124 | ); | 124 | ); |
| 125 | 125 | ||
| 126 | Cloud cloud(0, // Particles | 126 | Cloud cloud(0, // Particles |
| 127 | box, // Bounding Box | 127 | box, // Bounding Box |
| 128 | false // Wrap | 128 | false // Wrap |
| 129 | ); | 129 | ); |
| @@ -135,7 +135,7 @@ Finger myFinger(WIDTH, HEIGHT); · 5 unmodified lines | |||
| 135 | Field field; | 135 | Field field; |
| 136 | 136 | ||
| 137 | #ifndef _WIN32 | 137 | #ifndef _WIN32 |
| 138 | Audio audio(&audioScope, &myHead); | 138 | Audio audio(&audioScope, &myAvatar); |
| 139 | #endif | 139 | #endif |
| 140 | 140 | ||
| 141 | #define IDLE_SIMULATE_MSECS 8 // How often should call simulate and other stuff | 141 | #define IDLE_SIMULATE_MSECS 8 // How often should call simulate and other stuff |
| @@ -157,6 +157,13 @@ bool paintOn = false; // Whether to paint voxels as you fly around · 15 unmodified lines | |||
| 157 | VoxelDetail paintingVoxel; // The voxel we're painting if we're painting | 157 | VoxelDetail paintingVoxel; // The voxel we're painting if we're painting |
| 158 | unsigned char dominantColor = 0; // The dominant color of the voxel we're painting | 158 | unsigned char dominantColor = 0; // The dominant color of the voxel we're painting |
| 159 | bool perfStatsOn = false; // Do we want to display perfStats? | 159 | bool perfStatsOn = false; // Do we want to display perfStats? |
| 160 | bool frustumOn = false; // Whether or not to display the debug view frustum | ||
| 161 | |||
| 162 | bool viewFrustumFromOffset=false; // Wether or not to offset the view of the frustum | ||
| 163 | float viewFrustumOffsetYaw = -90.0; | ||
| 164 | float viewFrustumOffsetPitch = 7.5; | ||
| 165 | float viewFrustumOffsetRoll = 0.0; | ||
| 166 | |||
| 160 | int noiseOn = 0; // Whether to add random noise | 167 | int noiseOn = 0; // Whether to add random noise |
| 161 | float noise = 1.0; // Overall magnitude scaling for random noise levels | 168 | float noise = 1.0; // Overall magnitude scaling for random noise levels |
| 162 | 169 | ||
| @@ -182,10 +189,8 @@ SerialInterface serialPort; · 19 unmodified lines | |||
| 182 | int latency_display = 1; | 189 | int latency_display = 1; |
| 183 | 190 | ||
| 184 | glm::vec3 gravity; | 191 | glm::vec3 gravity; |
| 185 | int first_measurement = 1; | ||
| 186 | //int samplecount = 0; | ||
| 187 | 192 | ||
| 188 | // Frame rate Measurement | 193 | // Frame Rate Measurement |
| 189 | 194 | ||
| 190 | int frameCount = 0; | 195 | int frameCount = 0; |
| 191 | float FPS = 120.f; | 196 | float FPS = 120.f; |
| @@ -193,12 +198,6 @@ timeval timerStart, timerEnd; · 1 unmodified line | |||
| 193 | timeval lastTimeIdle; | 198 | timeval lastTimeIdle; |
| 194 | double elapsedTime; | 199 | double elapsedTime; |
| 195 | 200 | ||
| 196 | // Particles | ||
| 197 | |||
| 198 | |||
| 199 | float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles | ||
| 200 | float pointer_attenuation_quadratic[] = { 1.0f, 0.0f, 0.0f }; // for 2D view | ||
| 201 | |||
| 202 | #ifdef MARKER_CAPTURE | 201 | #ifdef MARKER_CAPTURE |
| 203 | 202 | ||
| 204 | /*** Marker Capture ***/ | 203 | /*** Marker Capture ***/ |
| @@ -250,11 +249,11 @@ void displayStats(void) · 45 unmodified lines | |||
| 250 | char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; | 249 | char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; |
| 251 | drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2); | 250 | drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2); |
| 252 | 251 | ||
| 253 | glm::vec3 headPos = myHead.getPos(); | 252 | glm::vec3 avatarPos = myAvatar.getPos(); |
| 254 | 253 | ||
| 255 | char stats[200]; | 254 | char stats[200]; |
| 256 | sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )", | 255 | sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )", |
| 257 | FPS, packetsPerSecond, bytesPerSecond, headPos.x,headPos.y,headPos.z); | 256 | FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z); |
| 258 | drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats); | 257 | drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats); |
| 259 | if (serialPort.active) { | 258 | if (serialPort.active) { |
| 260 | sprintf(stats, "ADC samples = %d, LED = %d", | 259 | sprintf(stats, "ADC samples = %d, LED = %d", |
| @@ -262,14 +261,6 @@ void displayStats(void) · 1 unmodified line | |||
| 262 | drawtext(300, statsVerticalOffset + 30, 0.10f, 0, 1.0, 0, stats); | 261 | drawtext(300, statsVerticalOffset + 30, 0.10f, 0, 1.0, 0, stats); |
| 263 | } | 262 | } |
| 264 | 263 | ||
| 265 | // Output the ping times to the various agents | ||
| 266 | // std::stringstream pingTimes; | ||
| 267 | // pingTimes << "Agent Pings, msecs:"; | ||
| 268 | // for (int i = 0; i < getAgentCount(); i++) { | ||
| 269 | // pingTimes << " " << getAgentAddress(i) << ": " << getAgentPing(i); | ||
| 270 | // } | ||
| 271 | // drawtext(10,50,0.10, 0, 1.0, 0, (char *)pingTimes.str().c_str()); | ||
| 272 | |||
| 273 | std::stringstream voxelStats; | 264 | std::stringstream voxelStats; |
| 274 | voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); | 265 | voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); |
| 275 | drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | 266 | drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| @@ -330,8 +321,8 @@ void initDisplay(void) · 54 unmodified lines | |||
| 330 | void init(void) | 321 | void init(void) |
| 331 | { | 322 | { |
| 332 | voxels.init(); | 323 | voxels.init(); |
| 333 | voxels.setViewerHead(&myHead); | 324 | voxels.setViewerHead(&myAvatar); |
| 334 | myHead.setRenderYaw(startYaw); | 325 | myAvatar.setRenderYaw(startYaw); |
| 335 | 326 | ||
| 336 | headMouseX = WIDTH/2; | 327 | headMouseX = WIDTH/2; |
| 337 | headMouseY = HEIGHT/2; | 328 | headMouseY = HEIGHT/2; |
| @@ -342,9 +333,9 @@ void init(void) · 4 unmodified lines | |||
| 342 | field = Field(); | 333 | field = Field(); |
| 343 | 334 | ||
| 344 | if (noiseOn) { | 335 | if (noiseOn) { |
| 345 | myHead.setNoise(noise); | 336 | myAvatar.setNoise(noise); |
| 346 | } | 337 | } |
| 347 | myHead.setPos(start_location ); | 338 | myAvatar.setPos(start_location ); |
| 348 | myCamera.setPosition( start_location ); | 339 | myCamera.setPosition( start_location ); |
| 349 | 340 | ||
| 350 | #ifdef MARKER_CAPTURE | 341 | #ifdef MARKER_CAPTURE |
| @@ -381,15 +372,15 @@ void reset_sensors() · 30 unmodified lines | |||
| 381 | // | 372 | // |
| 382 | // Reset serial I/O sensors | 373 | // Reset serial I/O sensors |
| 383 | // | 374 | // |
| 384 | myHead.setRenderYaw(startYaw); | 375 | myAvatar.setRenderYaw(startYaw); |
| 385 | 376 | ||
| 386 | yaw = renderYawRate = 0; | 377 | yaw = renderYawRate = 0; |
| 387 | pitch = renderPitch = renderPitchRate = 0; | 378 | pitch = renderPitch = renderPitchRate = 0; |
| 388 | myHead.setPos(start_location); | 379 | myAvatar.setPos(start_location); |
| 389 | headMouseX = WIDTH/2; | 380 | headMouseX = WIDTH/2; |
| 390 | headMouseY = HEIGHT/2; | 381 | headMouseY = HEIGHT/2; |
| 391 | 382 | ||
| 392 | myHead.reset(); | 383 | myAvatar.reset(); |
| 393 | 384 | ||
| 394 | if (serialPort.active) { | 385 | if (serialPort.active) { |
| 395 | serialPort.resetTrailingAverages(); | 386 | serialPort.resetTrailingAverages(); |
| @@ -405,7 +396,7 @@ void simulateHand(float deltaTime) { · 9 unmodified lines | |||
| 405 | float dx = mouseX - mouseStartX; | 396 | float dx = mouseX - mouseStartX; |
| 406 | float dy = mouseY - mouseStartY; | 397 | float dy = mouseY - mouseStartY; |
| 407 | glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0); | 398 | glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0); |
| 408 | myHead.hand->addVelocity(vel*deltaTime); | 399 | myAvatar.hand->addVelocity(vel*deltaTime); |
| 409 | } | 400 | } |
| 410 | } | 401 | } |
| 411 | 402 | ||
| @@ -421,12 +412,12 @@ void simulateHead(float frametime) · 9 unmodified lines | |||
| 421 | //float measured_lateral_accel = serialPort.getRelativeValue(ACCEL_X); | 412 | //float measured_lateral_accel = serialPort.getRelativeValue(ACCEL_X); |
| 422 | //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z); | 413 | //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z); |
| 423 | 414 | ||
| 424 | myHead.UpdatePos(frametime, &serialPort, headMirror, &gravity); | 415 | myAvatar.UpdatePos(frametime, &serialPort, headMirror, &gravity); |
| 425 | 416 | ||
| 426 | //------------------------------------------------------------------------------------- | 417 | //------------------------------------------------------------------------------------- |
| 427 | // set the position of the avatar | 418 | // set the position of the avatar |
| 428 | //------------------------------------------------------------------------------------- | 419 | //------------------------------------------------------------------------------------- |
| 429 | myHead.setAvatarPosition( -myHead.getPos().x, -myHead.getPos().y, -myHead.getPos().z ); | 420 | myAvatar.setAvatarPosition( -myAvatar.getPos().x, -myAvatar.getPos().y, -myAvatar.getPos().z ); |
| 430 | 421 | ||
| 431 | // Update head_mouse model | 422 | // Update head_mouse model |
| 432 | const float MIN_MOUSE_RATE = 30.0; | 423 | const float MIN_MOUSE_RATE = 30.0; |
| @@ -451,8 +442,8 @@ void simulateHead(float frametime) · 18 unmodified lines | |||
| 451 | 442 | ||
| 452 | // Update render pitch and yaw rates based on keyPositions | 443 | // Update render pitch and yaw rates based on keyPositions |
| 453 | const float KEY_YAW_SENSITIVITY = 2.0; | 444 | const float KEY_YAW_SENSITIVITY = 2.0; |
| 454 | if (myHead.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime; | 445 | if (myAvatar.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime; |
| 455 | if (myHead.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime; | 446 | if (myAvatar.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime; |
| 456 | 447 | ||
| 457 | if (fabs(measured_yaw_rate) > MIN_YAW_RATE) | 448 | if (fabs(measured_yaw_rate) > MIN_YAW_RATE) |
| 458 | { | 449 | { |
| @@ -479,32 +470,32 @@ void simulateHead(float frametime) · 20 unmodified lines | |||
| 479 | renderYawRate *= (1.f - 7.0*frametime); | 470 | renderYawRate *= (1.f - 7.0*frametime); |
| 480 | 471 | ||
| 481 | // Update own head data | 472 | // Update own head data |
| 482 | myHead.setRenderYaw(myHead.getRenderYaw() + renderYawRate); | 473 | myAvatar.setRenderYaw(myAvatar.getRenderYaw() + renderYawRate); |
| 483 | myHead.setRenderPitch(renderPitch); | 474 | myAvatar.setRenderPitch(renderPitch); |
| 484 | 475 | ||
| 485 | // Get audio loudness data from audio input device | 476 | // Get audio loudness data from audio input device |
| 486 | float loudness, averageLoudness; | 477 | float loudness, averageLoudness; |
| 487 | #ifndef _WIN32 | 478 | #ifndef _WIN32 |
| 488 | audio.getInputLoudness(&loudness, &averageLoudness); | 479 | audio.getInputLoudness(&loudness, &averageLoudness); |
| 489 | myHead.setLoudness(loudness); | 480 | myAvatar.setLoudness(loudness); |
| 490 | myHead.setAverageLoudness(averageLoudness); | 481 | myAvatar.setAverageLoudness(averageLoudness); |
| 491 | #endif | 482 | #endif |
| 492 | 483 | ||
| 493 | // Send my streaming head data to agents that are nearby and need to see it! | 484 | // Send my streaming head data to agents that are nearby and need to see it! |
| 494 | const int MAX_BROADCAST_STRING = 200; | 485 | const int MAX_BROADCAST_STRING = 200; |
| 495 | char broadcast_string[MAX_BROADCAST_STRING]; | 486 | char broadcast_string[MAX_BROADCAST_STRING]; |
| 496 | int broadcast_bytes = myHead.getBroadcastData(broadcast_string); | 487 | int broadcast_bytes = myAvatar.getBroadcastData(broadcast_string); |
| 497 | agentList.broadcastToAgents(broadcast_string, broadcast_bytes,AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE); | 488 | agentList.broadcastToAgents(broadcast_string, broadcast_bytes,AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE); |
| 498 | 489 | ||
| 499 | // If I'm in paint mode, send a voxel out to VOXEL server agents. | 490 | // If I'm in paint mode, send a voxel out to VOXEL server agents. |
| 500 | if (::paintOn) { | 491 | if (::paintOn) { |
| 501 | 492 | ||
| 502 | glm::vec3 headPos = myHead.getPos(); | 493 | glm::vec3 avatarPos = myAvatar.getPos(); |
| 503 | 494 | ||
| 504 | // For some reason, we don't want to flip X and Z here. | 495 | // For some reason, we don't want to flip X and Z here. |
| 505 | ::paintingVoxel.x = headPos.x/-10.0; | 496 | ::paintingVoxel.x = avatarPos.x/-10.0; |
| 506 | ::paintingVoxel.y = headPos.y/-10.0; | 497 | ::paintingVoxel.y = avatarPos.y/-10.0; |
| 507 | ::paintingVoxel.z = headPos.z/-10.0; | 498 | ::paintingVoxel.z = avatarPos.z/-10.0; |
| 508 | 499 | ||
| 509 | unsigned char* bufferOut; | 500 | unsigned char* bufferOut; |
| 510 | int sizeOut; | 501 | int sizeOut; |
| @@ -521,6 +512,9 @@ void simulateHead(float frametime) · 10 unmodified lines | |||
| 521 | } | 512 | } |
| 522 | } | 513 | } |
| 523 | 514 | ||
| 515 | |||
| 516 | |||
| 517 | |||
| 524 | // XXXBHG - this code is not yet working. This is here to help Jeffery debug getAvatarHeadLookatDirection() | 518 | // XXXBHG - this code is not yet working. This is here to help Jeffery debug getAvatarHeadLookatDirection() |
| 525 | // The code will draw a yellow line from the avatar's position to the origin, | 519 | // The code will draw a yellow line from the avatar's position to the origin, |
| 526 | // It also attempts to draw a cyan line from the avatar to 2 meters in front of the avatar in the direction | 520 | // It also attempts to draw a cyan line from the avatar to 2 meters in front of the avatar in the direction |
| @@ -538,117 +532,105 @@ void render_view_frustum() { · 11 unmodified lines | |||
| 538 | // farDist – the distance from the camera to the far plane | 532 | // farDist – the distance from the camera to the far plane |
| 539 | // farHeight – the height of the far plane | 533 | // farHeight – the height of the far plane |
| 540 | // farWidth – the width of the far plane | 534 | // farWidth – the width of the far plane |
| 541 | |||
| 542 | glm::vec3 cameraPosition = ::myHead.getPos()*-1.0; // We need to flip the sign to make this work. | ||
| 543 | glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! | ||
| 544 | 535 | ||
| 545 | // this is a temporary test, create a vertice that's 2 meters in front of avatar in direction their looking | 536 | glm::vec3 viewFrustumPosition = myAvatar.getHeadPosition(); |
| 546 | glm::vec3 lookingAt = cameraPosition+(cameraDirection*2.0); | 537 | glm::vec3 viewFrustumDirection = myAvatar.getHeadLookatDirection(); |
| 547 | 538 | ||
| 548 | // Some debug lines. | 539 | glm::vec3 up = myAvatar.getHeadLookatDirectionUp(); |
| 549 | glDisable(GL_LIGHTING); | 540 | glm::vec3 right = myAvatar.getHeadLookatDirectionRight(); |
| 550 | glColor4f(1.0, 1.0, 1.0, 1.0); | 541 | |
| 551 | glLineWidth(1.0); | 542 | // what? this are negative?? GRRRR!!! |
| 552 | glBegin(GL_LINES); | 543 | float nearDist = -0.1; |
| 553 | 544 | float farDist = -1.0; | |
| 554 | // line from avatar to the origin -- this one is working. | ||
| 555 | glColor3f(1,1,0); | ||
| 556 | glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); | ||
| 557 | glVertex3f(0,0,0); | ||
| 558 | |||
| 559 | // line from avatar to 2 meters in front of avatar -- this is NOT working | ||
| 560 | glColor3f(0,1,1); | ||
| 561 | glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); | ||
| 562 | glVertex3f(lookingAt.x,lookingAt.y,lookingAt.z); | ||
| 563 | |||
| 564 | /* | ||
| 565 | // Not yet ready for this... | ||
| 566 | glm::vec3 up = glm::vec3(0.0,1.0,0.0); | ||
| 567 | glm::vec3 right = glm::vec3(1.0,0.0,0.0); | ||
| 568 | float nearDist = 0.1; | ||
| 569 | float farDist = 500.0; | ||
| 570 | float fov = (0.7854f*2.0); // 45 deg * 2 = 90 deg | ||
| 571 | 545 | ||
| 572 | float screenWidth = 800.0; // hack! We need to make this eventually be the correct height/width | 546 | float fovHalfAngle = 0.7854f; // 45 deg for half, so fov = 90 deg |
| 573 | float screenHeight = 600.0; | 547 | |
| 548 | float screenWidth = ::WIDTH; // These values come from reshape() | ||
| 549 | float screenHeight = ::HEIGHT; | ||
| 574 | float ratio = screenWidth/screenHeight; | 550 | float ratio = screenWidth/screenHeight; |
| 575 | float nearHeight = 2 * tan(fov / 2) * nearDist; | 551 | |
| 552 | float nearHeight = 2 * tan(fovHalfAngle) * nearDist; | ||
| 576 | float nearWidth = nearHeight * ratio; | 553 | float nearWidth = nearHeight * ratio; |
| 577 | float farHeight = 2 * tan(fov / 2) * farDist; | 554 | float farHeight = 2 * tan(fovHalfAngle) * farDist; |
| 578 | float farWidth = farHeight * ratio; | 555 | float farWidth = farHeight * ratio; |
| 579 | 556 | ||
| 580 | glm::vec3 farCenter = cameraPosition+cameraDirection*farDist; | 557 | glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist; |
| 581 | glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5); | 558 | glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5); |
| 582 | glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5); | 559 | glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5); |
| 583 | glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5); | 560 | glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5); |
| 584 | glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5); | 561 | glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5); |
| 585 | 562 | ||
| 586 | glm::vec3 nearCenter = cameraPosition+cameraDirection*nearDist; | 563 | glm::vec3 nearCenter = viewFrustumPosition+viewFrustumDirection*nearDist; |
| 587 | glm::vec3 nearTopLeft = nearCenter + (up*nearHeight*0.5) - (right*nearWidth*0.5); | 564 | glm::vec3 nearTopLeft = nearCenter + (up*nearHeight*0.5) - (right*nearWidth*0.5); |
| 588 | glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); | 565 | glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); |
| 589 | glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); | 566 | glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); |
| 590 | glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); | 567 | glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); |
| 591 | */ | ||
| 592 | |||
| 593 | 568 | ||
| 594 | /* | 569 | // Get ready to draw some lines |
| 595 | glColor3f(1,1,1); | 570 | glDisable(GL_LIGHTING); |
| 571 | glColor4f(1.0, 1.0, 1.0, 1.0); | ||
| 572 | glLineWidth(1.0); | ||
| 573 | glBegin(GL_LINES); | ||
| 596 | 574 | ||
| 597 | // near plane - bottom edge | 575 | // near plane - bottom edge |
| 598 | glVertex3f(low.x,low.y,low.z); | 576 | glColor3f(1,0,0); |
| 599 | glVertex3f(high.x,low.y,low.z); | 577 | glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); |
| 578 | glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); | ||
| 600 | 579 | ||
| 601 | // near plane - top edge | 580 | // near plane - top edge |
| 602 | glVertex3f(low.x,high.y,low.z); | 581 | glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); |
| 603 | glVertex3f(high.x,high.y,low.z); | 582 | glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); |
| 604 | 583 | ||
| 605 | // near plane - right edge | 584 | // near plane - right edge |
| 606 | glVertex3f(low.x,high.y,low.z); | 585 | glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); |
| 607 | glVertex3f(low.x,low.y,low.z); | 586 | glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); |
| 608 | 587 | ||
| 609 | // near plane - left edge | 588 | // near plane - left edge |
| 610 | glVertex3f(high.x,high.y,low.z); | 589 | glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); |
| 611 | glVertex3f(high.x,low.y,low.z); | 590 | glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); |
| 612 | 591 | ||
| 613 | // far plane - bottom edge | 592 | // far plane - bottom edge |
| 614 | glVertex3f(low.x,low.y,high.z); | 593 | glColor3f(0,1,0); // GREEN!!! |
| 615 | glVertex3f(high.x,low.y,high.z); | 594 | glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); |
| 616 | 595 | glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); | |
| 596 | |||
| 617 | // far plane - top edge | 597 | // far plane - top edge |
| 618 | glVertex3f(low.x,high.y,high.z); | 598 | glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); |
| 619 | glVertex3f(high.x,high.y,high.z); | 599 | glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); |
| 620 | 600 | ||
| 621 | // far plane - right edge | 601 | // far plane - right edge |
| 622 | glVertex3f(low.x,high.y,high.z); | 602 | glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); |
| 623 | glVertex3f(low.x,low.y,high.z); | 603 | glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); |
| 624 | 604 | ||
| 625 | // far plane - left edge | 605 | // far plane - left edge |
| 626 | glVertex3f(high.x,high.y,high.z); | 606 | glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); |
| 627 | glVertex3f(high.x,low.y,high.z); | 607 | glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); |
| 628 | 608 | ||
| 629 | // right plane - bottom edge - near to distant | 609 | // right plane - bottom edge - near to distant |
| 630 | glVertex3f(low.x,low.y,low.z); | 610 | glColor3f(0,0,1); |
| 631 | glVertex3f(low.x,low.y,high.z); | 611 | glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); |
| 612 | glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); | ||
| 632 | 613 | ||
| 633 | // right plane - top edge - near to distant | 614 | // right plane - top edge - near to distant |
| 634 | glVertex3f(low.x,high.y,low.z); | 615 | glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); |
| 635 | glVertex3f(low.x,high.y,high.z); | 616 | glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); |
| 636 | 617 | ||
| 637 | // left plane - bottom edge - near to distant | 618 | // left plane - bottom edge - near to distant |
| 638 | glVertex3f(high.x,low.y,low.z); | 619 | glColor3f(0,1,1); |
| 639 | glVertex3f(high.x,low.y,high.z); | 620 | glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); |
| 621 | glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); | ||
| 640 | 622 | ||
| 641 | // left plane - top edge - near to distant | 623 | // left plane - top edge - near to distant |
| 642 | glVertex3f(high.x,high.y,low.z); | 624 | glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); |
| 643 | glVertex3f(high.x,high.y,high.z); | 625 | glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); |
| 644 | */ | 626 | |
| 645 | glEnd(); | 627 | glEnd(); |
| 646 | } | 628 | } |
| 647 | 629 | ||
| 648 | 630 | ||
| 649 | void display(void) | 631 | void display(void) |
| 650 | { | 632 | { |
| 651 | //printf( "avatar head lookat = %f, %f, %f\n", myHead.getAvatarHeadLookatDirection().x, myHead.getAvatarHeadLookatDirection().y, myHead.getAvatarHeadLookatDirection().z ); | 633 | //printf( "avatar head lookat = %f, %f, %f\n", myAvatar.getAvatarHeadLookatDirection().x, myAvatar.getAvatarHeadLookatDirection().y, myAvatar.getAvatarHeadLookatDirection().z ); |
| 652 | 634 | ||
| 653 | PerfStat("display"); | 635 | PerfStat("display"); |
| 654 | 636 | ||
| @@ -678,33 +660,42 @@ void display(void) · 23 unmodified lines | |||
| 678 | //-------------------------------------------------------- | 660 | //-------------------------------------------------------- |
| 679 | // camera settings | 661 | // camera settings |
| 680 | //-------------------------------------------------------- | 662 | //-------------------------------------------------------- |
| 681 | myCamera.setTargetPosition( myHead.getPos() ); | 663 | myCamera.setTargetPosition( myAvatar.getPos() ); |
| 682 | 664 | ||
| 683 | if ( displayHead ) | 665 | if ( displayHead ) { |
| 684 | { | ||
| 685 | //----------------------------------------------- | 666 | //----------------------------------------------- |
| 686 | // set the camera to looking at my own face | 667 | // set the camera to looking at my own face |
| 687 | //----------------------------------------------- | 668 | //----------------------------------------------- |
| 688 | myCamera.setYaw ( - myHead.getAvatarYaw() ); | 669 | myCamera.setYaw ( - myAvatar.getBodyYaw() ); |
| 689 | myCamera.setPitch ( 0.0 ); | 670 | myCamera.setPitch ( 0.0 ); |
| 690 | myCamera.setRoll ( 0.0 ); | 671 | myCamera.setRoll ( 0.0 ); |
| 691 | myCamera.setUp ( 0.4 ); | 672 | myCamera.setUp ( 0.4 ); |
| 692 | myCamera.setDistance( 0.5 ); | 673 | myCamera.setDistance( 0.5 ); |
| 693 | myCamera.setDistance( 0.08 ); | 674 | myCamera.setDistance( 0.08 ); |
| 694 | myCamera.update(); | 675 | myCamera.update(); |
| 695 | } | 676 | } else { |
| 696 | else | 677 | if (::viewFrustumFromOffset && ::frustumOn) { |
| 697 | { | 678 | //---------------------------------------------------- |
| 698 | //---------------------------------------------------- | 679 | // set the camera to third-person view but offset so we can see the frustum |
| 699 | // set the camera to third-person view behind my av | 680 | //---------------------------------------------------- |
| 700 | //---------------------------------------------------- | 681 | myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw ); |
| 701 | myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() ); | 682 | myCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch ); |
| 702 | myCamera.setPitch ( 0.0 ); | 683 | myCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll ); |
| 703 | myCamera.setRoll ( 0.0 ); | 684 | myCamera.setUp ( 0.2 + 0.2 ); |
| 704 | myCamera.setUp ( 0.2 ); | 685 | myCamera.setDistance( 0.5 + 0.2 ); |
| 705 | myCamera.setDistance( 1.6 ); | 686 | myCamera.update(); |
| 706 | myCamera.setDistance( 0.5 ); | 687 | } else { |
| 707 | myCamera.update(); | 688 | //---------------------------------------------------- |
| 689 | // set the camera to third-person view behind my av | ||
| 690 | //---------------------------------------------------- | ||
| 691 | myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); | ||
| 692 | myCamera.setPitch ( 0.0 ); | ||
| 693 | myCamera.setRoll ( 0.0 ); | ||
| 694 | myCamera.setUp ( 0.2 ); | ||
| 695 | myCamera.setDistance( 1.6 ); | ||
| 696 | myCamera.setDistance( 0.5 ); | ||
| 697 | myCamera.update(); | ||
| 698 | } | ||
| 708 | } | 699 | } |
| 709 | 700 | ||
| 710 | //--------------------------------------------- | 701 | //--------------------------------------------- |
| @@ -737,7 +728,7 @@ void display(void) · 26 unmodified lines | |||
| 737 | //--------------------------------------------- | 728 | //--------------------------------------------- |
| 738 | // draw a grid gound plane.... | 729 | // draw a grid gound plane.... |
| 739 | //--------------------------------------------- | 730 | //--------------------------------------------- |
| 740 | //drawGroundPlaneGrid( 5.0f, 9 ); | 731 | drawGroundPlaneGrid( 5.0f, 9 ); |
| 741 | 732 | ||
| 742 | 733 | ||
| 743 | // Draw cloud of dots | 734 | // Draw cloud of dots |
| @@ -754,7 +745,7 @@ void display(void) · 10 unmodified lines | |||
| 754 | // Draw field vectors | 745 | // Draw field vectors |
| 755 | if (displayField) field.render(); | 746 | if (displayField) field.render(); |
| 756 | 747 | ||
| 757 | // Render heads of other agents | 748 | // Render avatars of other agents |
| 758 | for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) | 749 | for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) |
| 759 | { | 750 | { |
| 760 | if (agent->getLinkedData() != NULL) | 751 | if (agent->getLinkedData() != NULL) |
| @@ -774,19 +765,19 @@ void display(void) · 13 unmodified lines | |||
| 774 | if (!displayHead && statsOn) render_world_box(); | 765 | if (!displayHead && statsOn) render_world_box(); |
| 775 | 766 | ||
| 776 | // brad's frustum for debugging | 767 | // brad's frustum for debugging |
| 777 | render_view_frustum(); | 768 | if (::frustumOn) render_view_frustum(); |
| 778 | 769 | ||
| 779 | 770 | ||
| 780 | //--------------------------------- | 771 | //--------------------------------- |
| 781 | // Render my own head | 772 | // Render my own avatar |
| 782 | //--------------------------------- | 773 | //--------------------------------- |
| 783 | myHead.render( true, 1 ); | 774 | myAvatar.render( true, 1 ); |
| 784 | 775 | ||
| 785 | /* | 776 | /* |
| 786 | glPushMatrix(); | 777 | glPushMatrix(); |
| 787 | glLoadIdentity(); | 778 | glLoadIdentity(); |
| 788 | glTranslatef(0.f, 0.f, -7.f); | 779 | glTranslatef(0.f, 0.f, -7.f); |
| 789 | myHead.render(displayHead, 1); | 780 | myAvatar.render(displayHead, 1); |
| 790 | glPopMatrix(); | 781 | glPopMatrix(); |
| 791 | */ | 782 | */ |
| 792 | 783 | ||
| @@ -809,10 +800,6 @@ void display(void) · 16 unmodified lines | |||
| 809 | if (audioScope.getState()) audioScope.render(); | 800 | if (audioScope.getState()) audioScope.render(); |
| 810 | #endif | 801 | #endif |
| 811 | 802 | ||
| 812 | |||
| 813 | //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0); | ||
| 814 | glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); | ||
| 815 | |||
| 816 | if (displayHeadMouse && !displayHead && statsOn) | 803 | if (displayHeadMouse && !displayHead && statsOn) |
| 817 | { | 804 | { |
| 818 | // Display small target box at center or head mouse target that can also be used to measure LOD | 805 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| @@ -890,9 +877,9 @@ int MenuCallBack setField(int state) { · 71 unmodified lines | |||
| 890 | int MenuCallBack setNoise(int state) { | 877 | int MenuCallBack setNoise(int state) { |
| 891 | int iRet = setValue(state, &noiseOn); | 878 | int iRet = setValue(state, &noiseOn); |
| 892 | if (noiseOn) { | 879 | if (noiseOn) { |
| 893 | myHead.setNoise(noise); | 880 | myAvatar.setNoise(noise); |
| 894 | } else { | 881 | } else { |
| 895 | myHead.setNoise(0); | 882 | myAvatar.setNoise(0); |
| 896 | } | 883 | } |
| 897 | return iRet; | 884 | return iRet; |
| 898 | } | 885 | } |
| @@ -966,11 +953,11 @@ void shiftPaintingColor() · 67 unmodified lines | |||
| 966 | 953 | ||
| 967 | void setupPaintingVoxel() | 954 | void setupPaintingVoxel() |
| 968 | { | 955 | { |
| 969 | glm::vec3 headPos = myHead.getPos(); | 956 | glm::vec3 avatarPos = myAvatar.getPos(); |
| 970 | 957 | ||
| 971 | ::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space | 958 | ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space |
| 972 | ::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space | 959 | ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space |
| 973 | ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space | 960 | ::paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space |
| 974 | ::paintingVoxel.s = 1.0/256; | 961 | ::paintingVoxel.s = 1.0/256; |
| 975 | 962 | ||
| 976 | shiftPaintingColor(); | 963 | shiftPaintingColor(); |
| @@ -1002,20 +989,20 @@ const float KEYBOARD_FLY_RATE = 0.08; · 25 unmodified lines | |||
| 1002 | 989 | ||
| 1003 | void specialkeyUp(int k, int x, int y) { | 990 | void specialkeyUp(int k, int x, int y) { |
| 1004 | if (k == GLUT_KEY_UP) { | 991 | if (k == GLUT_KEY_UP) { |
| 1005 | myHead.setDriveKeys(FWD, 0); | 992 | myAvatar.setDriveKeys(FWD, 0); |
| 1006 | myHead.setDriveKeys(UP, 0); | 993 | myAvatar.setDriveKeys(UP, 0); |
| 1007 | } | 994 | } |
| 1008 | if (k == GLUT_KEY_DOWN) { | 995 | if (k == GLUT_KEY_DOWN) { |
| 1009 | myHead.setDriveKeys(BACK, 0); | 996 | myAvatar.setDriveKeys(BACK, 0); |
| 1010 | myHead.setDriveKeys(DOWN, 0); | 997 | myAvatar.setDriveKeys(DOWN, 0); |
| 1011 | } | 998 | } |
| 1012 | if (k == GLUT_KEY_LEFT) { | 999 | if (k == GLUT_KEY_LEFT) { |
| 1013 | myHead.setDriveKeys(LEFT, 0); | 1000 | myAvatar.setDriveKeys(LEFT, 0); |
| 1014 | myHead.setDriveKeys(ROT_LEFT, 0); | 1001 | myAvatar.setDriveKeys(ROT_LEFT, 0); |
| 1015 | } | 1002 | } |
| 1016 | if (k == GLUT_KEY_RIGHT) { | 1003 | if (k == GLUT_KEY_RIGHT) { |
| 1017 | myHead.setDriveKeys(RIGHT, 0); | 1004 | myAvatar.setDriveKeys(RIGHT, 0); |
| 1018 | myHead.setDriveKeys(ROT_RIGHT, 0); | 1005 | myAvatar.setDriveKeys(ROT_RIGHT, 0); |
| 1019 | } | 1006 | } |
| 1020 | 1007 | ||
| 1021 | } | 1008 | } |
| @@ -1024,20 +1011,20 @@ void specialkey(int k, int x, int y) · 2 unmodified lines | |||
| 1024 | { | 1011 | { |
| 1025 | if (k == GLUT_KEY_UP || k == GLUT_KEY_DOWN || k == GLUT_KEY_LEFT || k == GLUT_KEY_RIGHT) { | 1012 | if (k == GLUT_KEY_UP || k == GLUT_KEY_DOWN || k == GLUT_KEY_LEFT || k == GLUT_KEY_RIGHT) { |
| 1026 | if (k == GLUT_KEY_UP) { | 1013 | if (k == GLUT_KEY_UP) { |
| 1027 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(UP, 1); | 1014 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(UP, 1); |
| 1028 | else myHead.setDriveKeys(FWD, 1); | 1015 | else myAvatar.setDriveKeys(FWD, 1); |
| 1029 | } | 1016 | } |
| 1030 | if (k == GLUT_KEY_DOWN) { | 1017 | if (k == GLUT_KEY_DOWN) { |
| 1031 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(DOWN, 1); | 1018 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(DOWN, 1); |
| 1032 | else myHead.setDriveKeys(BACK, 1); | 1019 | else myAvatar.setDriveKeys(BACK, 1); |
| 1033 | } | 1020 | } |
| 1034 | if (k == GLUT_KEY_LEFT) { | 1021 | if (k == GLUT_KEY_LEFT) { |
| 1035 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(LEFT, 1); | 1022 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(LEFT, 1); |
| 1036 | else myHead.setDriveKeys(ROT_LEFT, 1); | 1023 | else myAvatar.setDriveKeys(ROT_LEFT, 1); |
| 1037 | } | 1024 | } |
| 1038 | if (k == GLUT_KEY_RIGHT) { | 1025 | if (k == GLUT_KEY_RIGHT) { |
| 1039 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(RIGHT, 1); | 1026 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(RIGHT, 1); |
| 1040 | else myHead.setDriveKeys(ROT_RIGHT, 1); | 1027 | else myAvatar.setDriveKeys(ROT_RIGHT, 1); |
| 1041 | } | 1028 | } |
| 1042 | #ifndef _WIN32 | 1029 | #ifndef _WIN32 |
| 1043 | audio.setWalkingState(true); | 1030 | audio.setWalkingState(true); |
| @@ -1047,12 +1034,12 @@ void specialkey(int k, int x, int y) · 3 unmodified lines | |||
| 1047 | 1034 | ||
| 1048 | 1035 | ||
| 1049 | void keyUp(unsigned char k, int x, int y) { | 1036 | void keyUp(unsigned char k, int x, int y) { |
| 1050 | if (k == 'e') myHead.setDriveKeys(UP, 0); | 1037 | if (k == 'e') myAvatar.setDriveKeys(UP, 0); |
| 1051 | if (k == 'c') myHead.setDriveKeys(DOWN, 0); | 1038 | if (k == 'c') myAvatar.setDriveKeys(DOWN, 0); |
| 1052 | if (k == 'w') myHead.setDriveKeys(FWD, 0); | 1039 | if (k == 'w') myAvatar.setDriveKeys(FWD, 0); |
| 1053 | if (k == 's') myHead.setDriveKeys(BACK, 0); | 1040 | if (k == 's') myAvatar.setDriveKeys(BACK, 0); |
| 1054 | if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 0); | 1041 | if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 0); |
| 1055 | if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 0); | 1042 | if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 0); |
| 1056 | 1043 | ||
| 1057 | } | 1044 | } |
| 1058 | 1045 | ||
| @@ -1064,6 +1051,16 @@ void key(unsigned char k, int x, int y) · 5 unmodified lines | |||
| 1064 | if (k == '/') statsOn = !statsOn; // toggle stats | 1051 | if (k == '/') statsOn = !statsOn; // toggle stats |
| 1065 | if (k == '*') ::starsOn = !::starsOn; // toggle stars | 1052 | if (k == '*') ::starsOn = !::starsOn; // toggle stars |
| 1066 | if (k == 'V') ::showingVoxels = !::showingVoxels; // toggle voxels | 1053 | if (k == 'V') ::showingVoxels = !::showingVoxels; // toggle voxels |
| 1054 | if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging | ||
| 1055 | if (k == 'G') ::viewFrustumFromOffset = !::viewFrustumFromOffset; // toggle view frustum from offset debugging | ||
| 1056 | |||
| 1057 | if (k == '[') ::viewFrustumOffsetYaw -= 0.5; | ||
| 1058 | if (k == ']') ::viewFrustumOffsetYaw += 0.5; | ||
| 1059 | if (k == '{') ::viewFrustumOffsetPitch -= 0.5; | ||
| 1060 | if (k == '}') ::viewFrustumOffsetPitch += 0.5; | ||
| 1061 | if (k == '(') ::viewFrustumOffsetRoll -= 0.5; | ||
| 1062 | if (k == ')') ::viewFrustumOffsetRoll += 0.5; | ||
| 1063 | |||
| 1067 | if (k == '&') { | 1064 | if (k == '&') { |
| 1068 | ::paintOn = !::paintOn; // toggle paint | 1065 | ::paintOn = !::paintOn; // toggle paint |
| 1069 | ::setupPaintingVoxel(); // also randomizes colors | 1066 | ::setupPaintingVoxel(); // also randomizes colors |
| @@ -1076,11 +1073,11 @@ void key(unsigned char k, int x, int y) · 6 unmodified lines | |||
| 1076 | noiseOn = !noiseOn; // Toggle noise | 1073 | noiseOn = !noiseOn; // Toggle noise |
| 1077 | if (noiseOn) | 1074 | if (noiseOn) |
| 1078 | { | 1075 | { |
| 1079 | myHead.setNoise(noise); | 1076 | myAvatar.setNoise(noise); |
| 1080 | } | 1077 | } |
| 1081 | else | 1078 | else |
| 1082 | { | 1079 | { |
| 1083 | myHead.setNoise(0); | 1080 | myAvatar.setNoise(0); |
| 1084 | } | 1081 | } |
| 1085 | 1082 | ||
| 1086 | } | 1083 | } |
| @@ -1097,10 +1094,10 @@ void key(unsigned char k, int x, int y) · 10 unmodified lines | |||
| 1097 | 1094 | ||
| 1098 | if (k == 'f') displayField = !displayField; | 1095 | if (k == 'f') displayField = !displayField; |
| 1099 | if (k == 'l') displayLevels = !displayLevels; | 1096 | if (k == 'l') displayLevels = !displayLevels; |
| 1100 | if (k == 'e') myHead.setDriveKeys(UP, 1); | 1097 | if (k == 'e') myAvatar.setDriveKeys(UP, 1); |
| 1101 | if (k == 'c') myHead.setDriveKeys(DOWN, 1); | 1098 | if (k == 'c') myAvatar.setDriveKeys(DOWN, 1); |
| 1102 | if (k == 'w') myHead.setDriveKeys(FWD, 1); | 1099 | if (k == 'w') myAvatar.setDriveKeys(FWD, 1); |
| 1103 | if (k == 's') myHead.setDriveKeys(BACK, 1); | 1100 | if (k == 's') myAvatar.setDriveKeys(BACK, 1); |
| 1104 | if (k == ' ') reset_sensors(); | 1101 | if (k == ' ') reset_sensors(); |
| 1105 | if (k == 't') renderPitchRate -= KEYBOARD_PITCH_RATE; | 1102 | if (k == 't') renderPitchRate -= KEYBOARD_PITCH_RATE; |
| 1106 | if (k == 'g') renderPitchRate += KEYBOARD_PITCH_RATE; | 1103 | if (k == 'g') renderPitchRate += KEYBOARD_PITCH_RATE; |
| @@ -1111,8 +1108,8 @@ void key(unsigned char k, int x, int y) · 4 unmodified lines | |||
| 1111 | if (k == 'k') if (starsLod > 0.01) starsLod = stars.changeLOD(0.99); | 1108 | if (k == 'k') if (starsLod > 0.01) starsLod = stars.changeLOD(0.99); |
| 1112 | if (k == 'r') stars.readInput(starFile, 0); | 1109 | if (k == 'r') stars.readInput(starFile, 0); |
| 1113 | #endif | 1110 | #endif |
| 1114 | if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 1); | 1111 | if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 1); |
| 1115 | if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 1); | 1112 | if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 1); |
| 1116 | 1113 | ||
| 1117 | // press the . key to get a new random sphere of voxels added | 1114 | // press the . key to get a new random sphere of voxels added |
| 1118 | if (k == '.') addRandomSphere(wantColorRandomizer); | 1115 | if (k == '.') addRandomSphere(wantColorRandomizer); |
| @@ -1134,7 +1131,7 @@ void *networkReceive(void *args) · 15 unmodified lines | |||
| 1134 | 1131 | ||
| 1135 | if (incomingPacket[0] == PACKET_HEADER_TRANSMITTER_DATA) { | 1132 | if (incomingPacket[0] == PACKET_HEADER_TRANSMITTER_DATA) { |
| 1136 | // Pass everything but transmitter data to the agent list | 1133 | // Pass everything but transmitter data to the agent list |
| 1137 | myHead.hand->processTransmitterData(incomingPacket, bytesReceived); | 1134 | myAvatar.hand->processTransmitterData(incomingPacket, bytesReceived); |
| 1138 | } else if (incomingPacket[0] == PACKET_HEADER_VOXEL_DATA || | 1135 | } else if (incomingPacket[0] == PACKET_HEADER_VOXEL_DATA || |
| 1139 | incomingPacket[0] == PACKET_HEADER_Z_COMMAND || | 1136 | incomingPacket[0] == PACKET_HEADER_Z_COMMAND || |
| 1140 | incomingPacket[0] == PACKET_HEADER_ERASE_VOXEL) { | 1137 | incomingPacket[0] == PACKET_HEADER_ERASE_VOXEL) { |
| @@ -1166,12 +1163,12 @@ void idle(void) · 25 unmodified lines | |||
| 1166 | float xOffset = ( mouseX - mouseStartX ) / (double)WIDTH; | 1163 | float xOffset = ( mouseX - mouseStartX ) / (double)WIDTH; |
| 1167 | float yOffset = ( mouseY - mouseStartY ) / (double)HEIGHT; | 1164 | float yOffset = ( mouseY - mouseStartY ) / (double)HEIGHT; |
| 1168 | 1165 | ||
| 1169 | float leftRight = xOffset; | 1166 | float leftRight = xOffset; |
| 1170 | float downUp = yOffset; | 1167 | float downUp = -yOffset; |
| 1171 | float backFront = 0.0; | 1168 | float backFront = 0.0; |
| 1172 | 1169 | ||
| 1173 | glm::vec3 handMovement( leftRight, downUp, backFront ); | 1170 | glm::vec3 handMovement( leftRight, downUp, backFront ); |
| 1174 | myHead.setHandMovement( handMovement ); | 1171 | myAvatar.setHandMovement( handMovement ); |
| 1175 | } | 1172 | } |
| 1176 | 1173 | ||
| 1177 | // Simulation | 1174 | // Simulation |
| @@ -1194,7 +1191,7 @@ void idle(void) · 16 unmodified lines | |||
| 1194 | simulateHand(1.f/FPS); | 1191 | simulateHand(1.f/FPS); |
| 1195 | 1192 | ||
| 1196 | field.simulate(1.f/FPS); | 1193 | field.simulate(1.f/FPS); |
| 1197 | myHead.simulate(1.f/FPS); | 1194 | myAvatar.simulate(1.f/FPS); |
| 1198 | balls.simulate(1.f/FPS); | 1195 | balls.simulate(1.f/FPS); |
| 1199 | cloud.simulate(1.f/FPS); | 1196 | cloud.simulate(1.f/FPS); |
| 1200 | lattice.simulate(1.f/FPS); | 1197 | lattice.simulate(1.f/FPS); |