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