History

adding Camera and some utility classes and start of prototype avatar

Jeffrey Ventrella committed 13 years ago

Commit d3f6c191 parent f859d8e11 files · +1142 −30Browse files

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

Unified · Split

interface/src/main.cpp+51−14
@@ -50,6 +50,7 @@ · 49 unmodified lines
50 50
51#include "Head.h"51#include "Head.h"
52#include "Hand.h"52#include "Hand.h"
53#include "Camera.h"
53#include "Particle.h"54#include "Particle.h"
54#include "Texture.h"55#include "Texture.h"
55#include "Cloud.h"56#include "Cloud.h"
@@ -65,7 +66,10 @@ · 9 unmodified lines
65 66
66using namespace std;67using namespace std;
67 68
68int audio_on = 0; // Whether to turn on the audio support69
70double testThingy = 0.0;
71
72int audio_on = 1; // Whether to turn on the audio support
69int simulate_on = 1; 73int simulate_on = 1;
70 74
71AgentList agentList('I');75AgentList agentList('I');
@@ -95,6 +99,7 @@ Oscilloscope audioScope(256,200,true); · 23 unmodified lines
95 99
96#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you100#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
97Head myHead; // The rendered head of oneself101Head myHead; // The rendered head of oneself
102Camera myCamera; // My view onto the world (sometimes on myself :)
98 103
99char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";104char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
100FieldOfView fov;105FieldOfView fov;
@@ -342,8 +347,10 @@ void init(void) · 241 unmodified lines
342 if (noise_on) { 347 if (noise_on) {
343 myHead.setNoise(noise);348 myHead.setNoise(noise);
344 }349 }
345 myHead.setPos(start_location);350 myHead.setPos(start_location );
346 351
352 myCamera.setPosition( glm::dvec3( start_location ) );
353
347#ifdef MARKER_CAPTURE354#ifdef MARKER_CAPTURE
348 if(marker_capture_enabled){355 if(marker_capture_enabled){
349 marker_capturer.position_updated(&position_updated);356 marker_capturer.position_updated(&position_updated);
@@ -406,6 +413,12 @@ void simulateHand(float deltaTime) { · 56 unmodified lines
406 float dy = mouse_y - mouse_start_y;413 float dy = mouse_y - mouse_start_y;
407 glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0);414 glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0);
408 myHead.hand->addVelocity(vel*deltaTime);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 //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z);435 //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z);
423 436
424 myHead.UpdatePos(frametime, &serialPort, head_mirror, &gravity);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 // Update head_mouse model 444 // Update head_mouse model
427 const float MIN_MOUSE_RATE = 30.0;445 const float MIN_MOUSE_RATE = 30.0;
428 const float MOUSE_SENSITIVITY = 0.1f;446 const float MOUSE_SENSITIVITY = 0.1f;
@@ -551,16 +569,29 @@ void display(void) · 122 unmodified lines
551 569
552 glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);570 glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
553 glMateriali(GL_FRONT, GL_SHININESS, 96);571 glMateriali(GL_FRONT, GL_SHININESS, 96);
554 572
555 // Rotate, translate to camera location573 //-------------------------------------------------------------------------------------
556 fov.setOrientation(574 // set the caemra to third-person view
557 glm::rotate(glm::rotate(glm::translate(glm::mat4(1.0f), -myHead.getPos()), 575 //-------------------------------------------------------------------------------------
558 -myHead.getRenderYaw(), glm::vec3(0.0f,1.0f,0.0f)),576 myCamera.setYaw ( myHead.getRenderYaw() );
559 -myHead.getRenderPitch(), glm::vec3(1.0f,0.0f,0.0f)) );577 myCamera.setPitch ( 0.0 );
560 578 myCamera.setRoll ( 0.0 );
561 glLoadMatrixf( glm::value_ptr(fov.getWorldViewerXform()) );579
562 glRotatef(myHead.getRenderPitch(), 1, 0, 0);580 glm::dvec3 offset( 0.7, -0.2, 0.7 );
563 glRotatef(myHead.getRenderYaw(), 0, 1, 0);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 glDisable(GL_LIGHTING);596 glDisable(GL_LIGHTING);
566 glDisable(GL_DEPTH_TEST);597 glDisable(GL_DEPTH_TEST);
@@ -601,12 +632,18 @@ void display(void) · 34 unmodified lines
601 // Render the world box632 // Render the world box
602 if (!display_head && stats_on) render_world_box();633 if (!display_head && stats_on) render_world_box();
603 634
635
636myHead.render( true, 1 );
637
638 /*
604 // Render my own head639 // Render my own head
605 glPushMatrix();640 glPushMatrix();
606 glLoadIdentity();641 glLoadIdentity();
607 glTranslatef(0.f, 0.f, -7.f);642 glTranslatef(0.f, 0.f, -7.f);
608 myHead.render(display_head, 1);643 myHead.render(display_head, 1);
609 glPopMatrix();644 glPopMatrix();
645 */
646
610 }647 }
611 648
612 glPopMatrix();649 glPopMatrix();