added plants

This commit is contained in:
Jay Robson 2024-01-23 23:45:19 +11:00
parent a66222fdba
commit 9b99d84b20
3 changed files with 12 additions and 6 deletions

View File

@ -23,6 +23,7 @@ struct proc_state
std::string base;
std::vector<arrays::vertex> vertices;
std::vector<unsigned int> indices;
glm::vec<3, double> pos;
};
static unsigned int proc_texture(const proc_state& state, aiMaterial* mat, aiTextureType type)
@ -52,7 +53,7 @@ static void proc_mesh(proc_state& state, std::vector<mesh>& meshes, aiMesh* mesh
arrays::vertex vertex;
vertex.texid = texid;
vertex.pos = {mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z};
vertex.pos = state.pos + glm::vec<3, double>(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z);
if(mesh->HasNormals())
{
@ -95,9 +96,9 @@ static void proc_node(proc_state& state, std::vector<mesh>& meshes, aiNode* node
}
}
void model::load(std::string base, std::string filename)
void model::load(std::string base, std::string filename, glm::vec<3, double> pos)
{
proc_state state {.base = base};
proc_state state {.base = base, .pos = pos};
std::string path = base + "/" + filename;
Assimp::Importer importer;

View File

@ -3,6 +3,7 @@
#include "mesh.hpp"
#include <glm/vec3.hpp>
#include <vector>
#include <string>
@ -13,7 +14,8 @@ struct model
{
std::vector<mesh> meshes;
void load(std::string base, std::string path);
void load(std::string base, std::string path, glm::vec<3, double> offset);
void load(std::string base, std::string path) { load(base, path, {0, 0, 0}); }
void render() const;
};

View File

@ -70,8 +70,11 @@ void window::create()
shader::init_program();
// Model.load("Minimalistic Modern Office", "Minimalistic Modern Office.fbx");
Model.load("../assets", "scene.obj");
Model.load("../assets/scene", "scene.obj");
Model.load("../assets/AllPlants", "Plant3.obj", {2.5, 3.5, 0});
Model.load("../assets/AllPlants", "Plant1.obj", {-2.5, -3.5, 0});
Model.load("../assets/AllPlants", "Plant4.obj", {2, -3, 0});
Model.load("../assets/AllPlants", "Plant5.obj", {-2, 3, 0});
glViewport(0, 0, 800, 600);
}