History

leftover changes / minor corrections

tosh committed 13 years ago

Commit 5de3ec01 parent 4444bcf4 files · +60 −12Browse files

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

Unified · Split

interface/src/main.cpp+46−10
@@ -35,10 +35,15 @@ · 34 unmodified lines
3535 #include <pthread.h>
3636
3737 #include <glm/glm.hpp>
38+#include <glm/gtc/matrix_transform.hpp>
39+#include <glm/gtc/type_ptr.hpp>
40+
3841 #include "Field.h"
3942 #include "world.h"
4043 #include "Util.h"
4144 #include "Audio.h"
45+#include "FieldOfView.h"
46+#include "Stars.h"
4247 #include "Head.h"
4348 #include "Hand.h"
4449 #include "Particle.h"
@@ -54,7 +59,7 @@ · 9 unmodified lines
5459
5560 using namespace std;
5661
57−int audio_on = 1; // Whether to turn on the audio support
62+int audio_on = 0; // Whether to turn on the audio support
5863 int simulate_on = 1;
5964
6065 //
@@ -93,6 +98,10 @@ Oscilloscope audioScope(256,200,true); · 32 unmodified lines
9398 #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
9499 Head myHead; // The rendered head of oneself
95100
101+#define USE_FOV
102+FieldOfView fov;
103+
104+Stars stars;
96105
97106 glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
98107 ParticleSystem balls(0,
@@ -329,7 +338,9 @@ void init(void) · 230 unmodified lines
329338 head_mouse_y = HEIGHT/2;
330339 head_lean_x = WIDTH/2;
331340 head_lean_y = HEIGHT/2;
332−
341+
342+ stars.readInput("file://stars.txt");
343+
333344 // Initialize Field values
334345 field = Field();
335346 printf( "Field Initialized.\n" );
@@ -564,14 +575,29 @@ void display(void) · 228 unmodified lines
564575 glMateriali(GL_FRONT, GL_SHININESS, 96);
565576
566577 // Rotate, translate to camera location
578+#ifdef USE_FOV
579+ fov.setOrientation(
580+ glm::rotate(glm::rotate(glm::translate(glm::mat4(1.0f),
581+ glm::vec3(-location[0], -location[1], -location[2])),
582+ -myHead.getRenderYaw(), glm::vec3(0.0f,1.0f,0.0f)),
583+ -myHead.getRenderPitch(), glm::vec3(1.0f,0.0f,0.0f)) );
584+
585+ glLoadMatrixf( glm::value_ptr(fov.getWorldViewerXform()) );
586+#else
567587 glRotatef(myHead.getRenderPitch(), 1, 0, 0);
568588 glRotatef(myHead.getRenderYaw(), 0, 1, 0);
569589 glTranslatef(location[0], location[1], location[2]);
570−
590+#endif
591+
592+ glDisable(GL_LIGHTING);
593+ glDisable(GL_DEPTH_TEST);
594+ stars.render(fov);
595+ glEnable(GL_LIGHTING);
596+ glEnable(GL_DEPTH_TEST);
597+
571598 glColor3f(1,0,0);
572599 glutSolidSphere(0.25, 15, 15);
573600
574−
575601 // Draw cloud of dots
576602 glDisable( GL_POINT_SPRITE_ARB );
577603 glDisable( GL_TEXTURE_2D );
@@ -684,6 +710,7 @@ void display(void) · 106 unmodified lines
684710 framecount++;
685711 }
686712
713+const float KEYBOARD_PITCH_RATE = 0.8;
687714 const float KEYBOARD_YAW_RATE = 0.8;
688715 const float KEYBOARD_STRAFE_RATE = 0.03;
689716 const float KEYBOARD_FLY_RATE = 0.08;
@@ -741,6 +768,8 @@ void key(unsigned char k, int x, int y) · 51 unmodified lines
741768 if (k == ' ') reset_sensors();
742769 if (k == 'a') render_yaw_rate -= KEYBOARD_YAW_RATE;
743770 if (k == 'd') render_yaw_rate += KEYBOARD_YAW_RATE;
771+ if (k == 't') render_pitch_rate += KEYBOARD_PITCH_RATE;
772+ if (k == 'g') render_pitch_rate -= KEYBOARD_PITCH_RATE;
744773 if (k == 'o') simulate_on = !simulate_on;
745774 if (k == 'p')
746775 {
@@ -820,19 +849,26 @@ void reshape(int width, int height) · 73 unmodified lines
820849 {
821850 WIDTH = width;
822851 HEIGHT = height;
823−
824− glViewport(0, 0, width, height);
825852
826853 glMatrixMode(GL_PROJECTION); //hello
854+#ifdef USE_FOV
855+ fov.setResolution(width, height)
856+ .setFrustum(glm::vec3(-0.5f,-0.5f,-50.0f), glm::vec3(0.5f, 0.5f, 0.1f) )
857+ .setPerspective(0.78f);
858+
859+ glLoadMatrixf(glm::value_ptr(fov.getViewerScreenXform()));
860+#else
861+
827862 glLoadIdentity();
828863 gluPerspective(45, //view angle
829− 1.0, //aspect ratio
830− 0.1, //near clip
831− 50.0);//far clip
864+ 1.0, //aspect ratio
865+ 0.1, //near clip
866+ 50.0);//far clip
867+#endif
832868 glMatrixMode(GL_MODELVIEW);
833869 glLoadIdentity();
834870
835−
871+ glViewport(0, 0, width, height);
836872 }
837873
838874 void mouseFunc( int button, int state, int x, int y )