This commit is contained in:
s459310 2022-02-28 21:07:18 +01:00
parent a475f48922
commit ac7077596e
25 changed files with 112651 additions and 90 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,50 +1 @@
 Camera.cpp
main_2_1a.cpp
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(111,23): warning C4305: 'initializing': truncation from 'double' to 'float'
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(168,23): warning C4018: '<': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(250,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(251,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(514,69): warning C4305: 'argument': truncation from 'double' to 'float'
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(631,15): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
ParticleEmitter.cpp
G:\studia\grafika komputerowa\ggit\cw 2\src\ParticleEmitter.cpp(9,20): warning C4018: '<': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\ParticleEmitter.cpp(49,20): warning C4018: '<': signed/unsigned mismatch
Render_Utils.cpp
Shader_Loader.cpp
Physics.cpp
Texture.cpp
Generating Code...
image_DXT.c
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_DXT.c(92,9): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
image_helper.c
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_helper.c(325,22): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_helper.c(366,13): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_helper.c(373,20): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_helper.c(415,13): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\image_helper.c(422,20): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
SOIL.c
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\SOIL.c(1719,36): warning C4018: '<=': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\SOIL.c(1729,19): warning C4018: '<': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\SOIL.c(1841,6): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
stb_image_aug.c
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(177,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(251,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(303,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(1557,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(2394,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(2709,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(2995,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(3209,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(3548,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stb_image_aug.c(3644,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stbi_DDS_aug_c.h(362,19): warning C4018: '>': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stbi_DDS_aug_c.h(366,19): warning C4018: '>': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stbi_DDS_aug_c.h(390,19): warning C4018: '<': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stbi_DDS_aug_c.h(427,19): warning C4018: '<': signed/unsigned mismatch
G:\studia\grafika komputerowa\ggit\cw 2\src\SOIL\stbi_DDS_aug_c.h(498,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Generating Code...
Camera.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
grk-cw2.vcxproj -> G:\studia\grafika komputerowa\ggit\Debug\grk-cw2.exe
 grk-cw2.vcxproj -> G:\studia\grafika komputerowa\ggit\Debug\grk-cw2.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

48040
cw 2/models/fish1.obj Normal file

File diff suppressed because it is too large Load Diff

8054
cw 2/models/fish2.obj Normal file

File diff suppressed because it is too large Load Diff

12299
cw 2/models/plant1.obj Normal file

File diff suppressed because it is too large Load Diff

44181
cw 2/models/whale.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,5 @@ float logisticDepth(float depth)
void main()
{
float depth = logisticDepth(gl_FragCoord.z);
FragColor = texture(skybox, TexCoords) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 70.0f/255.0f, 80.0f/255.0f), 1.0f);
//FragColor = texture(skybox, TexCoords) * (1.0f - depth) + vec4(depth * vec3(102.0f/255.0f, 172.0f/255.0f, 233.0f/255.0f), 1.0f);
//FragColor = texture(skybox, TexCoords);
FragColor = texture(skybox, TexCoords) * (1.0f - depth) + vec4(depth * vec3(27.0f/255.0f, 104.0f/255.0f, 149.0f/255.0f), 1.0f);
}

View File

@ -21,6 +21,7 @@
#define SCREEN_X 1280
#define SCREEN_Y 720
#define SEAWEED_NUM 200
#define PLANT1_NUM 100
#define FISH_NUM 100
#define PARTICLE_NUM 300
#define GROUND_XY 168
@ -31,6 +32,7 @@ GLuint programColor;
GLuint programTexture;
GLuint programSkyBox;
auto radians = 0.01f;
struct fish
@ -95,11 +97,11 @@ float cubeMapVertices[] = {
SIZE, -SIZE, SIZE
};
// Modele
obj::Model groundModel, boxModel, sphereModel, seaweedModel, fishModel, submarineModel, particleModel, geyserModel;
obj::Model groundModel, boxModel, sphereModel, seaweedModel, fishModel1, submarineModel, particleModel, geyserModel, fishModel2, plantModel1;
// Contexty
Core::RenderContext groundContext, boxContext, sphereContext, seaweedContext, fishContext, submarineContext, particleContext, geyserContext;
Core::RenderContext groundContext, boxContext, sphereContext, seaweedContext, fishContext1, submarineContext, particleContext, geyserContext, fishContext2, plantContext1;
// Tekstury
GLuint boxTexture, groundTexture, seaweedTexture, cubeMapTexture, submarineTexture, particleTexture, geyserTexture;
GLuint boxTexture, groundTexture, seaweedTexture, cubeMapTexture, submarineTexture, particleTexture, geyserTexture, fishTexture1, fishTexture2, plantTexture1;
// Kamera
float cameraAngle = 0;
float y_rotation_angle;
@ -110,7 +112,7 @@ int xPos, yPos = 0;
float angleSpeed = 0.01f;
float moveSpeed = 0.15;
int boatMoving = 0;
int transformMatrix[6] = { 0, 0, 0, 0, 0, 0};
int transformMatrix[6] = { 0, 0, 0, 0, 0, 0 };
glm::vec3 cameraPos = glm::vec3(0, 35, 10);
glm::vec3 cameraSide;
glm::vec3 cameraVert;
@ -120,7 +122,7 @@ glm::mat4 cameraMatrix, perspectiveMatrix;
glm::mat4 groundMatrix;
glm::quat rotation = glm::quat(1, 0, 0, 0);
std::vector<glm::vec3> seaweedPosition;
std::vector<glm::vec3> plantPosition;
std::vector<glm::vec3> fishPosition;
std::vector<fish> fishList;
std::vector<std::vector<particle>> particleList;
@ -180,8 +182,8 @@ glm::vec3 search_for_y(float objX, float objZ, obj::Model model)
void keyDown(unsigned char key, int x, int y)
{
if (boatMoving < 3)
{
if (boatMoving < 3)
{
}
switch (key)
@ -349,11 +351,11 @@ void initBubbles() {
}
}
void initSeaweed() {
for (int i = 0; i < SEAWEED_NUM; i++) {
for (int i = 0; i < SEAWEED_NUM + PLANT1_NUM; i++) {
float plantX = static_cast<float>(rand() % (2 * GROUND_XY) - GROUND_XY);
float plantZ = static_cast<float>(rand() % (2 * GROUND_XY) - GROUND_XY);
glm::vec3 plant_pos = search_for_y(plantX, plantZ, groundModel);
seaweedPosition.push_back(plant_pos);
plantPosition.push_back(plant_pos);
}
}
@ -434,17 +436,23 @@ void renderSeaweed()
{
for (int i = 0; i < SEAWEED_NUM; i++) {
glm::mat4 seaweedMatrix = glm::translate(seaweedPosition[i]);
glm::mat4 seaweedMatrix = glm::translate(plantPosition[i]);
drawObjectColor(&seaweedContext, seaweedMatrix, glm::vec3(0.1f, 0.6f, 0.1f));
}
for (int i = SEAWEED_NUM; i < SEAWEED_NUM + PLANT1_NUM; i++)
{
glm::mat4 plant1Matrix = glm::translate(plantPosition[i]) * scale(glm::vec3(0.2f));
drawObjectTexture(&plantContext1, plant1Matrix, plantTexture1);
}
}
void renderFish()
{
glm::mat4 fishMatrix;
glm::mat4 fishMatrix1;
glm::mat4 fishMatrix2;
float fishSpeed = 0.05f;
for (int i = 0; i < FISH_NUM; i++) {
int result = rand() % (20000 - fishList[i].counter);
int result = rand() % (1200 - fishList[i].counter);
if (result == 0)
{
fishList[i].rotation = rand() % 4;
@ -455,23 +463,46 @@ void renderFish()
fishList[i].counter += 1;
}
switch (fishList[i].rotation)
if (i % 2 == 0)
{
case 0:
fishList[i].position.z -= fishSpeed;
break;
case 1:
fishList[i].position.x -= fishSpeed;
break;
case 2:
fishList[i].position.z += fishSpeed;
break;
case 3:
fishList[i].position.x += fishSpeed;
break;
switch (fishList[i].rotation)
{
case 0:
fishList[i].position.x += fishSpeed;
break;
case 1:
fishList[i].position.z -= fishSpeed;
break;
case 2:
fishList[i].position.x -= fishSpeed;
break;
case 3:
fishList[i].position.z += fishSpeed;
break;
}
fishMatrix1 = glm::translate(fishList[i].position) * glm::rotate(glm::radians(fishList[i].rotation * 90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.7f));
drawObjectTexture(&fishContext1, fishMatrix1, fishTexture1);
}
else
{
switch (fishList[i].rotation)
{
case 0:
fishList[i].position.z += fishSpeed;
break;
case 1:
fishList[i].position.x += fishSpeed;
break;
case 2:
fishList[i].position.z -= fishSpeed;
break;
case 3:
fishList[i].position.x -= fishSpeed;
break;
}
fishMatrix2 = glm::translate(fishList[i].position) * glm::rotate(glm::radians(fishList[i].rotation * 90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.5f));
drawObjectTexture(&fishContext2, fishMatrix2, fishTexture2);
}
fishMatrix = glm::translate(fishList[i].position) * glm::rotate(glm::radians(fishList[i].rotation * 90.0f), glm::vec3(0, 1, 0));
drawObjectColor(&fishContext, fishMatrix, fishList[i].color);
}
}
void renderBubbles()
@ -527,9 +558,9 @@ void renderScene()
}
else if (i == 2 && transformMatrix[2] == 1)
{
rotation = glm::angleAxis(angleSpeed, glm::vec3(0, -1, 0)) * rotation;
//cameraPos += cameraVert * moveSpeed; break;
rotation = glm::angleAxis(angleSpeed, glm::vec3(0, -1, 0)) * rotation;
//cameraPos += cameraVert * moveSpeed; break;
}
else if (i == 3 && transformMatrix[3] == 1)
{
@ -537,7 +568,7 @@ void renderScene()
//boatMoving = 1;
//cameraPos -= cameraVert * moveSpeed; break;
}
else if (i == 4 && transformMatrix[4] == 1)
else if (i == 4 && transformMatrix[4] == 1)
{
rotation = glm::angleAxis(angleSpeed, glm::vec3(-1, 0, 0)) * rotation;
//boatMoving = 1;
@ -546,8 +577,8 @@ void renderScene()
else if (i == 5 && transformMatrix[5] == 1)
{
rotation = glm::angleAxis(angleSpeed, glm::vec3(1, 0, 0)) * rotation;
// boatMoving = 1;
//cameraPos += cameraSide * moveSpeed; break;
// boatMoving = 1;
//cameraPos += cameraSide * moveSpeed; break;
}
}
@ -589,23 +620,30 @@ void init()
groundModel = obj::loadModelFromFile("models/ground.obj");
seaweedModel = obj::loadModelFromFile("models/seaweed.obj");
fishModel = obj::loadModelFromFile("models/fish.obj");
fishModel1 = obj::loadModelFromFile("models/fish1.obj");
fishModel2 = obj::loadModelFromFile("models/fish2.obj");
submarineModel = obj::loadModelFromFile("models/submarine.obj");
particleModel = obj::loadModelFromFile("models/sphere.obj");
geyserModel = obj::loadModelFromFile("models/geyser.obj");
plantModel1 = obj::loadModelFromFile("models/plant1.obj");
groundTexture = Core::LoadTexture("textures/sand.jpg");
groundTexture = Core::LoadTexture("textures/diffuse.jpg");
seaweedTexture = Core::LoadTexture("textures/sea.jpg");
submarineTexture = Core::LoadTexture("textures/Base_color.png");
particleTexture = Core::LoadTexture("textures/bubble.jpg");
particleTexture = Core::LoadTexture("textures/bubble2.png");
geyserTexture = Core::LoadTexture("textures/geyser.jpg");
fishTexture1 = Core::LoadTexture("textures/fish1.jpg");
fishTexture2 = Core::LoadTexture("textures/fish2.png");
plantTexture1 = Core::LoadTexture("textures/plant1.png");
groundContext.initFromOBJ(groundModel);
seaweedContext.initFromOBJ(seaweedModel);
fishContext.initFromOBJ(fishModel);
fishContext1.initFromOBJ(fishModel1);
fishContext2.initFromOBJ(fishModel2);
submarineContext.initFromOBJ(submarineModel);
particleContext.initFromOBJ(particleModel);
geyserContext.initFromOBJ(geyserModel);
plantContext1.initFromOBJ(plantModel1);
initFish();
initSeaweed();

BIN
cw 2/textures/bubble2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

BIN
cw 2/textures/diffuse.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
cw 2/textures/fish1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
cw 2/textures/fish2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 KiB

BIN
cw 2/textures/fish2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

BIN
cw 2/textures/plant1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB