WIP placeObject uses material depending on plant

This commit is contained in:
dompia5 2024-02-08 00:40:47 +01:00
parent 50f790fbe7
commit 3f1644dbdb
14 changed files with 39 additions and 37 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,21 +1,20 @@
 Render_Utils.cpp
main.cpp
 main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1): message : zobacz poprzednią definicję „APIENTRY”
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(126,15): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(166,30): warning C4244: "=": konwersja z "float" do "int", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(172,20): warning C4244: "=": konwersja z "int" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(321,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(404,57): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(405,58): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(426,57): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(427,58): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(437,17): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(514,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(553,87): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(641,44): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(642,44): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(643,44): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(141,15): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(175,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(181,30): warning C4244: "=": konwersja z "float" do "int", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(187,20): warning C4244: "=": konwersja z "int" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(312,57): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(313,58): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(388,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(471,57): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(472,58): warning C4305: "argument": obcięcie z "double" do "GLfloat"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(506,17): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(595,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(641,70): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(722,44): warning C4305: "argument": obcięcie z "double" do "float"
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(723,45): warning C4305: "argument": obcięcie z "double" do "float"
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\tuple(144,47): warning C4244: "inicjowanie": konwersja z "_Ty" do "_Ty", możliwa utrata danych
with
[
@ -58,8 +57,8 @@ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.3253
_Tag=std::_Unpack_tuple_t,
_Tpl=std::tuple<int,float>
]
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(173,50): message : zobacz odwołanie do kompilowanego tworzenia wystąpienia „std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept” funkcji szablon
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(173,33): message : zobacz pierwsze odwołanie do elementu „std::tuple<int,int>::tuple” w „populatePlanet”
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(188,50): message : zobacz odwołanie do kompilowanego tworzenia wystąpienia „std::tuple<int,int>::tuple<int,float,0>(std::tuple<int,float> &&) noexcept” funkcji szablon
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(188,33): message : zobacz pierwsze odwołanie do elementu „std::tuple<int,int>::tuple” w „populatePlanet”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\tuple(144,47): warning C4244: "inicjowanie": konwersja z "const int" do "_Ty", możliwa utrata danych
with
[
@ -110,7 +109,7 @@ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.3253
_RanIt=std::tuple<int,int> *,
_Pr=bool (__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)
]
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(181,7): message : zobacz odwołanie do kompilowanego tworzenia wystąpienia „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)” funkcji szablon
D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(197,7): message : zobacz odwołanie do kompilowanego tworzenia wystąpienia „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)” funkcji szablon
with
[
_Ty=std::tuple<int,int>,
@ -118,8 +117,8 @@ D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\cw 6\src\ex_6_1.hpp(
_Pr=bool (__cdecl *)(std::tuple<int,float>,std::tuple<int,float>)
]
Trwa generowanie kodu
9 of 2414 functions ( 0.4%) were compiled, the rest were copied from previous compilation.
4 functions were new in current compilation
23 functions had inline decision re-evaluated but remain unchanged
79 of 2545 functions ( 3.1%) were compiled, the rest were copied from previous compilation.
3 functions were new in current compilation
21 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu
grk-cw6.vcxproj -> D:\DANE\CppProjects\grk_cw1 (1)\PlanetCreator\PlanetCreator\Release\grk-cw6.exe

Binary file not shown.

Binary file not shown.

View File

@ -83,7 +83,7 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>

View File

@ -11,6 +11,6 @@ Pos=4,3
Size=218,129
[Window][Dodawanie nowej planety]
Pos=0,-22
Pos=1,-20
Size=282,158

View File

@ -121,8 +121,8 @@ 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;
Plant(float humMean, float humSD, float tempMean, float tempSD, std::string name, std::string fileName) {
float humMean; float humSD; float tempMean; float tempSD; std::string name; std::string fileName; Core::RenderContext modelContext; glm::vec3 pos; Material material;
Plant(float humMean, float humSD, float tempMean, float tempSD, std::string name, std::string fileName,Material material) {
this->humMean = humMean;
this->humSD = humSD;
this->tempMean = tempMean;
@ -132,6 +132,7 @@ namespace Plant
loadModelToContext(fileName, modelContext);
this->pos = glm::vec3(1,0,0);
this->material = material;
//this->pos = glm::vec3((rand() % 100) / 100, (rand() % 100) / 100, (rand() % 100) / 100);
}
@ -171,7 +172,7 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
float probability=0.5f;
int HOW_MANY_PLANTS = 10000;
int PRECISION = 10000;
float NOTHING_SPAWNS_CUTOFF = 0.0;
float NOTHING_SPAWNS_CUTOFF = 0.2;
int sum = 0;
int chosen_number = 0;
std::vector<std::tuple<int, int>> probabilities;
@ -188,6 +189,7 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
probabilities.push_back(probIdPair);
j++;
}
probabilities.push_back(std::make_tuple(-1, NOTHING_SPAWNS_CUTOFF * PRECISION));
for (auto& probability : probabilities) {
sum += std::get<1>(probability);
}
@ -200,7 +202,7 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
int winnerId = -1;
for (auto& probability : probabilities)
{
if (counter + chosen_number < std::get<1>(probability))
if (chosen_number > std::get<1>(probability))
{
winnerId = std::get<0>(probability);
break;
@ -308,7 +310,7 @@ void DrawContextInstanced(Core::RenderContext& context, std::vector<glm::mat4> t
//glUniform1f(glGetUniformLocation(program, "dissolve"), material.d);
glUniform1i(glGetUniformLocation(program, "illuminationModel"), material.illum);
glUniform1f(glGetUniformLocation(program, "metallic"), 0.05);
glUniform1f(glGetUniformLocation(program, "roughness"), 0.2);
glUniform1f(glGetUniformLocation(program, "roughness"), 0.9);
glDrawElementsInstanced(
GL_TRIANGLES, // mode
@ -366,8 +368,8 @@ void renderImGui() {
static PlanetParams newPlanetParams;
ImGui::InputFloat3("Pozycja", &newPlanetParams.position[0]);
ImGui::SliderFloat("Rozmiar", &newPlanetParams.size, 0.1f, 10.0f);
ImGui::SliderFloat("Wilgotnosc", &newPlanetParams.humidity, 0.0f, 10.0f); // Слайдер для влажности
ImGui::SliderFloat("Temperatura", &newPlanetParams.temperature, 0.0f, 10.0f); // Слайдер для осадков
ImGui::SliderFloat("Wilgotnosc", &newPlanetParams.humidity, 0.0f, 100.0f); // Слайдер для влажности
ImGui::SliderFloat("Temperatura", &newPlanetParams.temperature, 0.0f, 100.0f); // Слайдер для осадков
if (ImGui::Button("Dodac")) {
newPlanetParams =populatePlanet(newPlanetParams, plant_specimens);
@ -496,7 +498,7 @@ void drawObjectTexture_plantInstanced(Core::RenderContext& context, std::vector<
DrawContextInstanced(context, transformations,modelMatrices,count,material,program);
glUseProgram(0);
}
void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMatrix,float scale,std::vector<glm::vec3>placePoints, PlanetParams planetParams,int count) {
void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMatrix,float scale,std::vector<glm::vec3>placePoints, PlanetParams planetParams,int count,Material material) {
float planetScale = planetParams.size;
glm::mat4 savedobjectMatrix;
@ -522,7 +524,7 @@ void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMat
drawObjectTexture_plantInstanced(objectContext, matrices, plant2_1Material, program_pbr_instanced,count);
drawObjectTexture_plantInstanced(objectContext, matrices, material, program_pbr_instanced,count);
@ -636,7 +638,7 @@ void renderScene(GLFWwindow* window)
current_type_plant_positions.push_back(std::get<1>(plant));
}
//placeObjectOnPlanet(plant_specimens[std::get<0>(plant)].modelContext, glm::mat4(), 0.2, std::get<1>(plant), planet, plant_type_count);
placeObjectOnPlanet(plant_specimens[0].modelContext, glm::mat4(), 0.2, current_type_plant_positions, planet, plant_type_count);
placeObjectOnPlanet(plant_specimens[0].modelContext, glm::mat4(), 0.2, current_type_plant_positions, planet, plant_type_count, plant_specimens[0].material);
}
//for (const auto& plant : plants)
@ -715,10 +717,11 @@ void init(GLFWwindow* window)
//material
loadMTLAndGetTextureID("./models/plant_1_1.mtl", plant3Material);
loadMTLAndGetTextureID("./models/plant_2_1_small.mtl", plant2_1Material);
loadMTLAndGetTextureID("./models/plant_2_1_small.mtl", plant2_1Material);
plant_specimens.push_back(Plant::Plant(5, 0.99, 5, 1, "plant1_s", "./models/plant_1_1_zmn.obj", plant3Material));
plant_specimens.push_back(Plant::Plant(20, 0.95, 20, 1, "plant1_m", "./models/plant_2_1.obj", plant2_1Material));
plant_specimens.push_back(Plant::Plant(1, 0.99, 1, 1, "plant1_s", "./models/plant_1_1_zmn.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"));
//plant_specimens.push_back(Plant::Plant(1, 1, 1, 1, "testPlantFFFFFFFFFFFF", "./models/plant_4.ply"));