add plants

This commit is contained in:
Thyme1 2022-01-12 20:54:37 +01:00
parent 44164da244
commit ceab013b30
22 changed files with 39476 additions and 1141043 deletions

View File

@ -29,7 +29,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +0,0 @@
# Blender MTL File: 'fish.blend'
# Material Count: 1
newmtl Material
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.050000 0.050000 0.050000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd fish_texture.png

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,6 @@ void main()
vec3 R = reflect(-normalize(lightDir),normal);
float ambient = 0.2;
float specular = pow(max(0,dot(R,V)),1000);
gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0) * (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
//gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0);
//gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0) * (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0);
}

View File

@ -22,6 +22,6 @@ float logisticDepth(float depth, float steepness, float offset)
void main()
{
float depth = logisticDepth(gl_FragCoord.z, 0.1f, 3.0f);
FragColor = texture(skybox, TexCoords)* (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
//FragColor = texture(skybox, TexCoords);
//FragColor = texture(skybox, TexCoords)* (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
FragColor = texture(skybox, TexCoords);
}

View File

@ -22,11 +22,19 @@ GLuint textureSubmarine;
GLuint textureBubble;
GLuint textureFloor;
GLuint textureFish;
GLuint texturePlant1;
GLuint texturePlant2;
GLuint texturePlant3;
GLuint textureCoral1;
GLuint textureRocktower1;
GLuint textureArch;
unsigned int cubemapTexture, skyboxVAO;
unsigned int cubeVAO, cubeVBO;
std::vector<glm::vec3> bubbleArray[300];
glm::vec3 grassArray[200];
float old_x, old_y = -1;
glm::vec3 cursorDiff;
glm::vec3 lightDir = glm::normalize(glm::vec3(1.0f, -10.f, -1.0f));
@ -44,6 +52,12 @@ glm::mat4 cameraMatrix, perspectiveMatrix;
Core::Shader_Loader shaderLoader;
Core::RenderContext submarineContext;
Core::RenderContext floorContext;
Core::RenderContext plant1Context;
Core::RenderContext plant2Context;
Core::RenderContext plant3Context;
Core::RenderContext coral1Context;
Core::RenderContext rocktower1Context;
Core::RenderContext archContext;
Core::RenderContext fishContext;
Core::RenderContext bubbleContext;
@ -199,10 +213,12 @@ void generateBubbleArray() {
}
}
void keyboard(unsigned char key, int x, int y)
{
float angleSpeed = 10.f;
float moveSpeed = 1.0f;
float moveSpeed = 10.0f;
glm::vec3 nextPosition;
switch (key)
{
@ -368,6 +384,8 @@ void renderScene()
glm::mat4 submarineInitialTransformation = glm::translate(glm::vec3(0, -0.5, -0.4)) * glm::rotate(glm::radians(180.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
glm::mat4 floorTransformation = glm::translate(glm::vec3(-50, -190, 50)) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(100.f));
glm::mat4 submarineModelMatrix = glm::translate(cameraPos + cameraDir) * glm::mat4_cast(glm::inverse(rotation)) * submarineInitialTransformation;
@ -383,6 +401,8 @@ void renderScene()
drawObjectTexture(bubbleContext, animationMatrix(time + j, change0, bubbleArray[j], glm::vec3(0.04f), 0.1f), cubemapTexture, bubbleProgram);
}
for (int i = 0; i < 5; i++) {
if (time > -10) {
drawObjectTexture(fishContext, animationMatrix(time + 15, change1, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture);
@ -393,9 +413,28 @@ void renderScene()
time -= 6;
}
}
//drawObjectTexture(bubbleContext, submarineInitialTransformation, cubemapTexture, bubbleProgram);
drawObjectTexture(submarineContext, submarineModelMatrix, textureSubmarine, programTexture);
drawObjectTexture(floorContext, floorTransformation, textureFloor, programTexture);
for (int j = 0; j < 25; j++) {
glm::mat4 plantTransformation = glm::translate(grassArray[j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(plant1Context, plantTransformation, texturePlant1, programTexture);
plantTransformation = glm::translate(grassArray[25+j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(plant2Context, plantTransformation, texturePlant2, programTexture);
plantTransformation = glm::translate(grassArray[50 + j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(plant3Context, plantTransformation, texturePlant3, programTexture);
plantTransformation = glm::translate(grassArray[75 + j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(coral1Context, plantTransformation, textureCoral1, programTexture);
plantTransformation = glm::translate(grassArray[100 + j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(rocktower1Context, plantTransformation, textureRocktower1, programTexture);
plantTransformation = glm::translate(grassArray[125 + j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.25f));
drawObjectTexture(archContext, plantTransformation, textureArch, programTexture);
}
glutSwapBuffers();
}
@ -518,6 +557,38 @@ void init()
loadModelToContext("models/terrain.obj", floorContext);
textureFloor = Core::LoadTexture("textures/sand.png");
loadModelToContext("models/plant1.obj", plant1Context);
texturePlant1 = Core::LoadTexture("textures/plant1.png");
loadModelToContext("models/plant2.obj", plant2Context);
texturePlant2 = Core::LoadTexture("textures/plant2.png");
loadModelToContext("models/plant3.obj", plant3Context);
texturePlant3 = Core::LoadTexture("textures/plant3.png");
loadModelToContext("models/coral01.obj", coral1Context);
textureCoral1 = Core::LoadTexture("textures/coral01.png");
loadModelToContext("models/rocktower1.obj", rocktower1Context);
textureRocktower1 = Core::LoadTexture("textures/rocktower1.png");
loadModelToContext("models/arch.obj", archContext);
textureArch = Core::LoadTexture("textures/arch.png");
for (int i = 0; i < 200; i++) {
float random1 = distr(gen);
float random2 = distr(gen);
grassArray[i] = glm::vec3(random1, -skyboxVerticeParameter + 5, random2);
if (i >= 50) {
grassArray[i] = glm::vec3(random1, -skyboxVerticeParameter + 10, random2);
}
};
generateBubbleArray();
initCube();
initSkybox();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB