Showing the changes to interface/src/main.cpp (1 of 11 files). Show all
Unified · Split
| @@ -50,6 +50,7 @@ · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | #include "Head.h" |
| 52 | 52 | #include "Hand.h" |
| 53 | +#include "Camera.h" | |
| 53 | 54 | #include "Particle.h" |
| 54 | 55 | #include "Texture.h" |
| 55 | 56 | #include "Cloud.h" |
| @@ -65,7 +66,10 @@ · 9 unmodified lines | ||
| 65 | 66 | |
| 66 | 67 | using namespace std; |
| 67 | 68 | |
| 68 | −int audio_on = 0; // Whether to turn on the audio support | |
| 69 | + | |
| 70 | +double testThingy = 0.0; | |
| 71 | + | |
| 72 | +int audio_on = 1; // Whether to turn on the audio support | |
| 69 | 73 | int simulate_on = 1; |
| 70 | 74 | |
| 71 | 75 | AgentList agentList('I'); |
| @@ -95,6 +99,7 @@ Oscilloscope audioScope(256,200,true); · 23 unmodified lines | ||
| 95 | 99 | |
| 96 | 100 | #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you |
| 97 | 101 | Head myHead; // The rendered head of oneself |
| 102 | +Camera myCamera; // My view onto the world (sometimes on myself :) | |
| 98 | 103 | |
| 99 | 104 | char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; |
| 100 | 105 | FieldOfView fov; |
| @@ -342,8 +347,10 @@ void init(void) · 241 unmodified lines | ||
| 342 | 347 | if (noise_on) { |
| 343 | 348 | myHead.setNoise(noise); |
| 344 | 349 | } |
| 345 | − myHead.setPos(start_location); | |
| 346 | − | |
| 350 | + myHead.setPos(start_location ); | |
| 351 | + | |
| 352 | + myCamera.setPosition( glm::dvec3( start_location ) ); | |
| 353 | + | |
| 347 | 354 | #ifdef MARKER_CAPTURE |
| 348 | 355 | if(marker_capture_enabled){ |
| 349 | 356 | marker_capturer.position_updated(&position_updated); |
| @@ -406,6 +413,12 @@ void simulateHand(float deltaTime) { · 56 unmodified lines | ||
| 406 | 413 | float dy = mouse_y - mouse_start_y; |
| 407 | 414 | glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0); |
| 408 | 415 | myHead.hand->addVelocity(vel*deltaTime); |
| 416 | + | |
| 417 | + double leftRight = dx * 0.001; | |
| 418 | + double downUp = dy * 0.001; | |
| 419 | + double backFront = 0.0; | |
| 420 | + glm::dvec3 handMovement( leftRight, downUp, backFront ); | |
| 421 | + myHead.setHandMovement( handMovement ); | |
| 409 | 422 | } |
| 410 | 423 | } |
| 411 | 424 | |
| @@ -422,7 +435,12 @@ void simulateHead(float frametime) · 10 unmodified lines | ||
| 422 | 435 | //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z); |
| 423 | 436 | |
| 424 | 437 | myHead.UpdatePos(frametime, &serialPort, head_mirror, &gravity); |
| 425 | − | |
| 438 | + | |
| 439 | + //------------------------------------------------------------------------------------- | |
| 440 | + // set the position of the avatar | |
| 441 | + //------------------------------------------------------------------------------------- | |
| 442 | + myHead.setAvatarPosition( -myHead.getPos().x, -myHead.getPos().y, -myHead.getPos().z ); | |
| 443 | + | |
| 426 | 444 | // Update head_mouse model |
| 427 | 445 | const float MIN_MOUSE_RATE = 30.0; |
| 428 | 446 | const float MOUSE_SENSITIVITY = 0.1f; |
| @@ -551,16 +569,29 @@ void display(void) · 122 unmodified lines | ||
| 551 | 569 | |
| 552 | 570 | glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); |
| 553 | 571 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 554 | − | |
| 555 | − // Rotate, translate to camera location | |
| 556 | − fov.setOrientation( | |
| 557 | − glm::rotate(glm::rotate(glm::translate(glm::mat4(1.0f), -myHead.getPos()), | |
| 558 | − -myHead.getRenderYaw(), glm::vec3(0.0f,1.0f,0.0f)), | |
| 559 | − -myHead.getRenderPitch(), glm::vec3(1.0f,0.0f,0.0f)) ); | |
| 560 | − | |
| 561 | − glLoadMatrixf( glm::value_ptr(fov.getWorldViewerXform()) ); | |
| 562 | − glRotatef(myHead.getRenderPitch(), 1, 0, 0); | |
| 563 | − glRotatef(myHead.getRenderYaw(), 0, 1, 0); | |
| 572 | + | |
| 573 | + //------------------------------------------------------------------------------------- | |
| 574 | + // set the caemra to third-person view | |
| 575 | + //------------------------------------------------------------------------------------- | |
| 576 | + myCamera.setYaw ( myHead.getRenderYaw() ); | |
| 577 | + myCamera.setPitch ( 0.0 ); | |
| 578 | + myCamera.setRoll ( 0.0 ); | |
| 579 | + | |
| 580 | + glm::dvec3 offset( 0.7, -0.2, 0.7 ); | |
| 581 | + | |
| 582 | + glm::dvec3 positionWithOffset( myHead.getPos() ); | |
| 583 | + | |
| 584 | + positionWithOffset += offset; | |
| 585 | + | |
| 586 | + myCamera.setPosition( positionWithOffset ); | |
| 587 | + | |
| 588 | + //------------------------------------------------------------------------------------- | |
| 589 | + // transform to camera view | |
| 590 | + //------------------------------------------------------------------------------------- | |
| 591 | + glRotatef ( myCamera.getPitch(), 1, 0, 0 ); | |
| 592 | + glRotatef ( myCamera.getYaw(), 0, 1, 0 ); | |
| 593 | + glRotatef ( myCamera.getRoll(), 0, 0, 1 ); | |
| 594 | + glTranslatef( myCamera.getPosition().x, myCamera.getPosition().y, myCamera.getPosition().z ); | |
| 564 | 595 | |
| 565 | 596 | glDisable(GL_LIGHTING); |
| 566 | 597 | glDisable(GL_DEPTH_TEST); |
| @@ -601,12 +632,18 @@ void display(void) · 34 unmodified lines | ||
| 601 | 632 | // Render the world box |
| 602 | 633 | if (!display_head && stats_on) render_world_box(); |
| 603 | 634 | |
| 635 | + | |
| 636 | +myHead.render( true, 1 ); | |
| 637 | + | |
| 638 | + /* | |
| 604 | 639 | // Render my own head |
| 605 | 640 | glPushMatrix(); |
| 606 | 641 | glLoadIdentity(); |
| 607 | 642 | glTranslatef(0.f, 0.f, -7.f); |
| 608 | 643 | myHead.render(display_head, 1); |
| 609 | 644 | glPopMatrix(); |
| 645 | + */ | |
| 646 | + | |
| 610 | 647 | } |
| 611 | 648 | |
| 612 | 649 | glPopMatrix(); |