plant placement optimisation
This commit is contained in:
parent
0444c26667
commit
93f8e5583b
@ -11,6 +11,6 @@ Pos=4,3
|
||||
Size=218,129
|
||||
|
||||
[Window][Dodawanie nowej planety]
|
||||
Pos=23,7
|
||||
Pos=77,31
|
||||
Size=282,158
|
||||
|
||||
|
@ -202,7 +202,6 @@ void Core::DrawContext(Core::RenderContext& context)
|
||||
GL_UNSIGNED_INT, // type
|
||||
(void*)0 // element array buffer offset
|
||||
);
|
||||
std::cout << context.size << std::endl;
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace Plant
|
||||
this->tempSD = tempSD;
|
||||
this->name = name;
|
||||
this->fileName = fileName;
|
||||
loadModelToContext2("./models/plants/polygon.obj", modelContext);
|
||||
loadModelToContext2(fileName, modelContext);
|
||||
|
||||
this->pos = glm::vec3(1,0,0);
|
||||
//this->pos = glm::vec3((rand() % 100) / 100, (rand() % 100) / 100, (rand() % 100) / 100);
|
||||
@ -140,7 +140,7 @@ struct PlanetParams {
|
||||
|
||||
float humidity = 0.0f; // Начальное значение для влажности
|
||||
float temperature = 0.0f; // Начальное значение для осадков
|
||||
std::vector<Plant::Plant> plants = std::vector<Plant::Plant>();
|
||||
std::vector < std::tuple<int, glm::vec3 >> Plant_info;
|
||||
};
|
||||
|
||||
std::vector<PlanetParams> planets; // Список всех планет
|
||||
@ -198,7 +198,7 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
|
||||
Plant::Plant plant = plants[winnerId];
|
||||
plant_count += 1;
|
||||
plant.pos = glm::vec3((1.0 * (rand() / (RAND_MAX + 1.0))), (1.0 * (rand() / (RAND_MAX + 1.0))), (1.0 * (rand() / (RAND_MAX + 1.0))));
|
||||
planet.plants.push_back(plant);
|
||||
planet.Plant_info.push_back(std::make_tuple(winnerId,plant.pos));
|
||||
}
|
||||
|
||||
}
|
||||
@ -319,7 +319,7 @@ glm::mat4 createPerspectiveMatrix()
|
||||
|
||||
glm::mat4 perspectiveMatrix;
|
||||
float n = 0.05;
|
||||
float f = 100.;
|
||||
float f = 15.;
|
||||
float a1 = glm::min(aspectRatio, 1.f);
|
||||
float a2 = glm::min(1 / aspectRatio, 1.f);
|
||||
perspectiveMatrix = glm::mat4({
|
||||
@ -524,11 +524,13 @@ void renderScene(GLFWwindow* window)
|
||||
glm::mat4 modelMatrix = glm::translate(planet.position) * glm::scale(glm::vec3(planet.size));
|
||||
drawObjectTexture(sphereContext, modelMatrix, planet.texture, program);
|
||||
|
||||
std::vector<Plant::Plant>plants = planet.plants;
|
||||
std::vector<std::tuple<int,glm::vec3>>plants = planet.Plant_info;
|
||||
|
||||
for (const auto& plant : plants)
|
||||
//TODO: REMOVE PLACEHOLDER
|
||||
// placeObjectOnPlanet(plant_1_1Context, glm::mat4(), 0.2, plant.pos, planet);
|
||||
animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plant.pos, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
|
||||
placeObjectOnPlanet(plant_specimens[std::get<0>(plant)].modelContext, glm::mat4(), 0.2, std::get<1>(plant), planet);
|
||||
//animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plant.pos, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
|
||||
}
|
||||
|
||||
@ -544,11 +546,11 @@ void renderScene(GLFWwindow* window)
|
||||
//drawObjectColor(plant2Context, plantModelMatrix, glm::vec3(1, 1, 1), program);
|
||||
|
||||
|
||||
animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition, scaleFactor, plant_1_1_small_Context, plant_1_1_med_Context, plant_1_1Context, plantModelMatrix, plant3Material, program_pbr);
|
||||
//animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition, scaleFactor, plant_1_1_small_Context, plant_1_1_med_Context, plant_1_1Context, plantModelMatrix, plant3Material, program_pbr);
|
||||
|
||||
animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition1, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
//animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition1, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
|
||||
animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition2, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
//animateGrowingTree(elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plantPosition2, scaleFactor, plant_2_1_small_Context, plant_2_1_med_Context, plant_2_1Context, plantModelMatrix, plant2_1Material, program_pbr);
|
||||
|
||||
//glfwSwapBuffers(window);
|
||||
}
|
||||
@ -615,8 +617,8 @@ void init(GLFWwindow* window)
|
||||
loadMTLAndGetTextureID("./models/plant_1_1.mtl", plant3Material);
|
||||
loadMTLAndGetTextureID("./models/plant_2_1_small.mtl", plant2_1Material);
|
||||
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.99, 1, 1, "plant1_s", "./models/plant_1_1_small.obj"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.95, 1, 1, "plant1_m", "./models/plant_1_1_med1.obj"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.99, 1, 1, "plant1_s", "./models/plant_1_1.obj"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.95, 1, 1, "plant1_m", "./models/plant_1_1.obj"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.93, 1, 1, "plant1_l", "./models/plant_1_1.obj"));
|
||||
//plant_specimens.push_back(Plant::Plant(1, 0.90, 1, 1, "testPlantCCCCCCCCCCC", "./models/plant_4.ply"));
|
||||
//plant_specimens.push_back(Plant::Plant(1, 0.5, 1, 1, "testPlantBBBBBBBBB", "./models/plant_4.ply"));
|
||||
|
Loading…
Reference in New Issue
Block a user