@@ -36,6 +36,8 @@ bool SHOW_WATER = true; // Press L to hide/unhide water
3636bool DEBUG = false ; // Use 0 to toggle invincibility, disables bounds collision game over condition
3737bool SPRAY_PARTICLES = false ; // Press F to spray blue particle trails from the ship
3838int TOON_SHADING = true ; // Press P to toggle discretized color shading
39+ int SHOW_REFLECTION = 1 ; // Press X to toggle reflection
40+ int SHOW_REFRACTION = 1 ; // Press Z to toggle refraction
3941
4042// GAME OPTIONS (You may edit these!)
4143const int ISLAND_NUM = 10 ; // Default: 10
@@ -57,6 +59,8 @@ Island * tutorial_island; // Used to stop islands from being generated on to
5759GLuint normal_toggle_var; // Sends information to terrain shader for normals coloring
5860GLuint toon_toggle_var; // Sends information to toon shader to toggle toon coloring
5961GLuint uCam_pos; // Sends camera pos information to shader
62+ GLuint sRefract ; // Toggle refraction
63+ GLuint sReflect ; // Toggle reflection
6064GLuint uCam_look_at; // Sends camera look_at information to shader
6165glm::vec3 lastPoint; // Holds last point for mouse/cursor movement
6266bool place_island = true ; // Used to check if two islands are overlapping
@@ -116,7 +120,7 @@ void Window::initialize_objects()
116120 // Water initialization
117121 ocean = new Water ();
118122 ocean->toWorld = glm::translate (glm::mat4 (1 .0f ), glm::vec3 (0 .0f , 0 .0f , 0 .0f ));
119- ocean->scale (4000 .0f , 1 .0f , 4000 .0f );
123+ ocean->scale (4000 .0f , 15 .0f , 4000 .0f );
120124
121125 // Start clock for water waves
122126 tpf = clock ();
@@ -269,6 +273,8 @@ void Window::initialize_objects()
269273 std::cout << " , - Regenerate map into singular islands" << std::endl;
270274 std::cout << " G - Mute sound" << std::endl;
271275 std::cout << " P - Toggle toon coloring" << std::endl;
276+ std::cout << " Z - Toggle water refraction" << std::endl;
277+ std::cout << " X - Toggle water reflection" << std::endl;
272278}
273279
274280// Treat this as a destructor function. Delete dynamically allocated memory here.
@@ -599,6 +605,10 @@ void Window::display_callback(GLFWwindow* window)
599605 /* ********* RENDER WATER **********/
600606 glUseProgram (water_shaderProgram);
601607 // Adjust timer for input into water waves
608+ sRefract = glGetUniformLocation (water_shaderProgram, " show_refract" );
609+ glUniform1i (sRefract , SHOW_REFRACTION );
610+ sReflect = glGetUniformLocation (water_shaderProgram, " show_reflect" );
611+ glUniform1i (sReflect , SHOW_REFLECTION );
602612 elapsedTime = (float )(clock () - tpf) / CLOCKS_PER_SEC ;
603613 if (elapsedTime > 13 .0f && go_backwards == false ) {
604614 tpf = clock ();
@@ -679,6 +689,15 @@ void Window::key_callback(GLFWwindow* window, int key, int scancode, int action,
679689 sound->toggleMuteAll ();
680690 }
681691
692+ else if (key == GLFW_KEY_Y ) {
693+ if (mods == GLFW_MOD_SHIFT ) {
694+ model->translate (0 .0f , 3 .0f , 0 .0f );
695+ }
696+ else {
697+ model->translate (0 .0f , -3 .0f , 0 .0f );
698+ }
699+ }
700+
682701 else if (key == GLFW_KEY_T ) {
683702 std::cout << " Regenerating terrain!" << std::endl;
684703 for (int i = 0 ; i < isles.size (); i++) {
@@ -762,6 +781,23 @@ void Window::key_callback(GLFWwindow* window, int key, int scancode, int action,
762781 }
763782 }
764783
784+ else if (key == GLFW_KEY_Z ) {
785+ if (SHOW_REFRACTION == 1 ) {
786+ SHOW_REFRACTION = 0 ;
787+ }
788+ else {
789+ SHOW_REFRACTION = 1 ;
790+ }
791+ }
792+ else if (key == GLFW_KEY_X ) {
793+ if (SHOW_REFLECTION == 1 ) {
794+ SHOW_REFLECTION = 0 ;
795+ }
796+ else {
797+ SHOW_REFLECTION = 1 ;
798+ }
799+ }
800+
765801 else if (key == GLFW_KEY_R ) {
766802 FREE_CAMERA = false ;
767803 GAME_OVER = false ;
0 commit comments