Add new sub and shipwreck.

This commit is contained in:
Michal Zaporski 2022-01-23 17:42:46 +01:00
parent 770cdb4b47
commit 44ce730c8b
5 changed files with 386596 additions and 4 deletions

217926
cw 6/models/shipwreck.obj Normal file

File diff suppressed because it is too large Load Diff

168658
cw 6/models/sub.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@ Core::RenderContext crabContext;
Core::RenderContext coralTreeContext;
Core::RenderContext coralContext;
Core::RenderContext gorgonianCoralContext;
Core::RenderContext shipwreckContext;
int firstFishPositions[15][3];
int secondFishPositions[15][3];
@ -56,6 +57,8 @@ GLuint textureSecondFish;
GLuint textureThirdFish;
GLuint textureSeaTurtle;
GLuint textureCrab;
GLuint textureSand;
GLuint textureBoards;
void keyboard(unsigned char key, int x, int y)
{
@ -154,14 +157,14 @@ void renderScene()
float time = glutGet(GLUT_ELAPSED_TIME) / 1000.f;
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0,-0.25f,-2)) * glm::rotate(glm::radians(180.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.25f));
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0, -5, -15)) * glm::rotate(glm::radians(180.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.035f));
glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.5f) * glm::mat4_cast(glm::inverse(rotation)) * shipInitialTransformation;
drawObjectColor(shipContext, shipModelMatrix, glm::vec3(0.6f));
drawObjectColor(seafloorContext, glm::translate(glm::vec3(0,-15,0)) * glm::scale(glm::vec3(5.0f, 1.0f, 5.0f)), glm::vec3(0.7098f, 0.7098f, 0.7098f));
drawObjectTexture(seafloorContext, glm::translate(glm::vec3(0,-15,0)) * glm::scale(glm::vec3(5.0f, 1.0f, 5.0f)), textureSand);
//drawObjectColor(skyboxContext, glm::translate(glm::vec3(0, -15, 0)) * glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)), glm::vec3(0.7098f, 0.7098f, 0.7098f));
drawObjectTexture(skyboxContext, glm::translate(glm::vec3(0, -15, 0)) * glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)), textureSkybox);
// Animals
drawObjectTexture(seaTurtleContext, glm::translate(glm::vec3(0, cos(time) - 3, 0)) * glm::rotate(glm::radians(270.f), glm::vec3(1, 0, 0)) * glm::scale(glm::vec3(0.015f)), textureSeaTurtle);
drawObjectTexture(crabContext, glm::translate(glm::vec3(cos(time / 7) * 10, -13, 0)) * glm::rotate(glm::radians(270.f), glm::vec3(1, 0, 0)) * glm::scale(glm::vec3(0.2f)), textureCrab);
@ -174,6 +177,8 @@ void renderScene()
drawObjectColor(coralContext, glm::translate(glm::vec3(0, -14, 8)) * glm::rotate(glm::radians(270.f), glm::vec3(1, 0, 0)) * glm::scale(glm::vec3(0.1f)), glm::vec3(0.85f, 0.0255f, 0.6027f));
drawObjectColor(gorgonianCoralContext, glm::translate(glm::vec3(0, -14, 16)) * glm::rotate(glm::radians(270.f), glm::vec3(1, 0, 0)) * glm::scale(glm::vec3(0.07f)), glm::vec3(0.f, 1.f, 0.f));
drawObjectTexture(shipwreckContext, glm::translate(glm::vec3(20, -15, 0)) * glm::rotate(glm::radians(255.f), glm::vec3(1, 0, 0)) * glm::scale(glm::vec3(0.003f)), textureBoards);
glutSwapBuffers();
}
@ -196,7 +201,7 @@ void init()
glEnable(GL_DEPTH_TEST);
programColor = shaderLoader.CreateProgram("shaders/shader_color.vert", "shaders/shader_color.frag");
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
loadModelToContext("models/ship.obj", shipContext);
loadModelToContext("models/sub.obj", shipContext);
loadModelToContext("models/seafloor.obj", seafloorContext);
loadModelToContext("models/skybox.obj", skyboxContext);
loadModelToContext("models/first_fish.obj", firstFishContext);
@ -207,12 +212,15 @@ void init()
loadModelToContext("models/coral_tree.obj", coralTreeContext);
loadModelToContext("models/coral.obj", coralContext);
loadModelToContext("models/gorgonian_coral.obj", gorgonianCoralContext);
loadModelToContext("models/shipwreck.obj", shipwreckContext);
textureSkybox = Core::LoadTexture("textures/skybox.png");
textureFirstFish = Core::LoadTexture("textures/first_fish.png");
textureSecondFish = Core::LoadTexture("textures/second_fish.png");
textureThirdFish = Core::LoadTexture("textures/third_fish.png");
textureSeaTurtle = Core::LoadTexture("textures/sea_turtle.png");
textureCrab = Core::LoadTexture("textures/crab.png");
textureSand = Core::LoadTexture("textures/sand.png");
textureBoards = Core::LoadTexture("textures/boards.png");
for (int i = 0; i < 15; i++) {
firstFishPositions[i][0] = rand() % 30 - 15;
firstFishPositions[i][1] = rand() % 25 - 10;

BIN
cw 6/textures/boards.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB

BIN
cw 6/textures/sand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB