added plants vector to PlanetParams
This commit is contained in:
parent
1195ec1b91
commit
b364a755fc
@ -95,7 +95,7 @@ struct PlanetParams {
|
|||||||
|
|
||||||
float humidity = 0.0f; // Начальное значение для влажности
|
float humidity = 0.0f; // Начальное значение для влажности
|
||||||
float temperature = 0.0f; // Начальное значение для осадков
|
float temperature = 0.0f; // Начальное значение для осадков
|
||||||
|
std::vector<Plant::Plant> plants;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<PlanetParams> planets; // Список всех планет
|
std::vector<PlanetParams> planets; // Список всех планет
|
||||||
@ -119,7 +119,7 @@ namespace Plant
|
|||||||
class Plant {
|
class Plant {
|
||||||
|
|
||||||
public:
|
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) {
|
Plant(float humMean, float humSD, float tempMean, float tempSD, std::string name, std::string fileName) {
|
||||||
this->humMean = humMean;
|
this->humMean = humMean;
|
||||||
this->humSD = humSD;
|
this->humSD = humSD;
|
||||||
@ -130,6 +130,7 @@ namespace Plant
|
|||||||
this->modelContext = Core::RenderContext();
|
this->modelContext = Core::RenderContext();
|
||||||
loadModelToContext2("./models/plants/polygon.obj", modelContext);
|
loadModelToContext2("./models/plants/polygon.obj", modelContext);
|
||||||
this->modelMatrix = glm::mat4();
|
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)
|
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;
|
std::vector<Plant::Plant> plant_specimens;
|
||||||
|
|
||||||
void populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plants)
|
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 = dot(base,placePoint);
|
||||||
angle = acos(angle);
|
angle = acos(angle);
|
||||||
cobjectMatrix = cobjectMatrix * glm::rotate(cobjectMatrix, angle, axis) * glm::translate(base * diameter);
|
cobjectMatrix = cobjectMatrix * glm::rotate(cobjectMatrix, angle, axis) * glm::translate(base * diameter);
|
||||||
|
cobjectMatrix = cobjectMatrix * glm::translate(planetParams.position*1/scale);
|
||||||
drawObjectBiomes(objectContext, cobjectMatrix, programBiomes);
|
drawObjectBiomes(objectContext, cobjectMatrix, programBiomes);
|
||||||
|
|
||||||
//*glm::translate(planetParams.position)
|
|
||||||
|
|
||||||
// wysunąć w dobrą stronę
|
// wysunąć w dobrą stronę
|
||||||
|
|
||||||
@ -415,7 +416,8 @@ void renderScene(GLFWwindow* window)
|
|||||||
for (const auto& planet : planets) {
|
for (const auto& planet : planets) {
|
||||||
glm::mat4 modelMatrix = glm::translate(planet.position) * glm::scale(glm::vec3(planet.size));
|
glm::mat4 modelMatrix = glm::translate(planet.position) * glm::scale(glm::vec3(planet.size));
|
||||||
drawObjectTexture(sphereContext, modelMatrix, planet.texture, program);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user