Element interaktywny - drzwi
This commit is contained in:
parent
6637e01913
commit
31aa966162
12
cw 9/models/doorOrigin.mtl
Normal file
12
cw 9/models/doorOrigin.mtl
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Blender 3.4.1 MTL File: 'room.blend'
|
||||||
|
# www.blender.org
|
||||||
|
|
||||||
|
newmtl Material.007
|
||||||
|
Ns 250.000000
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd C:/Users/obses/Downloads/doorTexture.png
|
Binary file not shown.
@ -72,7 +72,6 @@ GLuint depthMap;
|
|||||||
|
|
||||||
GLuint program;
|
GLuint program;
|
||||||
GLuint programSun;
|
GLuint programSun;
|
||||||
GLuint programTest;
|
|
||||||
GLuint programTex;
|
GLuint programTex;
|
||||||
GLuint programDepth;
|
GLuint programDepth;
|
||||||
|
|
||||||
@ -83,16 +82,18 @@ Core::RenderContext sphereContext;
|
|||||||
|
|
||||||
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
||||||
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
||||||
|
|
||||||
|
//glm::vec3 sunPos = glm::vec3(-3.631, 9.78959, 5.59173);
|
||||||
|
//glm::vec3 sunDir = glm::vec3(-65.985, 7.96228, 33.1559);
|
||||||
|
|
||||||
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f)*5;
|
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f)*5;
|
||||||
|
|
||||||
// macierz light view point - punkt widzenia światła
|
// macierz light view point - punkt widzenia światła
|
||||||
glm::mat4 lightVP = glm::ortho(-4.f, 2.5f, -2.f, 5.f, 1.0f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
glm::mat4 lightVP = glm::ortho(-4.f, 2.5f, -2.f, 5.f, 1.0f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
||||||
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f);
|
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f);
|
||||||
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
|
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
|
||||||
GLuint VAO,VBO;
|
GLuint VAO,VBO;
|
||||||
@ -101,16 +102,24 @@ float aspectRatio = 1.f;
|
|||||||
|
|
||||||
float exposition = 1.f;
|
float exposition = 1.f;
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float r;
|
||||||
|
std::vector<glm::vec3> quadsPositions;
|
||||||
|
|
||||||
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
|
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
|
||||||
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
|
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
|
||||||
|
|
||||||
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||||
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||||
|
|
||||||
|
//glm::vec3 spotlightPos = glm::vec3(-3.631, 9.78959, 5.59173);
|
||||||
|
//glm::vec3 spotlightConeDir = glm::vec3(-65.985, 7.96228, 33.1559);
|
||||||
|
|
||||||
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9)*3;
|
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9)*3;
|
||||||
float spotlightPhi = 3.14 / 4;
|
float spotlightPhi = 3.14 / 4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float lastTime = -1.f;
|
float lastTime = -1.f;
|
||||||
float deltaTime = 0.f;
|
float deltaTime = 0.f;
|
||||||
|
|
||||||
@ -188,7 +197,6 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
|||||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||||
|
|
||||||
|
|
||||||
glUniform1f(glGetUniformLocation(program, "shadowMapWidth"), SHADOW_WIDTH);
|
glUniform1f(glGetUniformLocation(program, "shadowMapWidth"), SHADOW_WIDTH);
|
||||||
glUniform1f(glGetUniformLocation(program, "shadowMapHeight"), SHADOW_HEIGHT);
|
glUniform1f(glGetUniformLocation(program, "shadowMapHeight"), SHADOW_HEIGHT);
|
||||||
|
|
||||||
@ -200,6 +208,17 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID) {
|
||||||
|
glUseProgram(programTex);
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "lightPos"), 0, 0, 0);
|
||||||
|
Core::SetActiveTexture(textureID, "colorTexture", programTex, 0);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// metoda inicjalizująca mapę głębokości
|
// metoda inicjalizująca mapę głębokości
|
||||||
void initDepthMap() {
|
void initDepthMap() {
|
||||||
@ -298,6 +317,10 @@ void renderScene(GLFWwindow* window)
|
|||||||
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)),
|
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)),
|
||||||
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0);
|
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0);
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(0.1, 0.4, 0.6), 0.8f, 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::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::mattressContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
@ -311,7 +334,7 @@ void renderScene(GLFWwindow* window)
|
|||||||
drawObjectPBR(models::shelfContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::shelfContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::lampContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::lampContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::paintingContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::paintingContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::doorContext, trans, glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::doorframeContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::doorframeContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::floorthingContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::floorthingContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
drawObjectPBR(models::booksContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
drawObjectPBR(models::booksContext, glm::mat4(), glm::vec3(1, 1, 1), 0.8f, 0.0f);
|
||||||
@ -328,11 +351,6 @@ void renderScene(GLFWwindow* window)
|
|||||||
0.,0.,0.,1.,
|
0.,0.,0.,1.,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//drawObjectColor(shipContext,
|
|
||||||
// glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
|
||||||
// glm::vec3(0.3, 0.3, 0.5)
|
|
||||||
// );
|
|
||||||
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)),
|
||||||
glm::vec3(0.3, 0.3, 0.5),
|
glm::vec3(0.3, 0.3, 0.5),
|
||||||
@ -342,15 +360,6 @@ void renderScene(GLFWwindow* window)
|
|||||||
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
|
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
|
||||||
spotlightConeDir = spaceshipDir;
|
spotlightConeDir = spaceshipDir;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//test depth buffer
|
|
||||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
//glUseProgram(programTest);
|
|
||||||
//glActiveTexture(GL_TEXTURE0);
|
|
||||||
//glBindTexture(GL_TEXTURE_2D, depthMap);
|
|
||||||
//Core::DrawContext(models::testContext);
|
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
@ -381,14 +390,14 @@ void init(GLFWwindow* window)
|
|||||||
// enable testowania mapy głębokości
|
// enable testowania mapy głębokości
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
||||||
program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
|
program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
|
||||||
programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
|
|
||||||
programSun = shaderLoader.CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
|
programSun = shaderLoader.CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
|
||||||
|
|
||||||
// program odpowiadający za generowanie mapy głębokości
|
// program odpowiadający za generowanie mapy głębokości
|
||||||
programDepth = shaderLoader.CreateProgram("shaders/shader_depth.vert", "shaders/shader_depth.frag");
|
programDepth = shaderLoader.CreateProgram("shaders/shader_depth.vert", "shaders/shader_depth.frag");
|
||||||
|
|
||||||
|
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||||
|
|
||||||
loadModelToContext("./models/room.obj", models::roomContext);
|
loadModelToContext("./models/room.obj", models::roomContext);
|
||||||
loadModelToContext("./models/bed.obj", models::bedContext);
|
loadModelToContext("./models/bed.obj", models::bedContext);
|
||||||
loadModelToContext("./models/materace.obj", models::mattressContext);
|
loadModelToContext("./models/materace.obj", models::mattressContext);
|
||||||
@ -402,7 +411,7 @@ void init(GLFWwindow* window)
|
|||||||
loadModelToContext("./models/shelf.obj", models::shelfContext);
|
loadModelToContext("./models/shelf.obj", models::shelfContext);
|
||||||
loadModelToContext("./models/lamp.obj", models::lampContext);
|
loadModelToContext("./models/lamp.obj", models::lampContext);
|
||||||
loadModelToContext("./models/painting.obj", models::paintingContext);
|
loadModelToContext("./models/painting.obj", models::paintingContext);
|
||||||
loadModelToContext("./models/door.obj", models::doorContext);
|
loadModelToContext("./models/doorOrigin.obj", models::doorContext);
|
||||||
loadModelToContext("./models/doorframe.obj", models::doorframeContext);
|
loadModelToContext("./models/doorframe.obj", models::doorframeContext);
|
||||||
loadModelToContext("./models/floorthing.obj", models::floorthingContext);
|
loadModelToContext("./models/floorthing.obj", models::floorthingContext);
|
||||||
loadModelToContext("./models/books.obj", models::booksContext);
|
loadModelToContext("./models/books.obj", models::booksContext);
|
||||||
@ -470,6 +479,20 @@ void processInput(GLFWwindow* window)
|
|||||||
printf("spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", spaceshipDir.x, spaceshipDir.y, spaceshipDir.z);
|
printf("spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", spaceshipDir.x, spaceshipDir.y, spaceshipDir.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 (r >= 0) { r = 0; }
|
||||||
|
else { r = r + 0.01; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//cameraDir = glm::normalize(-cameraPos);
|
//cameraDir = glm::normalize(-cameraPos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user