mcl
This commit is contained in:
parent
339afe2b97
commit
6cd9fd3851
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,20 +1,21 @@
|
||||
main.cpp
|
||||
C:\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: APIENTRY: изменение макроопределения
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : см. предыдущее определение "APIENTRY"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(127,15): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(178,30): warning C4244: =: преобразование "float" в "int", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(184,20): warning C4244: =: преобразование "int" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(355,16): warning C4305: инициализация: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(459,61): warning C4305: аргумент: усечение из "double" в "GLfloat"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(460,61): warning C4305: аргумент: усечение из "double" в "GLfloat"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(473,17): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(588,13): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(722,92): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(723,96): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(724,100): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(725,102): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(728,106): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(729,96): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(136,15): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(157,23): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(205,30): warning C4244: =: преобразование "float" в "int", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(211,20): warning C4244: =: преобразование "int" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(390,16): warning C4305: инициализация: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(494,61): warning C4305: аргумент: усечение из "double" в "GLfloat"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(495,61): warning C4305: аргумент: усечение из "double" в "GLfloat"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(509,17): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(629,13): warning C4244: инициализация: преобразование "double" в "float", возможна потеря данных
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(773,90): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(774,94): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(775,98): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(776,100): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(779,104): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(780,94): warning C4305: аргумент: усечение из "double" в "float"
|
||||
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\tuple(158,47): warning C4244: инициализация: преобразование "_Ty" в "_Ty", возможна потеря данных
|
||||
with
|
||||
[
|
||||
@ -90,8 +91,8 @@ C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.2
|
||||
_Tag=std::_Unpack_tuple_t,
|
||||
_Tpl=std::tuple<int,float>
|
||||
]
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(185): message : выполняется компиляция ссылки на экземпляр шаблон функции "std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(185): message : выполняется компиляция ссылки на экземпляр шаблон функции "std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(212): message : выполняется компиляция ссылки на экземпляр шаблон функции "std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(212): message : выполняется компиляция ссылки на экземпляр шаблон функции "std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept"
|
||||
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\tuple(158,47): warning C4244: инициализация: преобразование "const int" в "_Ty", возможна потеря данных
|
||||
with
|
||||
[
|
||||
@ -174,7 +175,7 @@ C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.2
|
||||
_RanIt=std::tuple<int,int> *,
|
||||
_Pr=bool (__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)
|
||||
]
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(193): message : выполняется компиляция ссылки на экземпляр шаблон функции "void std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,bool(__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)>(const _RanIt,const _RanIt,_Pr)"
|
||||
C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(220): message : выполняется компиляция ссылки на экземпляр шаблон функции "void std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,bool(__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)>(const _RanIt,const _RanIt,_Pr)"
|
||||
with
|
||||
[
|
||||
_Ty=std::tuple<int,int>,
|
||||
@ -182,7 +183,7 @@ C:\Users\neryt\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(193): message : в
|
||||
_Pr=bool (__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)
|
||||
]
|
||||
Создание кода
|
||||
2 of 2460 functions (<0.1%) were compiled, the rest were copied from previous compilation.
|
||||
2 of 2535 functions (<0.1%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
23 functions had inline decision re-evaluated but remain unchanged
|
||||
Создание кода завершено
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,6 +22,8 @@
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
|
||||
const double M_PI = 3.14159265358979323846;
|
||||
|
||||
|
||||
struct Material {
|
||||
float Ns; // shininess
|
||||
@ -91,7 +93,7 @@ void loadMTLAndGetTextureID(const std::string& filePath, Material& material) {
|
||||
void loadModelToContext2(std::string path, Core::RenderContext& context)
|
||||
{
|
||||
Assimp::Importer import;
|
||||
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_FindInvalidData);
|
||||
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
|
||||
|
||||
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
|
||||
{
|
||||
@ -99,7 +101,7 @@ void loadModelToContext2(std::string path, Core::RenderContext& context)
|
||||
return;
|
||||
}
|
||||
|
||||
context.initFromAssimpMesh2(scene->mMeshes[0]);
|
||||
context.initFromAssimpMesh(scene->mMeshes[0]);
|
||||
}
|
||||
namespace Plant
|
||||
{
|
||||
@ -107,18 +109,25 @@ namespace Plant
|
||||
class Plant {
|
||||
|
||||
public:
|
||||
float humMean; float humSD; float tempMean; float tempSD; std::string name; std::string fileName; Core::RenderContext modelContext; glm::vec3 pos;
|
||||
float humMean; float humSD; float tempMean; float tempSD; float elapsedTime; std::string name; std::string fileName; Core::RenderContext modelContext; Core::RenderContext stageContext1; Core::RenderContext stageContext2; Core::RenderContext stageContext3; glm::vec3 pos;
|
||||
Plant(float humMean, float humSD, float tempMean, float tempSD, std::string name, std::string fileName) {
|
||||
this->humMean = humMean;
|
||||
this->humSD = humSD;
|
||||
this->tempMean = tempMean;
|
||||
this->tempSD = tempSD;
|
||||
this->name = name;
|
||||
this->elapsedTime = 0.0;
|
||||
this->fileName = fileName;
|
||||
this->modelContext = Core::RenderContext();
|
||||
loadModelToContext2("./models/plants/polygon.obj", modelContext);
|
||||
|
||||
this->stageContext1 = Core::RenderContext();
|
||||
this->stageContext2 = Core::RenderContext();
|
||||
this->stageContext3 = Core::RenderContext();
|
||||
this->pos = glm::vec3(1,0,0);
|
||||
|
||||
loadModelToContext2(fileName+".obj", modelContext);
|
||||
loadModelToContext2(fileName+"_small.obj", stageContext1);
|
||||
loadModelToContext2(fileName+ "_med.obj", stageContext2);
|
||||
loadModelToContext2(fileName+ ".obj", stageContext3);
|
||||
//this->pos = glm::vec3((rand() % 100) / 100, (rand() % 100) / 100, (rand() % 100) / 100);
|
||||
}
|
||||
|
||||
@ -143,6 +152,24 @@ struct PlanetParams {
|
||||
std::vector<Plant::Plant> plants = std::vector<Plant::Plant>();
|
||||
};
|
||||
|
||||
std::vector<glm::vec3> distributePlantsOnSphere(const glm::vec3& center, float radius, int count) {
|
||||
std::vector<glm::vec3> positions;
|
||||
float angleIncrement = M_PI * (3 - sqrt(5)); // Золотое сечение в радианах
|
||||
for (int i = 0; i < count; ++i) {
|
||||
float t = float(i) / float(count);
|
||||
float inclination = acos(1 - 2 * t); // Полярный угол
|
||||
float azimuth = angleIncrement * i; // Азимутальный угол
|
||||
|
||||
float x = sin(inclination) * cos(azimuth) ;
|
||||
float y = sin(inclination) * sin(azimuth) ;
|
||||
float z = cos(inclination);
|
||||
std::cout << x<<" "<<y << " " << z << std::endl;
|
||||
positions.push_back(center + radius * glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
struct Climate {
|
||||
float tempMin, tempMax;
|
||||
float precipMin, precipMax;
|
||||
@ -211,6 +238,14 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
|
||||
std::cout << "got a winner " << plant.name << std::endl;
|
||||
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);
|
||||
|
||||
// Распределение растений по поверхности планеты
|
||||
std::vector<glm::vec3> plantPositions = distributePlantsOnSphere(planet.position, planet.size, planet.plants.size());
|
||||
for (size_t i = 0; i < plantPositions.size(); ++i) {
|
||||
planet.plants[i].pos = plantPositions[i];
|
||||
planet.plants[i].elapsedTime = 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -439,7 +474,7 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
|
||||
|
||||
}
|
||||
|
||||
void drawObjectTexture_plant(Core::RenderContext& context, glm::mat4 modelMatrix, const Material& material, GLuint program) {
|
||||
void drawObjectTexture_plant(Core::RenderContext &context, glm::mat4 modelMatrix, const Material& material, GLuint program) {
|
||||
glUseProgram(program);
|
||||
Core::SetActiveTexture(material.textureID, "colorTexture", program, 0);
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
@ -458,6 +493,7 @@ void drawObjectTexture_plant(Core::RenderContext& context, glm::mat4 modelMatrix
|
||||
glUniform1i(glGetUniformLocation(program, "illuminationModel"), material.illum);
|
||||
glUniform1f(glGetUniformLocation(program, "metallic"), 0.05);
|
||||
glUniform1f(glGetUniformLocation(program, "roughness"), 0.2);
|
||||
std::cout << "DRAWWW " << std::endl;
|
||||
Core::DrawContext(context);
|
||||
glUseProgram(0);
|
||||
}
|
||||
@ -505,6 +541,7 @@ void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMat
|
||||
}
|
||||
Material plant3Material;
|
||||
|
||||
|
||||
Material plant2_1Material;
|
||||
PlanetParams TestPlanet = PlanetParams();
|
||||
struct TexturePlantData {
|
||||
@ -516,6 +553,7 @@ struct TexturePlantData {
|
||||
std::vector<TexturePlantData> texturePlantDataList;
|
||||
#include <cmath>
|
||||
float thirdTreeStartScale = 0.0f;
|
||||
float secTreeStartScale = 0.0f;
|
||||
void animateGrowingTree(float& elapsedTime, float deltaTime, float firstTreeDuration, float secondTreeDuration, float thirdTreeDuration,
|
||||
glm::vec3 plantPosition, float scaleFactor, Core::RenderContext& plant_1_1_small_Context, Core::RenderContext& plant_1_1Context, Core::RenderContext& thirdTreeContext,
|
||||
glm::mat4& plantModelMatrix, Material& plant3Material, GLuint program_pbr)
|
||||
@ -524,37 +562,40 @@ void animateGrowingTree(float& elapsedTime, float deltaTime, float firstTreeDura
|
||||
// static float thirdTreeStartScale = 0.0f;
|
||||
//pierwsze drzewo
|
||||
if (elapsedTime < firstTreeDuration) {
|
||||
|
||||
plantModelMatrix = glm::translate(plantPosition) * glm::scale(glm::vec3(scaleFactor + (elapsedTime / firstTreeDuration) * scaleFactor));
|
||||
float growthStage1 = ((elapsedTime ) / firstTreeDuration)*4;
|
||||
plantModelMatrix = plantModelMatrix * glm::scale(glm::vec3(scaleFactor + (elapsedTime / firstTreeDuration) * scaleFactor*10));
|
||||
drawObjectTexture_plant(plant_1_1_small_Context, plantModelMatrix, plant3Material, program_pbr);
|
||||
elapsedTime += deltaTime;
|
||||
|
||||
secTreeStartScale = scaleFactor + growthStage1 * scaleFactor;
|
||||
|
||||
}
|
||||
// drugie drzewo
|
||||
else if (elapsedTime < firstTreeDuration + secondTreeDuration) {
|
||||
|
||||
float growthStage2 = ((elapsedTime - firstTreeDuration) / secondTreeDuration);
|
||||
plantModelMatrix = glm::translate(plantPosition) * glm::scale(glm::vec3(scaleFactor + growthStage2 * scaleFactor));
|
||||
float growthStage2 = ((elapsedTime - firstTreeDuration) / secondTreeDuration)*3;
|
||||
plantModelMatrix = plantModelMatrix * glm::scale(glm::vec3(secTreeStartScale * 2 + growthStage2 * scaleFactor));
|
||||
drawObjectTexture_plant(plant_1_1Context, plantModelMatrix, plant3Material, program_pbr);
|
||||
//std::cout << "delta " << deltaTime << std::endl;
|
||||
//rozmiar
|
||||
if (elapsedTime >= firstTreeDuration && elapsedTime < firstTreeDuration + 4*deltaTime) {
|
||||
//if (elapsedTime >= firstTreeDuration && elapsedTime < firstTreeDuration + 4*deltaTime) {
|
||||
thirdTreeStartScale = scaleFactor + growthStage2 * scaleFactor;
|
||||
//std::cout << "thirdTreeStartScale: " << thirdTreeStartScale << std::endl;
|
||||
}
|
||||
// }
|
||||
elapsedTime += deltaTime;
|
||||
}
|
||||
//trzecie drzewo
|
||||
else if (elapsedTime < firstTreeDuration + secondTreeDuration + thirdTreeDuration) {
|
||||
|
||||
float growthStage3 = ((elapsedTime - firstTreeDuration - secondTreeDuration) / thirdTreeDuration);
|
||||
plantModelMatrix = glm::translate(plantPosition) * glm::scale(glm::vec3(thirdTreeStartScale*2 + growthStage3 * scaleFactor));
|
||||
float growthStage3 = ((elapsedTime - firstTreeDuration - secondTreeDuration) / thirdTreeDuration)*3;
|
||||
plantModelMatrix = plantModelMatrix * glm::scale(glm::vec3(thirdTreeStartScale*3 + growthStage3 * scaleFactor));
|
||||
drawObjectTexture_plant(thirdTreeContext, plantModelMatrix, plant3Material, program_pbr);
|
||||
elapsedTime += deltaTime;
|
||||
}
|
||||
else {
|
||||
|
||||
//plantModelMatrix = glm::translate(plantPosition) * glm::scale(glm::vec3(scaleFactor + scaleFactor));
|
||||
plantModelMatrix = glm::translate(plantPosition) * glm::scale(glm::vec3(thirdTreeStartScale*2 + scaleFactor));
|
||||
plantModelMatrix = plantModelMatrix * glm::scale(glm::vec3(thirdTreeStartScale*3 + scaleFactor));
|
||||
TexturePlantData newData;
|
||||
newData.thirdTreeContext = thirdTreeContext;
|
||||
newData.plantModelMatrix = plantModelMatrix;
|
||||
@ -562,7 +603,7 @@ void animateGrowingTree(float& elapsedTime, float deltaTime, float firstTreeDura
|
||||
newData.program_pbr = program_pbr;
|
||||
texturePlantDataList.push_back(newData);
|
||||
// drawObjectTexture_plant(thirdTreeContext, plantModelMatrix, plant3Material, program_pbr);
|
||||
elapsedTime = 0;
|
||||
|
||||
}
|
||||
|
||||
for (const auto& newData : texturePlantDataList) {
|
||||
@ -582,7 +623,7 @@ void animateGrowingTree(float& elapsedTime, float deltaTime, float firstTreeDura
|
||||
|
||||
void renderScene(GLFWwindow* window)
|
||||
{
|
||||
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
|
||||
glClearColor(0.05f, 0.05f, 0.2f, 1.0f);
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glm::mat4 transformation;
|
||||
float time = glfwGetTime();
|
||||
@ -594,9 +635,9 @@ void renderScene(GLFWwindow* window)
|
||||
static float elapsedTime = 0.0f;
|
||||
|
||||
std::cout << "delta " << time<<"chuj"<< lastFrameTime <<"elapsed"<<elapsedTime<< std::endl;
|
||||
float firstTreeDuration = 20.0f;
|
||||
float secondTreeDuration = 8.0f;
|
||||
float thirdTreeDuration = 5.0f;
|
||||
float firstTreeDuration = 2.0f;
|
||||
float secondTreeDuration = 2.0f;
|
||||
float thirdTreeDuration = 2.0f;
|
||||
//static float elapsedTime = 0.0f;
|
||||
glm::vec3 plantPosition = glm::vec3(1.f, 0.f, 3.5f);
|
||||
glm::vec3 plantPosition1 = glm::vec3(1.f, 0.f, 1.5f);
|
||||
@ -619,23 +660,31 @@ void renderScene(GLFWwindow* window)
|
||||
//drawObjectBiomes(plantContext, glm::eulerAngleY(glm::radians(90.f)) * glm::translate(glm::vec3(0.f, 0.f, 0.f)), programBiomes);
|
||||
//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, programTex);
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), planet.position) * glm::scale(glm::mat4(1.0f), glm::vec3(planet.size));
|
||||
drawObjectTexture(sphereContext, modelMatrix, planet.texture, programTex); // Отрисовка планеты
|
||||
|
||||
std::vector<Plant::Plant>plants = planet.plants;
|
||||
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);
|
||||
for ( auto& plant : planet.plants) {
|
||||
glm::vec3 normal = glm::normalize(plant.pos - planet.position);
|
||||
glm::quat orientation = glm::rotation(glm::vec3(0.0f, 1.0f, 0.0f), normal);
|
||||
|
||||
glm::mat4 plantMatrix = glm::translate(glm::mat4(1.0f), plant.pos) * glm::mat4_cast(orientation) * glm::scale(glm::mat4(1.0f), glm::vec3(0.1f)); // Масштаб адаптируйте под свои нужды
|
||||
|
||||
// Теперь используем материал, связанный с каждым растением
|
||||
// const Material& plantMaterial = plant.material; // Предполагаем, что у Plant есть поле Material material
|
||||
|
||||
// drawObjectTexture_plant(const_cast<Plant::Plant&>(plant).modelContext, plantMatrix, plant3Material, program_pbr);
|
||||
|
||||
animateGrowingTree(const_cast<Plant::Plant&>(plant).elapsedTime, deltaTime, firstTreeDuration, secondTreeDuration, thirdTreeDuration, plant.pos, scaleFactor, const_cast<Plant::Plant&>(plant).stageContext1, const_cast<Plant::Plant&>(plant).stageContext2, const_cast<Plant::Plant&>(plant).stageContext3, plantMatrix, plant2_1Material, program_pbr);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
//drawObjectTexture_plant(plant_1_1_small_Context, plantModelMatrix, plant3Material, program_pbr);
|
||||
@ -680,6 +729,8 @@ void loadModelToContext(std::string path, Core::RenderContext& context)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void init(GLFWwindow* window)
|
||||
{
|
||||
|
||||
@ -699,9 +750,9 @@ void init(GLFWwindow* window)
|
||||
|
||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||
//plant 1-1
|
||||
loadModelToContext("./models/plant_1_1_zmn.obj", plant_1_1Context);
|
||||
loadModelToContext("./models/plant_1_1_med_zmn.obj", plant_1_1_med_Context);
|
||||
loadModelToContext("./models/plant_1_1_small_zmn.obj", plant_1_1_small_Context);
|
||||
loadModelToContext("./models/plant_1_1.obj", plant_1_1Context);
|
||||
loadModelToContext("./models/plant_1_1_med.obj", plant_1_1_med_Context);
|
||||
loadModelToContext("./models/plant_1_1_small.obj", plant_1_1_small_Context);
|
||||
//plant 2-2
|
||||
loadModelToContext("./models/plant_2_1_small.obj", plant_2_1_small_Context);
|
||||
loadModelToContext("./models/plant_2_1_med.obj", plant_2_1_med_Context);
|
||||
@ -719,14 +770,14 @@ 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, "testPlant2", "./models/plant_4.ply"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.95, 1, 1, "testPlantXXXXX", "./models/plant_4.ply"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.93, 1, 1, "testPlantAAAAAAAAA", "./models/plant_4.ply"));
|
||||
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"));
|
||||
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"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.99, 1, 1, "testPlant2", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.95, 1, 1, "testPlantXXXXX", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.93, 1, 1, "testPlantAAAAAAAAA", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.90, 1, 1, "testPlantCCCCCCCCCCC", "./models/plant_1_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.5, 1, 1, "testPlantBBBBBBBBB", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 1, 1, 1, "testPlantFFFFFFFFFFFF", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.2, 1, 1, "testPlant!!!!!!!!!!!!!!!!", "./models/plant_2_1"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.1, 1, 1, "testPlant_MAYBE", "./models/plant_2_1"));
|
||||
|
||||
defaultTexture = Core::LoadTexture("textures/1.png");
|
||||
if (defaultTexture == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user