return texture to planet

This commit is contained in:
Deni 2024-02-07 14:13:42 +01:00
parent 66d6374d53
commit 66a4f36be1
2 changed files with 23 additions and 22 deletions

View File

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

View File

@ -138,9 +138,6 @@ struct PlanetParams {
float size = 1.0f;
GLuint texture;
// Добавьте другие параметры по мере необходимости
float precipitation = 0.0f; // Начальное значение для осадков
float humidity = 0.0f; // Начальное значение для влажности
float temperature = 0.0f; // Начальное значение для осадков
std::vector<Plant::Plant> plants = std::vector<Plant::Plant>();
@ -158,6 +155,7 @@ std::vector<Climate> climates;
std::vector<PlanetParams> planets; // Список всех планет
GLuint defaultTexture;
bool sortFunction(std::tuple<int, float> objA, std::tuple<int, float> objB)
@ -216,7 +214,15 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
}
}
planet.texture = defaultTexture;
for (const auto& climate : climates) {
if (planet.temperature >= climate.tempMin && planet.temperature <= climate.tempMax &&
planet.humidity >= climate.precipMin && planet.humidity <= climate.precipMax) {
planet.texture = climate.textureID;
}
}
return planet;
@ -245,7 +251,6 @@ GLuint plantProgram;
Core::Shader_Loader shaderLoader;
GLuint programBiomes;
GLuint defaultTexture;
Core::RenderContext plantContext;
@ -286,18 +291,6 @@ struct ModelContext {
GLuint EBO;
};
GLuint selectTextureForPlanet(float temperature, float precipitation) {
for (const auto& climate : climates) {
if (temperature >= climate.tempMin && temperature <= climate.tempMax &&
precipitation >= climate.precipMin && precipitation <= climate.precipMax) {
return climate.textureID;
}
}
return defaultTexture; // Вернуть текстуру по умолчанию, если не найдено соответствий
}
float aspectRatio = 1.f;
bool DoTheImportThing(const std::string& pFile) {
@ -346,7 +339,7 @@ void renderImGui() {
ImGui::SliderFloat("Temperatura", &newPlanetParams.temperature, 0.0f, 10.0f); // Слайдер для осадков
if (ImGui::Button("Dodac")) {
newPlanetParams =populatePlanet(newPlanetParams, plant_specimens);
newPlanetParams = populatePlanet(newPlanetParams, plant_specimens);
planets.push_back(newPlanetParams);
}
ImGui::End();
@ -604,7 +597,7 @@ void renderScene(GLFWwindow* window)
//drawObjectBiomes(plantContext, glm::eulerAngleX(30.f) * glm::translate(glm::vec3(0.f, 0.f, 0.f)), programBiomes);
for (const auto& planet : planets) {
glm::mat4 modelMatrix = glm::translate(planet.position) * glm::scale(glm::vec3(planet.size));
drawObjectTexture(sphereContext, modelMatrix, planet.texture, program);
drawObjectTexture(sphereContext, modelMatrix, planet.texture, programTex);
std::vector<Plant::Plant>plants = planet.plants;
for (const auto& plant : plants)
@ -615,13 +608,13 @@ void renderScene(GLFWwindow* window)
}
placeObjectOnPlanet(plant2Context, glm::scale(glm::mat4(), glm::vec3(0.2)), normalize(glm::vec3(1.0, 0.0, 1.0)), sphereContext, planetMatrix);
//placeObjectOnPlanet(plant2Context, glm::scale(glm::mat4(), glm::vec3(0.2)), normalize(glm::vec3(1.0, 0.0, 1.0)), sphereContext, planetMatrix);
renderSun();
//drawObjectColor(plant2Context, plantModelMatrix, glm::vec3(1,1,1), program);
// drawObjectColor(plant3Context,glm::translate(glm::vec3(1.0f, 0.5f, 3.0f)) *glm::scale(glm::vec3(0.03f)) *glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),glm::vec3(1, 1, 1), program);
drawObjectColor(plant3Context,glm::translate(glm::vec3(1.0f, 0.5f, 3.0f)) *glm::scale(glm::vec3(0.03f)) *glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),glm::vec3(1, 1, 1), program);
//drawObjectTexture_plant(plant_1_1_small_Context, plantModelMatrix, plant3Material, program_pbr);
//drawObjectTexture_plant(plant_2_1_small_Context, plantModelMatrix, plant2_1Material, program_pbr);
@ -711,6 +704,14 @@ void init(GLFWwindow* window)
plant_specimens.push_back(Plant::Plant(1, 1, 1, 1, "testPlantFFFFFFFFFFFF", "./models/plant_4.ply"));
plant_specimens.push_back(Plant::Plant(1, 0.2, 1, 1, "testPlant!!!!!!!!!!!!!!!!", "./models/plant_4.ply"));
plant_specimens.push_back(Plant::Plant(1, 0.1, 1, 1, "testPlant_MAYBE", "./models/plant_4.ply"));
defaultTexture = Core::LoadTexture("textures/1.png");
if (defaultTexture == 0) {
std::cout << "Failed to load default texture" << std::endl;
}
climates.push_back({ -10, 0, 0, 50, Core::LoadTexture("textures/1.png") });
climates.push_back({ 0, 10, 50, 100, Core::LoadTexture("textures/2.png") });
}