Merge branch 'importing_ply' into merge_with_textures
# Conflicts: # PlanetCreator/cw 6/grk-cw6.vcxproj.filters # PlanetCreator/cw 6/imgui.ini # PlanetCreator/cw 6/src/ex_6_1.hpp
This commit is contained in:
commit
66d6374d53
@ -17,6 +17,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Box.cpp" />
|
||||
<ClCompile Include="src\Camera.cpp" />
|
||||
<ClCompile Include="src\Distribution.cpp" />
|
||||
<ClCompile Include="src\imgui.cpp" />
|
||||
<ClCompile Include="src\imgui_demo.cpp" />
|
||||
<ClCompile Include="src\imgui_draw.cpp" />
|
||||
@ -35,6 +36,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Camera.h" />
|
||||
<ClInclude Include="src\Distribution.h" />
|
||||
<ClInclude Include="src\ex_6_1.hpp" />
|
||||
<ClInclude Include="src\imconfig.h" />
|
||||
<ClInclude Include="src\imgui.h" />
|
||||
@ -54,6 +56,7 @@
|
||||
<ClInclude Include="src\SOIL\stbi_DDS_aug.h" />
|
||||
<ClInclude Include="src\SOIL\stbi_DDS_aug_c.h" />
|
||||
<ClInclude Include="src\SOIL\stb_image_aug.h" />
|
||||
<ClInclude Include="src\stb_image.h" />
|
||||
<ClInclude Include="src\Texture.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
BIN
PlanetCreator/cw 6/models/plants/red.jpg
Normal file
BIN
PlanetCreator/cw 6/models/plants/red.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
12
PlanetCreator/cw 6/models/plants/test5.mtl
Normal file
12
PlanetCreator/cw 6/models/plants/test5.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender 4.0.2 MTL File: 'None'
|
||||
# www.blender.org
|
||||
|
||||
newmtl Material.001
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd red.jpg
|
74856
PlanetCreator/cw 6/models/plants/test5.obj
Normal file
74856
PlanetCreator/cw 6/models/plants/test5.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -139,11 +139,24 @@ struct PlanetParams {
|
||||
GLuint texture;
|
||||
// Добавьте другие параметры по мере необходимости
|
||||
|
||||
float precipitation = 0.0f; // Начальное значение для осадков
|
||||
|
||||
float humidity = 0.0f; // Начальное значение для влажности
|
||||
float temperature = 0.0f; // Начальное значение для осадков
|
||||
std::vector<Plant::Plant> plants = std::vector<Plant::Plant>();
|
||||
};
|
||||
|
||||
struct Climate {
|
||||
float tempMin, tempMax;
|
||||
float precipMin, precipMax;
|
||||
GLuint textureID;
|
||||
};
|
||||
|
||||
|
||||
// Глобальный массив климатов
|
||||
std::vector<Climate> climates;
|
||||
|
||||
|
||||
std::vector<PlanetParams> planets; // Список всех планет
|
||||
|
||||
|
||||
@ -224,7 +237,6 @@ namespace texture {
|
||||
GLuint asteroidNormal;
|
||||
}
|
||||
|
||||
|
||||
GLuint program;
|
||||
GLuint programSun;
|
||||
GLuint programTex;
|
||||
@ -233,7 +245,7 @@ GLuint plantProgram;
|
||||
Core::Shader_Loader shaderLoader;
|
||||
|
||||
GLuint programBiomes;
|
||||
|
||||
GLuint defaultTexture;
|
||||
|
||||
Core::RenderContext plantContext;
|
||||
|
||||
@ -247,15 +259,46 @@ Core::RenderContext plant_2_1_small_Context;
|
||||
Core::RenderContext plant_2_1_med_Context;
|
||||
|
||||
Core::RenderContext plant3Context;
|
||||
Core::RenderContext plant2Context;
|
||||
Core::RenderContext plant2_1Context;
|
||||
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
||||
|
||||
glm::vec3 sunPosition = glm::vec3(0.0f, 0.0f, 0.0f); // Позиция солнца
|
||||
glm::vec3 sunColor = glm::vec3(1.0f, 1.0f, 1.0f); // Цвет солнца
|
||||
|
||||
|
||||
|
||||
GLuint VAO,VBO;
|
||||
|
||||
glm::mat4 planetMatrix = glm::mat4();
|
||||
|
||||
struct Vertex {
|
||||
glm::vec3 position;
|
||||
glm::vec3 normal;
|
||||
glm::vec2 texCoords;
|
||||
};
|
||||
struct ModelContext {
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<unsigned int> indices;
|
||||
GLuint VAO;
|
||||
GLuint VBO;
|
||||
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) {
|
||||
// Create an instance of the Importer class
|
||||
@ -336,12 +379,15 @@ glm::mat4 createPerspectiveMatrix()
|
||||
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, GLuint program) {
|
||||
GLuint prog = program;
|
||||
glUseProgram(prog);
|
||||
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(prog, "color"), color.x, color.y, color.z);
|
||||
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0,0,0);
|
||||
//glUniform3f(glGetUniformLocation(prog, "lightPos"), 0,0,0);
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), sunPosition.x, sunPosition.y, sunPosition.z);
|
||||
|
||||
|
||||
GLuint colorStartLocation = glGetUniformLocation(prog, "colorStart");
|
||||
GLuint colorEndLocation = glGetUniformLocation(prog, "colorEnd");
|
||||
@ -356,6 +402,22 @@ void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::v
|
||||
glUseProgram(0);
|
||||
|
||||
}
|
||||
|
||||
void renderSun() {
|
||||
glUseProgram(programSun);
|
||||
|
||||
// Установка uniform-параметров для солнца, например, позиции и цвета
|
||||
glUniform3f(glGetUniformLocation(programSun, "sunPosition"), sunPosition.x, sunPosition.y, sunPosition.z);
|
||||
glUniform3f(glGetUniformLocation(programSun, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
|
||||
|
||||
|
||||
// Отрисовка объекта солнца (может быть простой сферой или кастомной моделью)
|
||||
// ...
|
||||
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
|
||||
void drawObjectBiomes(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint program) {
|
||||
GLuint prog = program;
|
||||
glUseProgram(prog);
|
||||
@ -363,7 +425,9 @@ void drawObjectBiomes(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0, 0, 0);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), sunPosition.x, sunPosition.y, sunPosition.z);
|
||||
|
||||
Core::DrawContext(context);
|
||||
glUseProgram(0);
|
||||
|
||||
@ -376,7 +440,7 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), 0, 0, 0);
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), sunPosition.x, sunPosition.y, sunPosition.z);
|
||||
Core::DrawContext(context);
|
||||
glUseProgram(0);
|
||||
|
||||
@ -551,7 +615,9 @@ 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);
|
||||
|
||||
renderSun();
|
||||
|
||||
|
||||
//drawObjectColor(plant2Context, plantModelMatrix, glm::vec3(1,1,1), program);
|
||||
@ -579,6 +645,7 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
//TODO :REMOVE THIS
|
||||
|
||||
|
||||
|
||||
void loadModelToContext(std::string path, Core::RenderContext& context)
|
||||
{
|
||||
Assimp::Importer import;
|
||||
@ -590,9 +657,7 @@ void loadModelToContext(std::string path, Core::RenderContext& context)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
context.initFromAssimpMesh(scene->mMeshes[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -604,6 +669,10 @@ void init(GLFWwindow* window)
|
||||
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
glm::vec3 lightPosition = glm::vec3(0.0f, 10.0f, 0.0f);
|
||||
glm::vec3 lightColor = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
float lightIntensity = 1.0f;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
|
||||
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||
@ -623,6 +692,7 @@ void init(GLFWwindow* window)
|
||||
loadModelToContext("./models/plant_2_1.obj", plant_2_1Context);
|
||||
loadModelToContext2("./models/plant_4.ply", plant3Context);
|
||||
|
||||
// setupBuffers(plantContex_test);
|
||||
texture::earth=Core::LoadTexture("textures/earth2.png");
|
||||
texture::clouds = Core::LoadTexture("textures/clouds.jpg");
|
||||
texture::moon = Core::LoadTexture("textures/moon_normals.png");
|
||||
@ -643,6 +713,7 @@ void init(GLFWwindow* window)
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.1, 1, 1, "testPlant_MAYBE", "./models/plant_4.ply"));
|
||||
}
|
||||
|
||||
|
||||
void shutdown(GLFWwindow* window)
|
||||
{
|
||||
shaderLoader.DeleteProgram(program);
|
||||
|
7985
PlanetCreator/cw 6/src/stb_image.h
Normal file
7985
PlanetCreator/cw 6/src/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
PlanetCreator/cw 6/textures/1.png
Normal file
BIN
PlanetCreator/cw 6/textures/1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 MiB |
BIN
PlanetCreator/cw 6/textures/2.png
Normal file
BIN
PlanetCreator/cw 6/textures/2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 MiB |
BIN
PlanetCreator/cw 6/textures/3.png
Normal file
BIN
PlanetCreator/cw 6/textures/3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 MiB |
Loading…
Reference in New Issue
Block a user