diff --git a/src/mesh.cpp b/src/mesh.cpp index 056ff8f..d85df52 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -5,17 +5,26 @@ Mesh::Mesh() { } Mesh::Mesh(std::string objPath) { + Logger logger; + objl::Loader loader; + bool canLoad = loader.LoadFile(objPath); + if (!canLoad) { + logger << LOGGER_ERROR << "Cannot load obj '" << objPath << "'" << LOGGER_ENDL; + return; + } + + OBJLtoGLM(loader.LoadedMeshes[0].Vertices, vertices, normals, texCoords); } Mesh::Mesh(objl::Mesh objMesh) { OBJLtoGLM(objMesh.Vertices, vertices, normals, texCoords); - // objMesh.Vertices includes normals, positions and texcoords - // it must convert them to the neccesary GLM shit + UintToGLuint(objMesh.Indices, indices); } -void Mesh::loadFromObj(objl::Mesh objmesh) { - +void Mesh::loadFromObj(objl::Mesh objMesh) { + OBJLtoGLM(objMesh.Vertices, vertices, normals, texCoords); + UintToGLuint(objMesh.Indices, indices); } void Mesh::settup() { diff --git a/src/mesh.h b/src/mesh.h index ccb5ab1..780f20d 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -12,6 +12,7 @@ #include +#include #include "./util/util.h" class Shader; diff --git a/src/model.h b/src/model.h index e69de29..12223c5 100644 --- a/src/model.h +++ b/src/model.h @@ -0,0 +1,12 @@ +#ifndef SMHENGINE_SRC_MODEL_H_ +#define SMHENGINE_SRC_MODEL_H_ + +#include "mesh.h" +#include "material.h" + +class Mesh { +public: + +}; + +#endif