added plants vector to PlanetParams

This commit is contained in:
dompia5 2024-02-02 19:59:24 +01:00
parent 1195ec1b91
commit b364a755fc

View File

@ -95,7 +95,7 @@ struct PlanetParams {
float humidity = 0.0f; // Начальное значение для влажности
float temperature = 0.0f; // Начальное значение для осадков
std::vector<Plant::Plant> plants;
};
std::vector<PlanetParams> planets; // Список всех планет
@ -119,7 +119,7 @@ namespace Plant
class Plant {
public:
float humMean; float humSD; float tempMean; float tempSD; std::string name; std::string fileName; glm::mat4 modelMatrix; Core::RenderContext modelContext;
float humMean; float humSD; float tempMean; float tempSD; std::string name; std::string fileName; glm::mat4 modelMatrix; Core::RenderContext modelContext; glm::vec3 pos;
Plant(float humMean, float humSD, float tempMean, float tempSD, std::string name, std::string fileName) {
this->humMean = humMean;
this->humSD = humSD;
@ -130,6 +130,7 @@ namespace Plant
this->modelContext = Core::RenderContext();
loadModelToContext2("./models/plants/polygon.obj", modelContext);
this->modelMatrix = glm::mat4();
this->pos = glm::vec3((rand() % 100) / 100, (rand() % 100) / 100, (rand() % 100) / 100);
}
float calcProbability(float xValue, float mean, float sd)
@ -141,7 +142,6 @@ namespace Plant
}
std::vector<Plant::Plant> plants;
std::vector<Plant::Plant> plant_specimens;
void populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plants)
@ -363,9 +363,10 @@ void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMat
angle = dot(base,placePoint);
angle = acos(angle);
cobjectMatrix = cobjectMatrix * glm::rotate(cobjectMatrix, angle, axis) * glm::translate(base * diameter);
cobjectMatrix = cobjectMatrix * glm::translate(planetParams.position*1/scale);
drawObjectBiomes(objectContext, cobjectMatrix, programBiomes);
//*glm::translate(planetParams.position)
// wysunąć w dobrą stronę
@ -415,7 +416,8 @@ void renderScene(GLFWwindow* window)
for (const auto& planet : planets) {
glm::mat4 modelMatrix = glm::translate(planet.position) * glm::scale(glm::vec3(planet.size));
drawObjectTexture(sphereContext, modelMatrix, planet.texture, program);
placeObjectOnPlanet(plant2Context, glm::mat4(),0.2, normalize(glm::vec3(0.1, 0.f, 1.f)), planet);
for (const auto& plant : planet.plants)
placeObjectOnPlanet(plant2Context, glm::mat4(),0.2, plant.pos, planet);
}