@@ -36,6 +36,8 @@ bool SHOW_WATER = true; // Press L to hide/unhide water
36
36
bool DEBUG = false ; // Use 0 to toggle invincibility, disables bounds collision game over condition
37
37
bool SPRAY_PARTICLES = false ; // Press F to spray blue particle trails from the ship
38
38
int 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
39
41
40
42
// GAME OPTIONS (You may edit these!)
41
43
const int ISLAND_NUM = 10 ; // Default: 10
@@ -57,6 +59,8 @@ Island * tutorial_island; // Used to stop islands from being generated on to
57
59
GLuint normal_toggle_var; // Sends information to terrain shader for normals coloring
58
60
GLuint toon_toggle_var; // Sends information to toon shader to toggle toon coloring
59
61
GLuint uCam_pos; // Sends camera pos information to shader
62
+ GLuint sRefract ; // Toggle refraction
63
+ GLuint sReflect ; // Toggle reflection
60
64
GLuint uCam_look_at; // Sends camera look_at information to shader
61
65
glm::vec3 lastPoint; // Holds last point for mouse/cursor movement
62
66
bool place_island = true ; // Used to check if two islands are overlapping
@@ -116,7 +120,7 @@ void Window::initialize_objects()
116
120
// Water initialization
117
121
ocean = new Water ();
118
122
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 );
120
124
121
125
// Start clock for water waves
122
126
tpf = clock ();
@@ -269,6 +273,8 @@ void Window::initialize_objects()
269
273
std::cout << " , - Regenerate map into singular islands" << std::endl;
270
274
std::cout << " G - Mute sound" << std::endl;
271
275
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;
272
278
}
273
279
274
280
// Treat this as a destructor function. Delete dynamically allocated memory here.
@@ -599,6 +605,10 @@ void Window::display_callback(GLFWwindow* window)
599
605
/* ********* RENDER WATER **********/
600
606
glUseProgram (water_shaderProgram);
601
607
// 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);
602
612
elapsedTime = (float )(clock () - tpf) / CLOCKS_PER_SEC;
603
613
if (elapsedTime > 13 .0f && go_backwards == false ) {
604
614
tpf = clock ();
@@ -679,6 +689,15 @@ void Window::key_callback(GLFWwindow* window, int key, int scancode, int action,
679
689
sound->toggleMuteAll ();
680
690
}
681
691
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
+
682
701
else if (key == GLFW_KEY_T) {
683
702
std::cout << " Regenerating terrain!" << std::endl;
684
703
for (int i = 0 ; i < isles.size (); i++) {
@@ -762,6 +781,23 @@ void Window::key_callback(GLFWwindow* window, int key, int scancode, int action,
762
781
}
763
782
}
764
783
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
+
765
801
else if (key == GLFW_KEY_R) {
766
802
FREE_CAMERA = false ;
767
803
GAME_OVER = false ;
0 commit comments