Element interaktywny - ruchome drzwi szafy

This commit is contained in:
s464903 2023-02-11 19:00:40 +01:00
parent 31aa966162
commit 0bddd667ee
4 changed files with 34 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<glm::vec3> 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);
}