cleaning up
This commit is contained in:
parent
cb7385bc1b
commit
ba77304023
@ -202,5 +202,7 @@ void Core::DrawContext(Core::RenderContext& context)
|
||||
GL_UNSIGNED_INT, // type
|
||||
(void*)0 // element array buffer offset
|
||||
);
|
||||
std::cout << context.size << std::endl;
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ namespace Plant
|
||||
this->tempSD = tempSD;
|
||||
this->name = name;
|
||||
this->fileName = fileName;
|
||||
this->modelContext = Core::RenderContext();
|
||||
loadModelToContext2("./models/plants/polygon.obj", modelContext);
|
||||
|
||||
this->pos = glm::vec3(1,0,0);
|
||||
@ -156,13 +155,13 @@ bool sortFunction(std::tuple<int, float> objA, std::tuple<int, float> objB)
|
||||
PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plants)
|
||||
{
|
||||
float probability=0.5f;
|
||||
int HOW_MANY_PLANTS = 100;
|
||||
int HOW_MANY_PLANTS = 1000;
|
||||
int PRECISION = 10000;
|
||||
float NOTHING_SPAWNS_CUTOFF = 0.0;
|
||||
int sum = 0;
|
||||
int chosen_number = 0;
|
||||
std::vector<std::tuple<int, int>> probabilities;
|
||||
|
||||
int plant_count = 0;
|
||||
|
||||
sum = NOTHING_SPAWNS_CUTOFF * PRECISION;
|
||||
int j = 0;
|
||||
@ -197,13 +196,13 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
|
||||
if (winnerId > -1)
|
||||
{
|
||||
Plant::Plant plant = plants[winnerId];
|
||||
std::cout << "got a winner " << plant.name << std::endl;
|
||||
plant_count += 1;
|
||||
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::cout <<"plant_count:" << plant_count << std::endl;
|
||||
|
||||
return planet;
|
||||
|
||||
@ -234,6 +233,9 @@ Core::Shader_Loader shaderLoader;
|
||||
|
||||
GLuint programBiomes;
|
||||
|
||||
Material plant3Material;
|
||||
|
||||
Material plant2_1Material;
|
||||
|
||||
Core::RenderContext plantContext;
|
||||
|
||||
@ -407,48 +409,28 @@ void drawObjectTexture_plant(Core::RenderContext& context, glm::mat4 modelMatrix
|
||||
|
||||
void placeObjectOnPlanet(Core::RenderContext& objectContext, glm::mat4 objectMatrix,float scale,glm::vec3 placePoint, PlanetParams planetParams) {
|
||||
float planetScale = planetParams.size;
|
||||
//placePoint is described by normalized vector that points to a point on a sphere from inside of itself
|
||||
placePoint = glm::normalize(placePoint);
|
||||
|
||||
//float diameter = ?;
|
||||
glm::mat4 cobjectMatrix = objectMatrix;
|
||||
cobjectMatrix = glm::scale(cobjectMatrix, glm::vec3(scale));
|
||||
|
||||
objectMatrix;
|
||||
objectMatrix = glm::scale(objectMatrix, glm::vec3(scale));
|
||||
float diameter = 24.4 * planetScale;
|
||||
//objectMatrix = objectMatrix * glm::translate(placePoint * 0.1f);
|
||||
glm::vec3 base = glm::vec3(0.f, 1.f, 0.f);
|
||||
glm::vec3 axis;
|
||||
float angle;
|
||||
//odpowiednio obrócić
|
||||
axis = glm::cross(placePoint, base);
|
||||
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);
|
||||
|
||||
objectMatrix = objectMatrix * glm::rotate(objectMatrix, angle, axis) * glm::translate(base * diameter);
|
||||
objectMatrix = objectMatrix * glm::translate(planetParams.position*(1/scale));
|
||||
drawObjectTexture_plant(objectContext, objectMatrix, plant3Material, program_pbr);
|
||||
|
||||
|
||||
// wysunąć w dobrą stronę
|
||||
|
||||
|
||||
|
||||
//objectMatrix = objectMatrix * glm::lookAt(
|
||||
// placePoint,
|
||||
// glm::vec3(0, 0, 0),
|
||||
// glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
//* objectMatrix;
|
||||
//*glm::translate(placePoint)
|
||||
//TEMPORARY DRAW FUNCTION
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Material plant3Material;
|
||||
|
||||
Material plant2_1Material;
|
||||
PlanetParams TestPlanet = PlanetParams();
|
||||
|
||||
#include <cmath>
|
||||
@ -598,9 +580,9 @@ void init(GLFWwindow* window)
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
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");
|
||||
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
||||
//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");
|
||||
//programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
||||
programBiomes = shaderLoader.CreateProgram("shaders/shader_biomes.vert", "shaders/shader_biomes.frag");
|
||||
program_pbr = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
|
||||
loadModelToContext2("./models/plants/polygon.obj", plantContext);
|
||||
@ -626,14 +608,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, "plant1_s", "./models/plant_1_1_small.obj"));
|
||||
plant_specimens.push_back(Plant::Plant(1, 0.95, 1, 1, "plant1_m", "./models/plant_1_1_med1.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"));
|
||||
//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"));
|
||||
}
|
||||
|
||||
void shutdown(GLFWwindow* window)
|
||||
|
Loading…
Reference in New Issue
Block a user