Showing the changes to interface/src/main.cpp (1 of 4 files). Show all
Unified · Split
| @@ -35,10 +35,15 @@ · 34 unmodified lines | |||
| 35 | #include <pthread.h> | 35 | #include <pthread.h> |
| 36 | 36 | ||
| 37 | #include <glm/glm.hpp> | 37 | #include <glm/glm.hpp> |
| 38 | #include <glm/gtc/matrix_transform.hpp> | ||
| 39 | #include <glm/gtc/type_ptr.hpp> | ||
| 40 | |||
| 38 | #include "Field.h" | 41 | #include "Field.h" |
| 39 | #include "world.h" | 42 | #include "world.h" |
| 40 | #include "Util.h" | 43 | #include "Util.h" |
| 41 | #include "Audio.h" | 44 | #include "Audio.h" |
| 45 | #include "FieldOfView.h" | ||
| 46 | #include "Stars.h" | ||
| 42 | #include "Head.h" | 47 | #include "Head.h" |
| 43 | #include "Hand.h" | 48 | #include "Hand.h" |
| 44 | #include "Particle.h" | 49 | #include "Particle.h" |
| @@ -54,7 +59,7 @@ · 9 unmodified lines | |||
| 54 | 59 | ||
| 55 | using namespace std; | 60 | using namespace std; |
| 56 | 61 | ||
| 57 | int audio_on = 1; // Whether to turn on the audio support | 62 | int audio_on = 0; // Whether to turn on the audio support |
| 58 | int simulate_on = 1; | 63 | int simulate_on = 1; |
| 59 | 64 | ||
| 60 | // | 65 | // |
| @@ -93,6 +98,10 @@ Oscilloscope audioScope(256,200,true); · 32 unmodified lines | |||
| 93 | #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you | 98 | #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you |
| 94 | Head myHead; // The rendered head of oneself | 99 | Head myHead; // The rendered head of oneself |
| 95 | 100 | ||
| 101 | #define USE_FOV | ||
| 102 | FieldOfView fov; | ||
| 103 | |||
| 104 | Stars stars; | ||
| 96 | 105 | ||
| 97 | glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); | 106 | glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); |
| 98 | ParticleSystem balls(0, | 107 | ParticleSystem balls(0, |
| @@ -329,7 +338,9 @@ void init(void) · 230 unmodified lines | |||
| 329 | head_mouse_y = HEIGHT/2; | 338 | head_mouse_y = HEIGHT/2; |
| 330 | head_lean_x = WIDTH/2; | 339 | head_lean_x = WIDTH/2; |
| 331 | head_lean_y = HEIGHT/2; | 340 | head_lean_y = HEIGHT/2; |
| 332 | 341 | ||
| 342 | stars.readInput("file://stars.txt"); | ||
| 343 | |||
| 333 | // Initialize Field values | 344 | // Initialize Field values |
| 334 | field = Field(); | 345 | field = Field(); |
| 335 | printf( "Field Initialized.\n" ); | 346 | printf( "Field Initialized.\n" ); |
| @@ -564,14 +575,29 @@ void display(void) · 228 unmodified lines | |||
| 564 | glMateriali(GL_FRONT, GL_SHININESS, 96); | 575 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 565 | 576 | ||
| 566 | // Rotate, translate to camera location | 577 | // 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 | ||
| 567 | glRotatef(myHead.getRenderPitch(), 1, 0, 0); | 587 | glRotatef(myHead.getRenderPitch(), 1, 0, 0); |
| 568 | glRotatef(myHead.getRenderYaw(), 0, 1, 0); | 588 | glRotatef(myHead.getRenderYaw(), 0, 1, 0); |
| 569 | glTranslatef(location[0], location[1], location[2]); | 589 | 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 | |||
| 571 | glColor3f(1,0,0); | 598 | glColor3f(1,0,0); |
| 572 | glutSolidSphere(0.25, 15, 15); | 599 | glutSolidSphere(0.25, 15, 15); |
| 573 | 600 | ||
| 574 | |||
| 575 | // Draw cloud of dots | 601 | // Draw cloud of dots |
| 576 | glDisable( GL_POINT_SPRITE_ARB ); | 602 | glDisable( GL_POINT_SPRITE_ARB ); |
| 577 | glDisable( GL_TEXTURE_2D ); | 603 | glDisable( GL_TEXTURE_2D ); |
| @@ -684,6 +710,7 @@ void display(void) · 106 unmodified lines | |||
| 684 | framecount++; | 710 | framecount++; |
| 685 | } | 711 | } |
| 686 | 712 | ||
| 713 | const float KEYBOARD_PITCH_RATE = 0.8; | ||
| 687 | const float KEYBOARD_YAW_RATE = 0.8; | 714 | const float KEYBOARD_YAW_RATE = 0.8; |
| 688 | const float KEYBOARD_STRAFE_RATE = 0.03; | 715 | const float KEYBOARD_STRAFE_RATE = 0.03; |
| 689 | const float KEYBOARD_FLY_RATE = 0.08; | 716 | const float KEYBOARD_FLY_RATE = 0.08; |
| @@ -741,6 +768,8 @@ void key(unsigned char k, int x, int y) · 51 unmodified lines | |||
| 741 | if (k == ' ') reset_sensors(); | 768 | if (k == ' ') reset_sensors(); |
| 742 | if (k == 'a') render_yaw_rate -= KEYBOARD_YAW_RATE; | 769 | if (k == 'a') render_yaw_rate -= KEYBOARD_YAW_RATE; |
| 743 | if (k == 'd') render_yaw_rate += KEYBOARD_YAW_RATE; | 770 | 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; | ||
| 744 | if (k == 'o') simulate_on = !simulate_on; | 773 | if (k == 'o') simulate_on = !simulate_on; |
| 745 | if (k == 'p') | 774 | if (k == 'p') |
| 746 | { | 775 | { |
| @@ -820,19 +849,26 @@ void reshape(int width, int height) · 73 unmodified lines | |||
| 820 | { | 849 | { |
| 821 | WIDTH = width; | 850 | WIDTH = width; |
| 822 | HEIGHT = height; | 851 | HEIGHT = height; |
| 823 | |||
| 824 | glViewport(0, 0, width, height); | ||
| 825 | 852 | ||
| 826 | glMatrixMode(GL_PROJECTION); //hello | 853 | 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 | |||
| 827 | glLoadIdentity(); | 862 | glLoadIdentity(); |
| 828 | gluPerspective(45, //view angle | 863 | gluPerspective(45, //view angle |
| 829 | 1.0, //aspect ratio | 864 | 1.0, //aspect ratio |
| 830 | 0.1, //near clip | 865 | 0.1, //near clip |
| 831 | 50.0);//far clip | 866 | 50.0);//far clip |
| 867 | #endif | ||
| 832 | glMatrixMode(GL_MODELVIEW); | 868 | glMatrixMode(GL_MODELVIEW); |
| 833 | glLoadIdentity(); | 869 | glLoadIdentity(); |
| 834 | 870 | ||
| 835 | 871 | glViewport(0, 0, width, height); | |
| 836 | } | 872 | } |
| 837 | 873 | ||
| 838 | void mouseFunc( int button, int state, int x, int y ) | 874 | void mouseFunc( int button, int state, int x, int y ) |