Skybox and seafloor implemented

This commit is contained in:
Mateusz Drewniak 2022-01-03 20:19:33 +01:00
parent f648151410
commit 40c425b64e
8 changed files with 115696 additions and 7 deletions

45404
cw 6/models/mountains.obj Normal file

File diff suppressed because it is too large Load Diff

12
cw 6/models/seafloor.mtl Normal file
View File

@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Default_OBJ
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2

51971
cw 6/models/seafloor.obj Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

4105
cw 6/models/skybox.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,8 @@ GLuint programTexture;
Core::Shader_Loader shaderLoader;
Core::RenderContext skyboxContext;
Core::RenderContext seafloorContext;
Core::RenderContext shipContext;
Core::RenderContext sphereContext;
@ -31,11 +33,12 @@ float cameraAngle = 0;
glm::mat4 cameraMatrix, perspectiveMatrix;
glm::vec3 lightDir = glm::normalize(glm::vec3(1.0f, -0.9f, -1.0f));
glm::vec3 lightDir = glm::normalize(glm::vec3(0.0f, -1.0f, 0.0f));
glm::quat rotation = glm::quat(1, 0, 0, 0);
GLuint textureAsteroid;
GLuint textureSkybox;
void keyboard(unsigned char key, int x, int y)
{
@ -44,12 +47,12 @@ void keyboard(unsigned char key, int x, int y)
float moveSpeed = 0.1f;
switch(key)
{
case 'z': cameraAngle -= angleSpeed; break;
case 'x': cameraAngle += angleSpeed; break;
case 'w': cameraPos += cameraDir * moveSpeed; break;
case 's': cameraPos -= cameraDir * moveSpeed; break;
case 'd': cameraPos += cameraSide * moveSpeed; break;
case 'a': cameraPos -= cameraSide * moveSpeed; break;
case 'z': cameraAngle -= angleSpeed; break;
case 'x': cameraAngle += angleSpeed; break;
case 'w': cameraPos += cameraDir * moveSpeed; break;
case 's': cameraPos -= cameraDir * moveSpeed; break;
case 'd': cameraPos += cameraSide * moveSpeed; break;
case 'a': cameraPos -= cameraSide * moveSpeed; break;
}
}
@ -125,8 +128,11 @@ void renderScene()
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0,-0.25f,0)) * glm::rotate(glm::radians(180.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.25f));
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));
//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(sphereContext, glm::translate(glm::vec3(0,0,0)), textureAsteroid);
drawObjectTexture(skyboxContext, glm::translate(glm::vec3(0, -15, 0)) * glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)), textureSkybox);
for (int i = 0; i < 10; i++) drawObjectTexture(sphereContext, glm::translate(planetPositions[i]), textureAsteroid);
@ -154,7 +160,10 @@ void init()
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
loadModelToContext("models/spaceship.obj", shipContext);
loadModelToContext("models/sphere.obj", sphereContext);
loadModelToContext("models/seafloor.obj", seafloorContext);
loadModelToContext("models/skybox.obj", skyboxContext);
textureAsteroid = Core::LoadTexture("textures/asteroid.png");
textureSkybox = Core::LoadTexture("textures/skybox.png");
for (int i = 0; i < 10; i++) planetPositions[i] = glm::ballRand(planetSpreadFactor);
}

BIN
cw 6/textures/skybox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw4", "cw 4\grk-cw4.vcx
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw6", "cw 6\grk-cw6.vcxproj", "{10701B86-9B0B-46A1-85DA-6238CBCC507B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw5", "cw 5\grk-cw5.vcxproj", "{3A5EA2E9-4B50-4E36-B2AA-7DC086FCD066}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -33,6 +35,10 @@ Global
{10701B86-9B0B-46A1-85DA-6238CBCC507B}.Debug|Win32.Build.0 = Debug|Win32
{10701B86-9B0B-46A1-85DA-6238CBCC507B}.Release|Win32.ActiveCfg = Release|Win32
{10701B86-9B0B-46A1-85DA-6238CBCC507B}.Release|Win32.Build.0 = Release|Win32
{3A5EA2E9-4B50-4E36-B2AA-7DC086FCD066}.Debug|Win32.ActiveCfg = Debug|Win32
{3A5EA2E9-4B50-4E36-B2AA-7DC086FCD066}.Debug|Win32.Build.0 = Debug|Win32
{3A5EA2E9-4B50-4E36-B2AA-7DC086FCD066}.Release|Win32.ActiveCfg = Release|Win32
{3A5EA2E9-4B50-4E36-B2AA-7DC086FCD066}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE