deszcz poza pokojem

This commit is contained in:
AnielaWalczak 2023-02-10 22:58:05 +01:00
parent e214a19f45
commit de7216a411
24 changed files with 240 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>C:\Users\Anna Niczyporuk\source\repos\GRK_Projectnew\Debug\grk-cw9.exe</FullPath> <FullPath>C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\Debug\grk-cw9.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

View File

@ -1 +1,65 @@
 grk-cw9.vcxproj -> C:\Users\Anna Niczyporuk\source\repos\GRK_Projectnew\Debug\grk-cw9.exe  main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(87,16): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(88,14): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(90,17): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(91,15): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(101,9): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(111,29): warning C4244: 'return': conversion from 'int' to 'float', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\Collision_System.cpp(115,29): warning C4244: 'return': conversion from 'int' to 'float', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(242,30): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(259,17): warning C4101: 'data': unreferenced local variable
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(284,38): warning C4305: '=': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(313,16): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(507,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(523,98): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(526,68): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(587,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(588,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(589,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(592,31): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(593,25): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(648,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(649,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(650,8): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(653,31): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(654,25): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(730,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(738,108): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(746,87): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(746,223): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(749,59): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(750,37): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(782,2): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(875,108): warning C4305: 'argument': truncation from 'double' to 'T'
with
[
T=float
]
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(1112,21): warning C4305: '-=': truncation from 'double' to 'float'
C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\cw 9\src\ex_9_1.hpp(1114,21): warning C4305: '+=': truncation from 'double' to 'float'
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
grk-cw9.vcxproj -> C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\Debug\grk-cw9.exe

View File

@ -1,2 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0: PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.30.30705:TargetPlatformVersion=10.0.19041.0:
Debug|Win32|C:\Users\Anna Niczyporuk\source\repos\GRK_Projectnew\| Debug|Win32|C:\Users\walcz\Desktop\nowe\GRK_Project\GRK_Project\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,13 @@
#version 410 core
uniform vec3 objectColor;
uniform vec3 lightDir;
in vec3 interpNormal;
void main()
{
vec3 normal = normalize(interpNormal);
float diffuse = 0.4;
gl_FragColor = vec4(objectColor * diffuse, 1.0);
}

View File

@ -0,0 +1,16 @@
#version 410 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelMatrix;
out vec3 interpNormal;
void main()
{
gl_Position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0);
interpNormal = (modelMatrix * vec4(vertexNormal, 0.0)).xyz;
}

View File

@ -193,14 +193,26 @@ GLuint programDepth;
GLuint programSkybox; GLuint programSkybox;
GLuint programWater; GLuint programWater;
GLuint skyboxTexture; GLuint skyboxTexture;
GLuint bubblesColor;
GLuint bubbleTexture;
Core::RenderContext bubbleContext;
Core::Shader_Loader shaderLoader; Core::Shader_Loader shaderLoader;
Core::RenderContext waterContext; Core::RenderContext waterContext;
Core::RenderContext shipContext; Core::RenderContext shipContext;
Core::RenderContext sphereContext; Core::RenderContext sphereContext;
TriangleSoup water; TriangleSoup water;
CONST int bubbleQuantity = 2000;
glm::vec3 bubbleLocation[bubbleQuantity];
glm::vec3 bubbleOriginalLocation[bubbleQuantity];
bool bubbleZdir[bubbleQuantity];
bool bubbleXdir[bubbleQuantity];
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 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5; glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5;
@ -230,6 +242,8 @@ glm::vec3 lightPos = glm::vec3(-8, 4, 2);
float lastTime = -1.f; float lastTime = -1.f;
float deltaTime = 0.f; float deltaTime = 0.f;
void bubbleManager();
unsigned int loadSkybox(std::vector<std::string> faces) unsigned int loadSkybox(std::vector<std::string> faces)
{ {
unsigned int textureID; unsigned int textureID;
@ -465,6 +479,23 @@ void drawObjectDepth(Core::RenderContext context, glm::mat4 viewProjectionMatrix
glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix); glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawContext(context); Core::DrawContext(context);
} }
void drawBubbleColor(Core::RenderContext context, glm::mat4 modelMatrix, glm::vec3 color)
{
GLuint program = bubblesColor;
glUseProgram(program);
glUniform3f(glGetUniformLocation(program, "objectColor"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(program, "lightDir"), sunDir.x, sunDir.y, sunDir.z);
glm::mat4 transformation = createPerspectiveMatrix() * createCameraMatrix() * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(program, "modelViewProjectionMatrix"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawContext(context);
glUseProgram(0);
}
void renderShadowapSun() { void renderShadowapSun() {
@ -504,7 +535,6 @@ void renderShadowapSun() {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
} }
@ -545,6 +575,97 @@ void drawObjectColorWater(Core::RenderContext& context, glm::mat4 modelMatrix, g
water.render(); water.render();
} }
void bubbleMovement(int i) {
float bubbleWobblingDivider = 100;
int x = floor(bubbleLocation[i].x);
int y = floor(bubbleLocation[i].y);
int z = floor(bubbleLocation[i].z);
float bubbleWobbling = 0.0005;
float bubbleDown = 0.05;
//printf(xDir ? "true\n" : "false\n");
//printf(zDir ? "true\n" : "false\n");
if (bubbleLocation[i].x >= bubbleOriginalLocation[i].x + bubbleWobbling * bubbleWobblingDivider) {
bubbleXdir[i] = false;
//printf("herex1\n");
}
else if (bubbleLocation[i].x < bubbleOriginalLocation[i].x - bubbleWobbling * bubbleWobblingDivider) {
bubbleXdir[i] = true;
//printf("herex2\n");
}
if (bubbleLocation[i].z >= bubbleOriginalLocation[i].z + bubbleWobbling * bubbleWobblingDivider) {
bubbleZdir[i] = false;
}
else if (bubbleLocation[i].z < bubbleOriginalLocation[i].z - bubbleWobbling * bubbleWobblingDivider) {
bubbleZdir[i] = true;
}
bubbleZdir[i] = false;
bubbleXdir[i] = false;
if (bubbleXdir[i]) {
bubbleLocation[i].x += bubbleWobbling;
}
else {
bubbleLocation[i].x -= bubbleWobbling;
}
if (bubbleZdir[i]) {
bubbleLocation[i].z += bubbleWobbling;
}
else {
bubbleLocation[i].z -= bubbleWobbling;
}
if (y <= -10.0 ) {
bubbleLocation[i].y = 10.0;
}
if (x <= (-1.0 + 2.9) && x > (-1.0 - 2.9) && z <= (-1.2 + 3.2) && z > (-1.2 - 3.2) && y <= (1.0 + 2.36) ) {
bubbleLocation[i].y = 10.0;
}
bubbleLocation[i].y -= bubbleDown;
}
void bubbleManager() {
for (int i = 0; i < bubbleQuantity; i++)
{
bubbleMovement(i);
glm::mat4 modelMatrix = glm::translate(bubbleLocation[i]);
// Scaling models
glm::vec3 scale = glm::vec3(0.01, 0.04, 0.02);
modelMatrix = glm::scale(modelMatrix, scale);
//glUseProgram(programTex);
drawObjectTex(bubbleContext, modelMatrix, 0, 0, texture::water);
//drawBubbleColor(bubbleContext, modelMatrix, glm::vec3(.3f, .55f, 0.96f));
// srand(time(NULL));
float MAX_NUM = 20.0;
//bubbleLocation[i].x = (((float)rand() / (float)(RAND_MAX)) * MAX_NUM) - MAX_NUM / 2;
bubbleLocation[i].y = (((float)rand() / (float)(RAND_MAX)) * 10) - 5;
//bubbleLocation[i].z = (((float)rand() / (float)(RAND_MAX)) * MAX_NUM) - MAX_NUM / 2;
bubbleOriginalLocation[i] = bubbleLocation[i];
bubbleZdir[i] = true;
bubbleXdir[i] = false;
}
}
void renderScene(GLFWwindow* window) void renderScene(GLFWwindow* window)
{ {
@ -646,19 +767,6 @@ void renderScene(GLFWwindow* window)
drawObjectTexPBR_ARM(models::c_tableContext, glm::mat4(), texture::c_table_albedo, texture::c_table_normal, texture::c_table_arm); drawObjectTexPBR_ARM(models::c_tableContext, glm::mat4(), texture::c_table_albedo, texture::c_table_normal, texture::c_table_arm);
drawObjectTexPBR_ARM(models::vaseContext, glm::mat4(), texture::vase_albedo, texture::vase_normal, texture::vase_arm); drawObjectTexPBR_ARM(models::vaseContext, glm::mat4(), texture::vase_albedo, texture::vase_normal, texture::vase_arm);
glUseProgram(programWater); glUseProgram(programWater);
//drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0, -1.0, 0.0)) * glm::scale(glm::vec3(30.0)), glm::vec3(0.1, 0.1, 0.95), time, texture::water); //drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0, -1.0, 0.0)) * glm::scale(glm::vec3(30.0)), glm::vec3(0.1, 0.1, 0.95), time, texture::water);
drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0f, -1.7f, 0.0f)), glm::vec4(0.1, 0.1, 0.95, 0.5), time, texture::water); drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0f, -1.7f, 0.0f)), glm::vec4(0.1, 0.1, 0.95, 0.5), time, texture::water);
@ -671,7 +779,8 @@ void renderScene(GLFWwindow* window)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depthMap); glBindTexture(GL_TEXTURE_2D, depthMap);
Core::DrawContext(models::testContext);*/ Core::DrawContext(models::testContext);*/
bubbleManager();
glUseProgram(0); glUseProgram(0);
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
@ -720,6 +829,7 @@ void init(GLFWwindow* window)
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag"); programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
programTexPBR = shaderLoader.CreateProgram("shaders/shader_tex_pbr.vert", "shaders/shader_tex_pbr.frag"); programTexPBR = shaderLoader.CreateProgram("shaders/shader_tex_pbr.vert", "shaders/shader_tex_pbr.frag");
programTexPBR_ARM = shaderLoader.CreateProgram("shaders/shader_tex_pbr_arm.vert", "shaders/shader_tex_pbr_arm.frag"); programTexPBR_ARM = shaderLoader.CreateProgram("shaders/shader_tex_pbr_arm.vert", "shaders/shader_tex_pbr_arm.frag");
bubblesColor = shaderLoader.CreateProgram("shaders/bubbles_shader_color.vert", "shaders/bubbles_shader_color.frag");
water.readOBJ("./models/plane2.obj"); water.readOBJ("./models/plane2.obj");
texture::water = Core::LoadTexture("textures/test.png"); texture::water = Core::LoadTexture("textures/test.png");
texture::rust = Core::LoadTexture("textures/rust.jpg"); texture::rust = Core::LoadTexture("textures/rust.jpg");
@ -821,7 +931,7 @@ void init(GLFWwindow* window)
texture::vase_normal = Core::LoadTexture("textures/vase/normal.png"); texture::vase_normal = Core::LoadTexture("textures/vase/normal.png");
loadModelToContext("models/bubble.obj", bubbleContext, false);
loadModelToContext("./models/sphere.obj", sphereContext, false); loadModelToContext("./models/sphere.obj", sphereContext, false);
loadModelToContext("./models/spaceship.obj", shipContext, false); loadModelToContext("./models/spaceship.obj", shipContext, false);
//loadModelToContext("./models/bed.obj", models::bedContext, true); //loadModelToContext("./models/bed.obj", models::bedContext, true);
@ -866,7 +976,7 @@ void init(GLFWwindow* window)
loadModelToContext("./models/uploads_files_1938755_KAUSTBY.obj", models::chairContext, false); loadModelToContext("./models/uploads_files_1938755_KAUSTBY.obj", models::chairContext, false);
loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, true); loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, true);
//collisionSystem.calculateSceneBounding(); //collisionSystem.calculateSceneBounding();
skyboxTexture = loadSkybox(faces); skyboxTexture = loadSkybox(faces);
//drawSkybox(models::cubeContext, transformation, skyboxTexture); //drawSkybox(models::cubeContext, transformation, skyboxTexture);
/*glUseProgram(programSkybox); /*glUseProgram(programSkybox);
@ -914,6 +1024,22 @@ void processInput(GLFWwindow* window)
texture::screen = Core::LoadTexture("textures/visual.png"); texture::screen = Core::LoadTexture("textures/visual.png");
PlaySound(nullptr, nullptr, 0); PlaySound(nullptr, nullptr, 0);
} }
if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) {
for (int i = 0; i < bubbleQuantity; i++)
{
// srand(time(NULL));
float MAX_NUM = 20.0;
bubbleLocation[i].x = (((float)rand() / (float)(RAND_MAX)) * MAX_NUM) - MAX_NUM / 2;
bubbleLocation[i].y = (((float)rand() / (float)(RAND_MAX)) * 10) - 5;
bubbleLocation[i].z = (((float)rand() / (float)(RAND_MAX)) * MAX_NUM) - MAX_NUM / 2;
bubbleOriginalLocation[i] = bubbleLocation[i];
bubbleZdir[i] = true;
bubbleXdir[i] = false;
}
}
cameraDir = spaceshipDir; cameraDir = spaceshipDir;
cameraPos = newSpaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f; cameraPos = newSpaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;