diff --git a/src/ex_9_1.hpp b/src/ex_9_1.hpp index b1694ae..5240d75 100644 --- a/src/ex_9_1.hpp +++ b/src/ex_9_1.hpp @@ -4,6 +4,7 @@ #include "ext.hpp" #include #include +#include #include "Shader_Loader.h" #include "Render_Utils.h" @@ -46,6 +47,7 @@ namespace textures { GLuint deskTexture; GLuint ceilingLampTexture; GLuint bedTexture; + GLuint flashlightTexture; } GLuint depthMapFBO; @@ -55,7 +57,9 @@ GLuint program; GLuint programSun; GLuint programTex; GLuint programDepth; +GLuint programSkybox; +bool flashOff = false; Core::Shader_Loader shaderLoader; @@ -324,14 +328,16 @@ void renderScene(GLFWwindow* window) // ); drawObjectPBR(shipContext, glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.03f)), - textures::sunTexture, - 0.2, - 1.0 + textures::flashlightTexture, + 0.0, + 0.0 ); spotlightPos = spaceshipPos + 0.2 * spaceshipDir; - spotlightConeDir = spaceshipDir; - + if (!flashOff) + spotlightConeDir = spaceshipDir; + else + spotlightConeDir = -spaceshipDir; glUseProgram(0); glfwSwapBuffers(window); } @@ -397,6 +403,7 @@ void init(GLFWwindow* window) loadModelToContext("./models2/lamp/Lamp_LOVMANAD_OBJ.obj", models::lamp); loadModelToContext("./models2/door/source/door.obj", models::door); + textures::flashlightTexture = Core::LoadTexture("./models/FlashlightTexture.png"); textures::sunTexture = Core::LoadTexture("./models/sun.jpeg"); textures::windowFrameTexture = Core::LoadTexture("./models2/Frame/frame.png"); textures::bookShelfTexture = Core::LoadTexture("./models2/bookshelf/SHELF_TEXTURE.bmp"); @@ -424,20 +431,25 @@ void processInput(GLFWwindow* window) spaceshipPos += spaceshipDir * moveSpeed; if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) spaceshipPos -= spaceshipDir * moveSpeed; - if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) + if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) spaceshipPos += spaceshipSide * moveSpeed; - if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) + if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) spaceshipPos -= spaceshipSide * moveSpeed; if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) spaceshipPos += spaceshipUp * moveSpeed; if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) spaceshipPos -= spaceshipUp * moveSpeed; - if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) + if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0)); - if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) + if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0)); + if (glfwGetKey(window, GLFW_KEY_4) == GLFW_PRESS) + flashOff = false; + if (glfwGetKey(window, GLFW_KEY_5) == GLFW_PRESS) + flashOff = true; - cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f; + + cameraPos = spaceshipPos - 0.6 * spaceshipDir + glm::vec3(0, 1, 0) * 0.26f; cameraDir = spaceshipDir; if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS)