From d22362489c0ae47a79040175f07f11723e10f16c Mon Sep 17 00:00:00 2001 From: K4RP4T Date: Thu, 8 Feb 2024 03:01:36 +0100 Subject: [PATCH] zmiana tekstur --- grk/cw 6/src/Planet.hpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/grk/cw 6/src/Planet.hpp b/grk/cw 6/src/Planet.hpp index 1527c47..e252927 100644 --- a/grk/cw 6/src/Planet.hpp +++ b/grk/cw 6/src/Planet.hpp @@ -39,21 +39,20 @@ Core::Shader_Loader shaderLoader; Core::RenderContext sphereContext; Core::RenderContext cubeContext; -const char* const planetTexPaths[] = { "./textures/planets/Alpine.jpg", "./textures/planets/ceres.jpg", "./textures/planets/denim.png", "./textures/planets/desert.png", "./textures/planets/dirty.png", - "./textures/planets/earth.jpg", "./textures/planets/eris.jpg", "./textures/planets/haumea.jpg", "./textures/planets/Icy.png", "./textures/planets/jupiter.jpg", "./textures/planets/kora.png", - "./textures/planets/leather.png", "./textures/planets/makemake.jpg", "./textures/planets/mars.jpg", "./textures/planets/mchowa.png", "./textures/planets/mercury.png", "./textures/planets/neptune.jpg", - "./textures/planets/saturn.jpg", "./textures/planets/Savannah.png", "./textures/planets/snow-foot.png", "./textures/planets/Swamp.png", "./textures/planets/toxic.jpg", "./textures/planets/Tropical.png", - "./textures/planets/uranus.jpg", "./textures/planets/venus.jpg", "./textures/planets/Volcanic.png", "./textures/planets/watermelon.png", "./textures/planets/wood.png" }; +const char* const planetTexPaths[] = { "./textures/planets/ceres.jpg", "./textures/planets/desert.png", "./textures/planets/dirty.png", "./textures/planets/earth.jpg", "./textures/planets/eris.jpg", + "./textures/planets/haumea.jpg", "./textures/planets/Icy.png", "./textures/planets/jupiter.jpg", "./textures/planets/kora.png", "./textures/planets/makemake.jpg", "./textures/planets/mars.jpg", + "./textures/planets/mchowa.png", "./textures/planets/mercury.png", "./textures/planets/neptune.jpg", "./textures/planets/saturn.jpg", "./textures/planets/Savannah.png", + "./textures/planets/snow-foot.png", "./textures/planets/Swamp.png", "./textures/planets/Tropical.png", "./textures/planets/uranus.jpg", + "./textures/planets/venus.jpg", "./textures/planets/Volcanic.png", "./textures/planets/watermelon.png", "./textures/planets/wood.png" }; int planetTexIndex = 0; GLuint planetTex; -const char* const normalTexPaths[] = { "./textures/planets/normalne/alpine.png", "./textures/planets/normalne/ceres.png", "./textures/planets/normalne/denim.png", "./textures/planets/normalne/desert.png", - "./textures/planets/normalne/dirty.png", "./textures/planets/normalne/earth_normalmap.png", "./textures/planets/normalne/eris.png", "./textures/planets/normalne/haumea.png", "./textures/planets/normalne/icy.png", - "./textures/planets/normalne/jupiter.png", "./textures/planets/normalne/kora.png", "./textures/planets/normalne/leather.png", "./textures/planets/normalne/makemake.png", "./textures/planets/normalne/mars.png", - "./textures/planets/normalne/mchowa.png", "./textures/planets/normalne/mercury.png", "./textures/planets/normalne/neptune.jpg", "./textures/planets/normalne/saturn.png", "./textures/planets/normalne/savannah.png", - "./textures/planets/normalne/snow-foot.png", "./textures/planets/normalne/swamp.png", "./textures/planets/normalne/toxic.png", "./textures/planets/normalne/tropical.png", "./textures/planets/normalne/uranus.png", +const char* const normalTexPaths[] = { "./textures/planets/normalne/ceres.png", "./textures/planets/normalne/desert.png", "./textures/planets/normalne/dirty.png", "./textures/planets/normalne/earth_normalmap.png", + "./textures/planets/normalne/eris.png", "./textures/planets/normalne/haumea.png", "./textures/planets/normalne/icy.png", "./textures/planets/normalne/jupiter.png", + "./textures/planets/normalne/kora.png", "./textures/planets/normalne/makemake.png", "./textures/planets/normalne/mars.png", "./textures/planets/normalne/mchowa.png", + "./textures/planets/normalne/mercury.png", "./textures/planets/normalne/neptune.jpg", "./textures/planets/normalne/saturn.png", "./textures/planets/normalne/savannah.png", + "./textures/planets/normalne/snow-foot.png", "./textures/planets/normalne/swamp.png", "./textures/planets/normalne/tropical.png", "./textures/planets/normalne/uranus.png", "./textures/planets/normalne/venus.png", "./textures/planets/normalne/volcanic.png", "./textures/planets/normalne/watermelon.png", "./textures/planets/normalne/wood.png" }; -int normalTexIndex = 0; GLuint normalTex; glm::vec3 planetPos = glm::vec3(0.f, 0.f, 0.f); @@ -220,6 +219,7 @@ void showGUI() { planetTexIndex = sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1; planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]); + normalTex = Core::LoadTexture(normalTexPaths[planetTexIndex]); } ImGui::SameLine(); if (ImGui::Button("Next", ImVec2(60, 20))) { @@ -229,6 +229,7 @@ void showGUI() { planetTexIndex = 0; planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]); + normalTex = Core::LoadTexture(normalTexPaths[planetTexIndex]); } ImGui::SliderFloat("Size", &planetSize, 0.001f, 0.01f, "%.5f", ImGuiSliderFlags_AlwaysClamp); @@ -540,6 +541,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod planetTexIndex = 0; planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]); + normalTex = Core::LoadTexture(normalTexPaths[planetTexIndex]); } else if (key == GLFW_KEY_Y && action == GLFW_PRESS) { --planetTexIndex; @@ -548,6 +550,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod planetTexIndex = sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1; planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]); + normalTex = Core::LoadTexture(normalTexPaths[planetTexIndex]); } //tekstura słońca @@ -725,9 +728,9 @@ void init(GLFWwindow* window) { loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/cube.obj", cubeContext); - planetTex = Core::LoadTexture(planetTexPaths[std::abs(planetTexIndex % 21)]); - sunTex = Core::LoadTexture(sunTexPaths[std::abs(sunTexIndex % 5)]); - normalTex = Core::LoadTexture(normalTexPaths[std::abs(normalTexIndex % 23)]); + planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]); + normalTex = Core::LoadTexture(normalTexPaths[planetTexIndex]); + sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]); skyBoxTex = Core::LoadSkyBox(skyBoxPaths);