From 0bddd667eeb00d9e4a8755da68566319f2e6aff7 Mon Sep 17 00:00:00 2001 From: s464903 Date: Sat, 11 Feb 2023 19:00:40 +0100 Subject: [PATCH] Element interaktywny - ruchome drzwi szafy --- cw 9/models/doorOrigin.mtl | 2 +- cw 9/models/wardrobeDoorLeft.mtl | 6 +++--- cw 9/models/wardrobeDoorRight.mtl | 6 +++--- cw 9/src/ex_9_1.hpp | 36 +++++++++++++++++++++++-------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/cw 9/models/doorOrigin.mtl b/cw 9/models/doorOrigin.mtl index e12afb9..773415e 100644 --- a/cw 9/models/doorOrigin.mtl +++ b/cw 9/models/doorOrigin.mtl @@ -1,4 +1,4 @@ -# Blender 3.4.1 MTL File: 'room.blend' +# Blender 3.4.1 MTL File: 'door.blend' # www.blender.org newmtl Material.007 diff --git a/cw 9/models/wardrobeDoorLeft.mtl b/cw 9/models/wardrobeDoorLeft.mtl index 59f8b50..55cdf7a 100644 --- a/cw 9/models/wardrobeDoorLeft.mtl +++ b/cw 9/models/wardrobeDoorLeft.mtl @@ -1,8 +1,8 @@ -# Blender 3.4.1 MTL File: 'room.blend' +# Blender 3.4.1 MTL File: 'wardrobe_door.blend' # www.blender.org -newmtl Material.003 -Ns 0.000000 +newmtl Material +Ns 24.840498 Ka 1.000000 1.000000 1.000000 Ks 0.554348 0.554348 0.554348 Ke 0.000000 0.000000 0.000000 diff --git a/cw 9/models/wardrobeDoorRight.mtl b/cw 9/models/wardrobeDoorRight.mtl index 59f8b50..55cdf7a 100644 --- a/cw 9/models/wardrobeDoorRight.mtl +++ b/cw 9/models/wardrobeDoorRight.mtl @@ -1,8 +1,8 @@ -# Blender 3.4.1 MTL File: 'room.blend' +# Blender 3.4.1 MTL File: 'wardrobe_door.blend' # www.blender.org -newmtl Material.003 -Ns 0.000000 +newmtl Material +Ns 24.840498 Ka 1.000000 1.000000 1.000000 Ks 0.554348 0.554348 0.554348 Ke 0.000000 0.000000 0.000000 diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index 3bcff44..bdd1111 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -102,10 +102,10 @@ float aspectRatio = 1.f; float exposition = 1.f; -float x; -float y; -float z; float r; +float r1; +float r2; + std::vector quadsPositions; glm::vec3 pointlightPos = glm::vec3(0, 2, 0); @@ -320,13 +320,21 @@ void renderScene(GLFWwindow* window) glm::mat4 trans; trans = glm::translate(trans, glm::vec3(8.39806f, 0.021251f, 5.95622f)); trans = glm::rotate(trans, r * glm::radians(180.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + + glm::mat4 transWardrobeDoorR; + transWardrobeDoorR = glm::translate(transWardrobeDoorR, glm::vec3(-5.5f, 1.42f, -4.45f)); + transWardrobeDoorR = glm::rotate(transWardrobeDoorR, r2 * glm::radians(180.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + + glm::mat4 transWardrobeDoorL; + transWardrobeDoorL = glm::translate(transWardrobeDoorL, glm::vec3(-5.5f, 1.42f, -0.38f)); + transWardrobeDoorL = glm::rotate(transWardrobeDoorL, r1 * glm::radians(180.0f), glm::vec3(0.0f, 1.0f, 0.0f)); drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(0.1, 0.4, 0.6), 0.8f, 0.0f); drawObjectPBR(models::bedContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); drawObjectPBR(models::mattressContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); drawObjectPBR(models::wardrobeContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); - drawObjectPBR(models::wardrobeDoorLeftContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); - drawObjectPBR(models::wardrobeDoorRightContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); + drawObjectPBR(models::wardrobeDoorLeftContext, transWardrobeDoorL, glm::vec3(1, 1, 1), 0.8f, 0.0f); + drawObjectPBR(models::wardrobeDoorRightContext, transWardrobeDoorR, glm::vec3(1, 1, 1), 0.8f, 0.0f); drawObjectPBR(models::deskContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); drawObjectPBR(models::chairContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); drawObjectPBR(models::windowContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f); @@ -480,19 +488,29 @@ void processInput(GLFWwindow* window) } if (glfwGetKey(window, GLFW_KEY_7)) { - if (r < -0.55) { r = -0.55; } else { r = r - 0.01; } - - } - if (glfwGetKey(window, GLFW_KEY_8)) { + if (glfwGetKey(window, GLFW_KEY_8)) { if (r >= 0) { r = 0; } else { r = r + 0.01; } } + if (glfwGetKey(window, GLFW_KEY_9)) { + if (r1 < -0.55) { r1 = -0.55; } + else { r1 = r1 - 0.01; } + if (r2 >= 0.55) { r2 = 0.55; } + else { r2 = r2 + 0.01; } + } + if (glfwGetKey(window, GLFW_KEY_0)) { + if (r1 >= 0) { r1 = 0; } + else { r1 = r1 + 0.01; } + if (r2 <= 0) { r2 = 0; } + else { r2 = r2 - 0.01; } + } + //cameraDir = glm::normalize(-cameraPos); }