diff --git a/grk/cw 6/src/Planet.hpp b/grk/cw 6/src/Planet.hpp index 4089d0f..41f4442 100644 --- a/grk/cw 6/src/Planet.hpp +++ b/grk/cw 6/src/Planet.hpp @@ -14,8 +14,9 @@ #include #include - +/* namespace texturePlanets { + GLuint blank; GLuint earth; GLuint planet; GLuint mercury; @@ -55,7 +56,7 @@ namespace textureMoons { namespace textureMaterials { GLuint clouds; } - +*/ GLuint program; GLuint programSun; GLuint programDepth; @@ -65,13 +66,25 @@ Core::Shader_Loader shaderLoader; Core::RenderContext sphereContext; -glm::vec3 sunPos = glm::vec3(12.f, 0.f, 12.f); -float sunSize = 0.04f; +const char* const planetTexPaths[] = { "./textures/planets/earth.png", "./textures/planets/mercury.png", "./textures/planets/venus.jpg", "./textures/planets/mars.jpg", + "./textures/planets/jupiter.jpg", "./textures/planets/saturn.jpg", "./textures/planets/uranus.jpg", "./textures/planets/neptune.jpg", "./textures/planets/icy.png", + "./textures/planets/volcanic.png", "./textures/planets/desert.png", "./textures/planets/tropical.png", "./textures/planets/toxic.jpg", "./textures/planets/swamp.png", + "./textures/planets/savannah.png", "./textures/planets/alpine.png", "./textures/planets/ceres.jpg", "./textures/planets/eris.jpg", "./textures/planets/haumea.jpg", + "./textures/planets/makemake.jpg" }; +int planetTexIndex = 80; +GLuint planetTex; glm::vec3 planetPos = glm::vec3(0.f, 0.f, 0.f); float planetSize = 0.005f; float planetRot = 0.f; +const char* const sunTexPaths[] = { "./textures/suns/sol.jpg", "./textures/suns/orange.jpg", "./textures/suns/lava.png", "./textures/suns/star.png", "./textures/suns/sun.jpg" }; +int sunTexIndex = 20; +GLuint sunTex; + +glm::vec3 sunPos = glm::vec3(12.f, 0.f, 12.f); +float sunSize = 0.04f; + glm::vec3 cameraPos = glm::vec3(-2.f, 0.f, 0.f); glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f); @@ -87,7 +100,8 @@ unsigned int depthMapFBO; int HDR_WIDTH = 1024; int HDR_HEIGHT = 1024; -glm::vec3 lightColor = glm::vec3(50, 50, 50); +float lightPower = 50.f; +glm::vec3 lightColor = glm::vec3(lightPower, lightPower, lightPower); glm::mat4 createCameraMatrix() { glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f))); @@ -228,16 +242,16 @@ void renderScene(GLFWwindow* window) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float time = glfwGetTime(); - glm::mat4 sunScale = glm::scale(glm::vec3(sunSize)); - glm::mat4 sunTranslate = glm::translate(sunPos); - - drawSun(sphereContext, sunTranslate * sunScale, textureSuns::sun1); - glm::mat4 planetScale = glm::scale(glm::vec3(planetSize)); glm::mat4 planetRotate = glm::rotate(time * planetRot, glm::vec3(0, 1, 0)); glm::mat4 planetTranslate = glm::translate(planetPos); - drawObjectTexture(sphereContext, planetTranslate * planetRotate * planetScale, texturePlanets::earth); + drawObjectTexture(sphereContext, planetTranslate * planetRotate * planetScale, planetTex); + + glm::mat4 sunScale = glm::scale(glm::vec3(sunSize)); + glm::mat4 sunTranslate = glm::translate(sunPos); + + drawSun(sphereContext, sunTranslate * sunScale, sunTex); glfwSwapBuffers(window); } @@ -273,34 +287,8 @@ void init(GLFWwindow* window) { loadModelToContext("./models/sphere.obj", sphereContext); - texturePlanets::earth = Core::LoadTexture("./textures/planets/earth2.png"); - /*texturePlanets::planet = Core::LoadTexture("./textures/planets/planet.png"); - texturePlanets::mercury = Core::LoadTexture("./textures/planets/mercury1.jpg"); - texturePlanets::venus = Core::LoadTexture("./textures/planets/earth2.png"); - texturePlanets::mars = Core::LoadTexture("./textures/planets/mars.jpg"); - texturePlanets::alpine = Core::LoadTexture("./textures/planets/Alpine.png"); - texturePlanets::ceres = Core::LoadTexture("./textures/planets/ceres_fictional.jpg"); - texturePlanets::eris = Core::LoadTexture("./textures/planets/eris_fictional.jpg"); - texturePlanets::haumea = Core::LoadTexture("./textures/planets/haumea_fictional.jpg"); - texturePlanets::icy = Core::LoadTexture("./textures/planets/Icy.png"); - texturePlanets::jupiter = Core::LoadTexture("./textures/planets/jupiter.jpg"); - texturePlanets::makemake = Core::LoadTexture("./textures/planets/makemake_fictional.jpg"); - texturePlanets::martian = Core::LoadTexture("./textures/planets/Martian.png"); - texturePlanets::neptune = Core::LoadTexture("./textures/planets/neptune.jpg"); - texturePlanets::saturn = Core::LoadTexture("./textures/planets/saturn.jpg"); - texturePlanets::savannah = Core::LoadTexture("./textures/planets/Savannah.png"); - texturePlanets::swamp = Core::LoadTexture("./textures/planets/Swamp.png"); - texturePlanets::tropical = Core::LoadTexture("./textures/planets/Tropical.png"); - texturePlanets::uranus = Core::LoadTexture("./textures/planets/uranus.jpg"); - texturePlanets::venusian = Core::LoadTexture("./textures/planets/Venusian.png"); - texturePlanets::volcanic = Core::LoadTexture("./textures/planets/Volcanic.png");*/ - - textureSuns::sun1 = Core::LoadTexture("./textures/suns/sun1.jpg"); - /*textureSuns::sun2 = Core::LoadTexture("./textures/suns/sun2.jpg"); - textureSuns::sun3 = Core::LoadTexture("./textures/suns/sun3.jpg"); - textureSuns::sun4 = Core::LoadTexture("./textures/suns/sun4.jpg");*/ - - textureMaterials::clouds = Core::LoadTexture("./textures/planets/clouds.jpg"); + planetTex = Core::LoadTexture(planetTexPaths[std::abs(planetTexIndex % 20)]); + sunTex = Core::LoadTexture(sunTexPaths[std::abs(sunTexIndex % 5)]); } void shutdown(GLFWwindow* window) { @@ -318,7 +306,7 @@ void processInput(GLFWwindow* window) //ruch kamerą glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f))); - float cameraSpeed = 0.01f; + float cameraSpeed = 0.02f; if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS && glm::length(planetPos - cameraPos) > 0.01f * 150) cameraPos += cameraDir * cameraSpeed; @@ -347,10 +335,35 @@ void processInput(GLFWwindow* window) if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS && planetRot > -1.f) planetRot -= rotationSpeed; - //if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) - // cameraDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(cameraDir, 0)); - //if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) - // cameraDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(cameraDir, 0)); + //zmiana tekstury planety + if (glfwGetKey(window, GLFW_KEY_T) == GLFW_PRESS) { + planetTex = Core::LoadTexture(planetTexPaths[std::abs(++planetTexIndex % 20)]); + Sleep(200); + } + if (glfwGetKey(window, GLFW_KEY_Y) == GLFW_PRESS && planetTexIndex > 0) { + planetTex = Core::LoadTexture(planetTexPaths[std::abs(--planetTexIndex % 20)]); + Sleep(200); + } + + //zmiana tekstury słońca + if (glfwGetKey(window, GLFW_KEY_U) == GLFW_PRESS) { + sunTex = Core::LoadTexture(sunTexPaths[std::abs(++sunTexIndex % 5)]); + Sleep(200); + } + if (glfwGetKey(window, GLFW_KEY_I) == GLFW_PRESS && sunTexIndex > 0) { + sunTex = Core::LoadTexture(sunTexPaths[std::abs(--sunTexIndex % 5)]); + Sleep(200); + } + + //siła światła + float powerSpeed = 0.5f; + + if (glfwGetKey(window, GLFW_KEY_O) == GLFW_PRESS && lightPower < 250.f) + lightPower += powerSpeed; + if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS && lightPower > 0.5f) + lightPower -= powerSpeed; + + lightColor = glm::vec3(lightPower, lightPower, lightPower); } // funkcja jest glowna petla diff --git a/grk/cw 6/textures/planets/clouds.jpg b/grk/cw 6/textures/materials/clouds.jpg similarity index 100% rename from grk/cw 6/textures/planets/clouds.jpg rename to grk/cw 6/textures/materials/clouds.jpg diff --git a/grk/cw 6/textures/planets/Martian.png b/grk/cw 6/textures/planets/Martian.png deleted file mode 100644 index db4c183..0000000 Binary files a/grk/cw 6/textures/planets/Martian.png and /dev/null differ diff --git a/grk/cw 6/textures/planets/Venusian.png b/grk/cw 6/textures/planets/Venusian.png deleted file mode 100644 index bee66be..0000000 Binary files a/grk/cw 6/textures/planets/Venusian.png and /dev/null differ diff --git a/grk/cw 6/textures/planets/ceres_fictional.jpg b/grk/cw 6/textures/planets/ceres.jpg similarity index 100% rename from grk/cw 6/textures/planets/ceres_fictional.jpg rename to grk/cw 6/textures/planets/ceres.jpg diff --git a/grk/cw 6/textures/planets/desert.png b/grk/cw 6/textures/planets/desert.png new file mode 100644 index 0000000..123f906 Binary files /dev/null and b/grk/cw 6/textures/planets/desert.png differ diff --git a/grk/cw 6/textures/planets/earth.png b/grk/cw 6/textures/planets/earth.png index 2aed90c..465f5d3 100644 Binary files a/grk/cw 6/textures/planets/earth.png and b/grk/cw 6/textures/planets/earth.png differ diff --git a/grk/cw 6/textures/planets/earth2.png b/grk/cw 6/textures/planets/earth2.png deleted file mode 100644 index 465f5d3..0000000 Binary files a/grk/cw 6/textures/planets/earth2.png and /dev/null differ diff --git a/grk/cw 6/textures/planets/earth_nightmap.jpg b/grk/cw 6/textures/planets/earth_nightmap.jpg deleted file mode 100644 index 863be2c..0000000 Binary files a/grk/cw 6/textures/planets/earth_nightmap.jpg and /dev/null differ diff --git a/grk/cw 6/textures/planets/eris_fictional.jpg b/grk/cw 6/textures/planets/eris.jpg similarity index 100% rename from grk/cw 6/textures/planets/eris_fictional.jpg rename to grk/cw 6/textures/planets/eris.jpg diff --git a/grk/cw 6/textures/planets/haumea_fictional.jpg b/grk/cw 6/textures/planets/haumea.jpg similarity index 100% rename from grk/cw 6/textures/planets/haumea_fictional.jpg rename to grk/cw 6/textures/planets/haumea.jpg diff --git a/grk/cw 6/textures/planets/makemake_fictional.jpg b/grk/cw 6/textures/planets/makemake.jpg similarity index 100% rename from grk/cw 6/textures/planets/makemake_fictional.jpg rename to grk/cw 6/textures/planets/makemake.jpg diff --git a/grk/cw 6/textures/planets/mercury.png b/grk/cw 6/textures/planets/mercury.png new file mode 100644 index 0000000..e96849a Binary files /dev/null and b/grk/cw 6/textures/planets/mercury.png differ diff --git a/grk/cw 6/textures/planets/mercury1.jpg b/grk/cw 6/textures/planets/mercury1.jpg deleted file mode 100644 index eebaed9..0000000 Binary files a/grk/cw 6/textures/planets/mercury1.jpg and /dev/null differ diff --git a/grk/cw 6/textures/planets/mercury2.jpg b/grk/cw 6/textures/planets/mercury2.jpg deleted file mode 100644 index 9bb2c0b..0000000 Binary files a/grk/cw 6/textures/planets/mercury2.jpg and /dev/null differ diff --git a/grk/cw 6/textures/planets/planet.png b/grk/cw 6/textures/planets/planet.png deleted file mode 100644 index f1554a9..0000000 Binary files a/grk/cw 6/textures/planets/planet.png and /dev/null differ diff --git a/grk/cw 6/textures/planets/saturn_ring_alpha.png b/grk/cw 6/textures/planets/saturn_ring_alpha.png deleted file mode 100644 index ce82586..0000000 Binary files a/grk/cw 6/textures/planets/saturn_ring_alpha.png and /dev/null differ diff --git a/grk/cw 6/textures/planets/toxic.jpg b/grk/cw 6/textures/planets/toxic.jpg new file mode 100644 index 0000000..ceed8d5 Binary files /dev/null and b/grk/cw 6/textures/planets/toxic.jpg differ diff --git a/grk/cw 6/textures/suns/lava.png b/grk/cw 6/textures/suns/lava.png new file mode 100644 index 0000000..ad73178 Binary files /dev/null and b/grk/cw 6/textures/suns/lava.png differ diff --git a/grk/cw 6/textures/suns/orange.jpg b/grk/cw 6/textures/suns/orange.jpg new file mode 100644 index 0000000..86d8b69 Binary files /dev/null and b/grk/cw 6/textures/suns/orange.jpg differ diff --git a/grk/cw 6/textures/suns/sun1.jpg b/grk/cw 6/textures/suns/sol.jpg similarity index 100% rename from grk/cw 6/textures/suns/sun1.jpg rename to grk/cw 6/textures/suns/sol.jpg diff --git a/grk/cw 6/textures/suns/sun4.png b/grk/cw 6/textures/suns/star.png similarity index 100% rename from grk/cw 6/textures/suns/sun4.png rename to grk/cw 6/textures/suns/star.png diff --git a/grk/cw 6/textures/suns/sun3.jpg b/grk/cw 6/textures/suns/sun.jpg similarity index 100% rename from grk/cw 6/textures/suns/sun3.jpg rename to grk/cw 6/textures/suns/sun.jpg diff --git a/grk/cw 6/textures/suns/sun2.jpg b/grk/cw 6/textures/suns/sun2.jpg deleted file mode 100644 index 045493a..0000000 Binary files a/grk/cw 6/textures/suns/sun2.jpg and /dev/null differ diff --git a/grk/cw 6/textures/suns/sun5.png b/grk/cw 6/textures/suns/sun5.png deleted file mode 100644 index ae3426b..0000000 Binary files a/grk/cw 6/textures/suns/sun5.png and /dev/null differ diff --git a/grk/cw 6/textures/test.png b/grk/cw 6/textures/test.png deleted file mode 100644 index 7419ea4..0000000 Binary files a/grk/cw 6/textures/test.png and /dev/null differ diff --git a/grk/cw 6/textures/test_normals.png b/grk/cw 6/textures/test_normals.png deleted file mode 100644 index 6c0d6cb..0000000 Binary files a/grk/cw 6/textures/test_normals.png and /dev/null differ