Prześlij pliki do 'src'

This commit is contained in:
Michał Ciesiółka 2023-01-26 00:13:53 +01:00
parent b72f14a8f6
commit 44e365f083

View File

@ -4,6 +4,7 @@
#include "ext.hpp" #include "ext.hpp"
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include <stdlib.h>
#include "Shader_Loader.h" #include "Shader_Loader.h"
#include "Render_Utils.h" #include "Render_Utils.h"
@ -46,6 +47,7 @@ namespace textures {
GLuint deskTexture; GLuint deskTexture;
GLuint ceilingLampTexture; GLuint ceilingLampTexture;
GLuint bedTexture; GLuint bedTexture;
GLuint flashlightTexture;
} }
GLuint depthMapFBO; GLuint depthMapFBO;
@ -55,7 +57,9 @@ GLuint program;
GLuint programSun; GLuint programSun;
GLuint programTex; GLuint programTex;
GLuint programDepth; GLuint programDepth;
GLuint programSkybox;
bool flashOff = false;
Core::Shader_Loader shaderLoader; Core::Shader_Loader shaderLoader;
@ -324,14 +328,16 @@ void renderScene(GLFWwindow* window)
// ); // );
drawObjectPBR(shipContext, drawObjectPBR(shipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)), glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)),
textures::sunTexture, textures::flashlightTexture,
0.2, 0.0,
1.0 0.0
); );
spotlightPos = spaceshipPos + 0.2 * spaceshipDir; spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
spotlightConeDir = spaceshipDir; if (!flashOff)
spotlightConeDir = spaceshipDir;
else
spotlightConeDir = -spaceshipDir;
glUseProgram(0); glUseProgram(0);
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
@ -397,6 +403,7 @@ void init(GLFWwindow* window)
loadModelToContext("./models2/lamp/Lamp_LOVMANAD_OBJ.obj", models::lamp); loadModelToContext("./models2/lamp/Lamp_LOVMANAD_OBJ.obj", models::lamp);
loadModelToContext("./models2/door/source/door.obj", models::door); loadModelToContext("./models2/door/source/door.obj", models::door);
textures::flashlightTexture = Core::LoadTexture("./models/FlashlightTexture.png");
textures::sunTexture = Core::LoadTexture("./models/sun.jpeg"); textures::sunTexture = Core::LoadTexture("./models/sun.jpeg");
textures::windowFrameTexture = Core::LoadTexture("./models2/Frame/frame.png"); textures::windowFrameTexture = Core::LoadTexture("./models2/Frame/frame.png");
textures::bookShelfTexture = Core::LoadTexture("./models2/bookshelf/SHELF_TEXTURE.bmp"); textures::bookShelfTexture = Core::LoadTexture("./models2/bookshelf/SHELF_TEXTURE.bmp");
@ -424,20 +431,25 @@ void processInput(GLFWwindow* window)
spaceshipPos += spaceshipDir * moveSpeed; spaceshipPos += spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
spaceshipPos -= spaceshipDir * moveSpeed; spaceshipPos -= spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
spaceshipPos += spaceshipSide * moveSpeed; spaceshipPos += spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
spaceshipPos -= spaceshipSide * moveSpeed; spaceshipPos -= spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
spaceshipPos += spaceshipUp * moveSpeed; spaceshipPos += spaceshipUp * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
spaceshipPos -= spaceshipUp * moveSpeed; 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)); 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)); 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; cameraDir = spaceshipDir;
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS)