Add more model with textures

This commit is contained in:
xxxEGOxxx 2023-02-12 20:58:52 +01:00
commit 8462bafdce
12 changed files with 6753 additions and 16 deletions

12
cw 9/models/algae1.mtl Normal file
View File

@ -0,0 +1,12 @@
# Blender 3.4.1 MTL File: 'Akwarium_room.blend'
# www.blender.org
newmtl Material.003
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 1

2188
cw 9/models/algae1.obj Normal file

File diff suppressed because it is too large Load Diff

12
cw 9/models/algae2.mtl Normal file
View File

@ -0,0 +1,12 @@
# Blender 3.4.1 MTL File: 'Akwarium_room.blend'
# www.blender.org
newmtl Material.004
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 1

2188
cw 9/models/algae2.obj Normal file

File diff suppressed because it is too large Load Diff

12
cw 9/models/algae3.mtl Normal file
View File

@ -0,0 +1,12 @@
# Blender 3.4.1 MTL File: 'Akwarium_room.blend'
# www.blender.org
newmtl Material.002
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 1

2188
cw 9/models/algae3.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
# Blender 3.4.1 MTL File: 'Akwarium_room.blend'
# www.blender.org

View File

@ -0,0 +1,39 @@
# Blender 3.4.1
# www.blender.org
mtllib default_terrain.mtl
o Cube.002
v 0.035878 0.002409 5.100057
v 0.035878 0.067083 5.100057
v 0.035878 0.002409 -4.969659
v 0.035878 0.067083 -4.969659
v 8.950408 0.002409 5.100057
v 8.950408 0.067083 5.100057
v 8.950408 0.002409 -4.969659
v 8.950408 0.067083 -4.969659
vn -1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000
vn 1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 1.0000
vn -0.0000 -1.0000 -0.0000
vn -0.0000 1.0000 -0.0000
vt 0.375000 0.000000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.625000 0.000000
vt 0.625000 1.000000
vt 0.875000 0.750000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.500000
vt 0.625000 0.500000
s 0
f 1/1/1 2/4/1 4/9/1 3/7/1
f 3/7/2 4/9/2 8/14/2 7/13/2
f 7/13/3 8/14/3 6/12/3 5/11/3
f 5/11/4 6/12/4 2/5/4 1/2/4
f 3/8/5 7/13/5 5/11/5 1/3/5
f 8/14/6 4/10/6 2/6/6 6/12/6

View File

@ -0,0 +1,2 @@
# Blender 3.4.1 MTL File: 'Akwarium_room.blend'
# www.blender.org

View File

@ -0,0 +1,39 @@
# Blender 3.4.1
# www.blender.org
mtllib glassWindow.mtl
o Cube.001
v -6.858948 1.083408 0.096810
v -6.858948 2.261496 0.096810
v -6.858948 1.083408 -2.484538
v -6.858948 2.261496 -2.484538
v -6.913365 1.083408 0.096810
v -6.913365 2.261496 0.096810
v -6.913365 1.083408 -2.484538
v -6.913365 2.261496 -2.484538
vn 1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000
vn -1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 1.0000
vn -0.0000 -1.0000 -0.0000
vn -0.0000 1.0000 -0.0000
vt 0.375000 0.000000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.625000 0.000000
vt 0.625000 1.000000
vt 0.875000 0.750000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.500000
vt 0.625000 0.500000
s 0
f 1/1/1 3/7/1 4/9/1 2/4/1
f 3/7/2 7/13/2 8/14/2 4/9/2
f 7/13/3 5/11/3 6/12/3 8/14/3
f 5/11/4 1/2/4 2/5/4 6/12/4
f 3/8/5 1/3/5 5/11/5 7/13/5
f 8/14/6 6/12/6 2/6/6 4/10/6

View File

@ -16,7 +16,7 @@
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <string> #include <string>
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; const unsigned int SHADOW_WIDTH = 16384, SHADOW_HEIGHT = 16384;
int WIDTH = 500, HEIGHT = 500; int WIDTH = 500, HEIGHT = 500;
@ -61,6 +61,13 @@ namespace models {
Core::RenderContext plant1DirtContext; Core::RenderContext plant1DirtContext;
Core::RenderContext plant1PotContext; Core::RenderContext plant1PotContext;
Core::RenderContext defaultTerrainContext;
Core::RenderContext algae1Context;
Core::RenderContext algae2Context;
Core::RenderContext algae3Context;
Core::RenderContext glassWindowContext;
} }
namespace texture { namespace texture {
@ -90,6 +97,11 @@ namespace texture {
GLuint plant1DirtTexture; GLuint plant1DirtTexture;
GLuint plant1PotTexture; GLuint plant1PotTexture;
GLuint defaultTerrainTexture;
GLuint algaeTexture;
GLuint glassWindowTexture;
} }
GLuint depthMapFBO; GLuint depthMapFBO;
@ -390,7 +402,19 @@ void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) {
drawObjectDepth(models::doorhandleContext, lightVP, glm::mat4()); drawObjectDepth(models::doorhandleContext, lightVP, glm::mat4());
drawObjectDepth(models::door_next_toContext, lightVP, glm::mat4()); drawObjectDepth(models::door_next_toContext, lightVP, glm::mat4());
drawObjectDepth(models::door_next_to_doorhandleContext, lightVP, glm::mat4()); drawObjectDepth(models::door_next_to_doorhandleContext, lightVP, glm::mat4());
drawObjectDepth(models::defaultTerrainContext, lightVP, glm::mat4());
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
-spaceshipDir.x,-spaceshipDir.y,-spaceshipDir.z,0,
0.,0.,0.,1.,
});
drawObjectDepth(shipContext, lightVP,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)));
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
@ -570,7 +594,7 @@ void renderScene(GLFWwindow* window)
drawObjectPBRWithTexture(models::landContext, glm::mat4(), texture::landTexture, 0.5f, 0.0f, 10); drawObjectPBRWithTexture(models::landContext, glm::mat4(), texture::landTexture, 0.5f, 0.0f, 10);
drawObjectPBRWithTexture(models::sofaBaseContext, glm::mat4(), texture::sofaBaseTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::sofaBaseContext, glm::mat4(), texture::sofaBaseTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::sofaContext, glm::mat4(), texture::sofaTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::sofaContext, glm::mat4(), texture::sofaTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::roofContext, glm::mat4(), texture::roofTexture, 0.8f, 0.0f, 5); drawObjectPBRWithTexture(models::roofContext, glm::mat4(), texture::roofTexture, 0.5f, 0.0f, 5);
drawObjectPBRWithTexture(models::fish2Context, glm::mat4(), texture::fishRedTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::fish2Context, glm::mat4(), texture::fishRedTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::fish3Context, glm::mat4(), texture::fishTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::fish3Context, glm::mat4(), texture::fishTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::door1Context, glm::mat4(), texture::door1Texture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::door1Context, glm::mat4(), texture::door1Texture, 0.5f, 0.0f, 0);
@ -583,13 +607,23 @@ void renderScene(GLFWwindow* window)
drawObjectPBRWithTexture(models::plant1DirtContext, glm::mat4(), texture::plant1DirtTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::plant1DirtContext, glm::mat4(), texture::plant1DirtTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::plant1PotContext, glm::mat4(), texture::plant1PotTexture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::plant1PotContext, glm::mat4(), texture::plant1PotTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::plant1Context, glm::mat4(), texture::plant1Texture, 0.5f, 0.0f, 0); drawObjectPBRWithTexture(models::plant1Context, glm::mat4(), texture::plant1Texture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::defaultTerrainContext, glm::mat4(), texture::defaultTerrainTexture, 0.5f, 0.0f, 5);
drawObjectPBRWithTexture(models::algae1Context, glm::mat4(), texture::algaeTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::algae2Context, glm::mat4(), texture::algaeTexture, 0.5f, 0.0f, 0);
drawObjectPBRWithTexture(models::algae3Context, glm::mat4(), texture::algaeTexture, 0.5f, 0.0f, 0);
//objects with textures that contain transparency should be drawn here (last) //objects with textures that contain transparency should be drawn here (last)
drawObjectPBRWithTexture(models::glassWallContext, glm::mat4(), texture::glassWallTexture, 0.8f, 0.0f, 5); drawObjectPBRWithTexture(models::glassWallContext, glm::mat4(), texture::glassWallTexture, 0.8f, 0.0f, 5);
drawObjectPBRWithTexture(models::aquariumContext, glm::mat4(), texture::aquariumTexture, 0.8f, 0.0f, 5); drawObjectPBRWithTexture(models::aquariumContext, glm::mat4(), texture::aquariumTexture, 0.8f, 0.0f, 5);
drawObjectPBRWithTexture(models::glassWindowContext, glm::mat4(), texture::glassWallTexture, 0.5f, 0.0f, 5);
//Terraingen();
//test depth buffer //test depth buffer
/*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -669,6 +703,13 @@ void init(GLFWwindow* window)
loadModelToContext("./models/plant1dirt.obj", models::plant1DirtContext); loadModelToContext("./models/plant1dirt.obj", models::plant1DirtContext);
loadModelToContext("./models/plant1pot.obj", models::plant1PotContext); loadModelToContext("./models/plant1pot.obj", models::plant1PotContext);
loadModelToContext("./models/default_terrain.obj", models::defaultTerrainContext);
loadModelToContext("./models/algae1.obj", models::algae1Context);
loadModelToContext("./models/algae2.obj", models::algae2Context);
loadModelToContext("./models/algae3.obj", models::algae3Context);
loadModelToContext("./models/glassWindow.obj", models::glassWindowContext);
//loading textures //loading textures
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -698,6 +739,8 @@ void init(GLFWwindow* window)
texture::plant1Texture = Core::LoadTexture("textures/plant1.jpg"); texture::plant1Texture = Core::LoadTexture("textures/plant1.jpg");
texture::plant1DirtTexture = Core::LoadTexture("textures/plant1dirt.jpg"); texture::plant1DirtTexture = Core::LoadTexture("textures/plant1dirt.jpg");
texture::plant1PotTexture = Core::LoadTexture("textures/plant1pot.jpg"); texture::plant1PotTexture = Core::LoadTexture("textures/plant1pot.jpg");
texture::defaultTerrainTexture = Core::LoadTexture("textures/plant1dirt.jpg");
texture::algaeTexture = Core::LoadTexture("textures/algae.jpg");
// //
//prepering skybox //prepering skybox
@ -797,36 +840,48 @@ void processInput(GLFWwindow* window)
glfwSetWindowShouldClose(window, true); glfwSetWindowShouldClose(window, true);
} }
float minX = -1000.f, maxX = 1000.f, minY = -1000.f, maxY = 1000.f, minZ = -1000.f, maxZ = 1000.f; //float minX = -1000.f, maxX = 1000.f, minY = -1000.f, maxY = 1000.f, minZ = -1000.f, maxZ = 1000.f;
//float minX = -6.f, maxX = -0.47f, minY = 0.65f, maxY = 2.5f, minZ = -4.4f, maxZ = 4.5f; float minX = -6.f, maxX = -0.47f, minY = 0.65f, maxY = 2.5f, minZ = -4.4f, maxZ = 4.5f;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos + spaceshipDir * moveSpeed; glm::vec3 newPos = spaceshipPos + spaceshipDir * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos - spaceshipDir * moveSpeed; glm::vec3 newPos = spaceshipPos - spaceshipDir * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_A) == 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_D) == 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_C) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos + spaceshipSide * moveSpeed; glm::vec3 newPos = spaceshipPos + spaceshipSide * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos - spaceshipSide * moveSpeed; glm::vec3 newPos = spaceshipPos - spaceshipSide * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos + spaceshipUp * moveSpeed; glm::vec3 newPos = spaceshipPos + spaceshipUp * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) {
glm::vec3 newPos = spaceshipPos - spaceshipUp * moveSpeed; glm::vec3 newPos = spaceshipPos - spaceshipUp * moveSpeed;
if (newPos.x > minX && newPos.x < maxX && newPos.y > minY && newPos.y < maxY && newPos.z > minZ && newPos.z < maxZ) { if (newPos.x > minX && newPos.x < maxX) spaceshipPos.x = newPos.x;
spaceshipPos = newPos;}} if (newPos.y > minY && newPos.y < maxY) spaceshipPos.y = newPos.y;
if (newPos.z > minZ && newPos.z < maxZ) spaceshipPos.z = newPos.z;
}
/* /*
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)

BIN
cw 9/textures/algae.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB