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
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
55using namespace std;60using namespace std;
56 61
57int audio_on = 1; // Whether to turn on the audio support62int audio_on = 0; // Whether to turn on the audio support
58int simulate_on = 1; 63int 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 you98#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
94Head myHead; // The rendered head of oneself99Head myHead; // The rendered head of oneself
95 100
101#define USE_FOV
102FieldOfView fov;
103
104Stars stars;
96 105
97glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);106glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
98ParticleSystem balls(0, 107ParticleSystem 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 values344 // 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 location577 // 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 dots601 // 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
713const float KEYBOARD_PITCH_RATE = 0.8;
687const float KEYBOARD_YAW_RATE = 0.8;714const float KEYBOARD_YAW_RATE = 0.8;
688const float KEYBOARD_STRAFE_RATE = 0.03;715const float KEYBOARD_STRAFE_RATE = 0.03;
689const float KEYBOARD_FLY_RATE = 0.08;716const 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); //hello853 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 angle863 gluPerspective(45, //view angle
829 1.0, //aspect ratio864 1.0, //aspect ratio
830 0.1, //near clip865 0.1, //near clip
831 50.0);//far clip866 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
838void mouseFunc( int button, int state, int x, int y ) 874void mouseFunc( int button, int state, int x, int y )