diff --git a/src/graphics/model.cpp b/src/graphics/model.cpp index 3862792..84755ea 100644 --- a/src/graphics/model.cpp +++ b/src/graphics/model.cpp @@ -23,6 +23,7 @@ struct proc_state std::string base; std::vector vertices; std::vector 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& 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& 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; diff --git a/src/graphics/model.hpp b/src/graphics/model.hpp index 86aa60e..26eaa0f 100644 --- a/src/graphics/model.hpp +++ b/src/graphics/model.hpp @@ -3,6 +3,7 @@ #include "mesh.hpp" +#include #include #include @@ -13,7 +14,8 @@ struct model { std::vector 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; }; diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index 6122107..f4ea4bf 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -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); }