add floor

This commit is contained in:
Thyme1 2022-01-08 23:38:26 +01:00
parent 38f9de35fa
commit 0e5d73c49d
3 changed files with 1050667 additions and 25 deletions

1050628
grafika_projekt/models/floor.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@ GLuint programColor;
GLuint programTexture;
GLuint textureSubmarine;
GLuint textureBubble;
GLuint textureFloor;
GLuint textureFish;
unsigned int cubemapTexture, skyboxVAO;
unsigned int cubeVAO, cubeVBO;
@ -40,6 +41,7 @@ glm::mat4 cameraMatrix, perspectiveMatrix;
Core::Shader_Loader shaderLoader;
Core::RenderContext submarineContext;
Core::RenderContext floorContext;
Core::RenderContext fishContext;
Core::RenderContext bubbleContext;
@ -63,29 +65,6 @@ glm::vec3(-18.0f, -10.0f, -10.0f),
std::random_device rd; // obtain a random number from hardware
std::mt19937 gen(rd()); // seed the generator
std::uniform_int_distribution<> distr(-50, 50); // define the range
std::vector<glm::vec3> genBubbleKeyPoints(){
float random1 = distr(gen);
float random2 = distr(gen);
std::vector<glm::vec3> bubbleKeyPoints({
glm::vec3(random1 , -50.0f, random2),
glm::vec3(random1 , 50.0f, random2)
}
);
return bubbleKeyPoints;
};
void generateArray() {
for (int i = 0; i < 100; i++) {
array[i] = genBubbleKeyPoints();
}
}
@ -110,6 +89,35 @@ std::string skyboxTextures[6] = {
float skyboxVerticeParameter = 50.0f;
float skyboxBoundary = 48.0f;
std::random_device rd; // obtain a random number from hardware
std::mt19937 gen(rd()); // seed the generator
std::uniform_int_distribution<> distr(-skyboxVerticeParameter, skyboxVerticeParameter); // define the range
std::vector<glm::vec3> genBubbleKeyPoints() {
float random1 = distr(gen);
float random2 = distr(gen);
std::vector<glm::vec3> bubbleKeyPoints({
glm::vec3(random1 , -skyboxVerticeParameter, random2),
glm::vec3(random1 , skyboxVerticeParameter, random2)
}
);
return bubbleKeyPoints;
};
void generateBubbleArray() {
for (int i = 0; i < 100; i++) {
array[i] = genBubbleKeyPoints();
}
}
float cubeVertices[] = {
// positions // normals
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
@ -381,9 +389,10 @@ 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, -skyboxVerticeParameter, 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;
glm::mat4 bubbleInitialTransformation = 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.5f));
glm::vec3 change1 = glm::vec3(0, 3, 0);
glm::vec3 change2 = glm::vec3(0, 0, 0);
@ -417,6 +426,7 @@ void renderScene()
drawObjectTexture(submarineContext, submarineModelMatrix, textureSubmarine, programTexture);
drawObjectTexture(floorContext, floorTransformation, textureFloor, programTexture);
glutSwapBuffers();
}
@ -535,7 +545,11 @@ void init()
textureSubmarine = Core::LoadTexture("textures/submarine.png");
loadModelToContext("models/sphere.obj", bubbleContext);
textureBubble = Core::LoadTexture("textures/bubble.png");
generateArray();
loadModelToContext("models/floor.obj", floorContext);
textureFloor = Core::LoadTexture("textures/floor.jpg");
generateBubbleArray();
initCube();
initSkybox();

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB