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
5050
5151 #include "Head.h"
5252 #include "Hand.h"
53+#include "Camera.h"
5354 #include "Particle.h"
5455 #include "Texture.h"
5556 #include "Cloud.h"
@@ -65,7 +66,10 @@ · 9 unmodified lines
6566
6667 using namespace std;
6768
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
6973 int simulate_on = 1;
7074
7175 AgentList agentList('I');
@@ -95,6 +99,7 @@ Oscilloscope audioScope(256,200,true); · 23 unmodified lines
9599
96100 #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
97101 Head myHead; // The rendered head of oneself
102+Camera myCamera; // My view onto the world (sometimes on myself :)
98103
99104 char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
100105 FieldOfView fov;
@@ -342,8 +347,10 @@ void init(void) · 241 unmodified lines
342347 if (noise_on) {
343348 myHead.setNoise(noise);
344349 }
345− myHead.setPos(start_location);
346−
350+ myHead.setPos(start_location );
351+
352+ myCamera.setPosition( glm::dvec3( start_location ) );
353+
347354 #ifdef MARKER_CAPTURE
348355 if(marker_capture_enabled){
349356 marker_capturer.position_updated(&position_updated);
@@ -406,6 +413,12 @@ void simulateHand(float deltaTime) { · 56 unmodified lines
406413 float dy = mouse_y - mouse_start_y;
407414 glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0);
408415 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 );
409422 }
410423 }
411424
@@ -422,7 +435,12 @@ void simulateHead(float frametime) · 10 unmodified lines
422435 //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z);
423436
424437 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+
426444 // Update head_mouse model
427445 const float MIN_MOUSE_RATE = 30.0;
428446 const float MOUSE_SENSITIVITY = 0.1f;
@@ -551,16 +569,29 @@ void display(void) · 122 unmodified lines
551569
552570 glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
553571 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 );
564595
565596 glDisable(GL_LIGHTING);
566597 glDisable(GL_DEPTH_TEST);
@@ -601,12 +632,18 @@ void display(void) · 34 unmodified lines
601632 // Render the world box
602633 if (!display_head && stats_on) render_world_box();
603634
635+
636+myHead.render( true, 1 );
637+
638+ /*
604639 // Render my own head
605640 glPushMatrix();
606641 glLoadIdentity();
607642 glTranslatef(0.f, 0.f, -7.f);
608643 myHead.render(display_head, 1);
609644 glPopMatrix();
645+ */
646+
610647 }
611648
612649 glPopMatrix();