This commit is contained in:
Ben
2019-02-27 15:11:04 +00:00
parent c9a1d535a6
commit 76a574610a
2 changed files with 17 additions and 11 deletions

View File

@@ -7,13 +7,10 @@ Mesh::Mesh() {
Mesh::Mesh(std::string objPath) {
Logger logger;
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string warn;
std::string err;
ObjLMesh mesh;
std::string warn, err;
bool canLoad = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, objPath.c_str());
bool canLoad = tinyobj::LoadObj(&mesh.attrib, &mesh.shapes, &mesh.materials, &warn, &err, objPath.c_str());
if (!err.empty() || !canLoad) {
logger << LOGGER_ERROR << "Cannot load obj '" << objPath << "' :" << err << LOGGER_ENDL;
@@ -26,14 +23,14 @@ Mesh::Mesh(std::string objPath) {
logger << LOGGER_INFO << "Loaded: " << objPath << LOGGER_ENDL;
loadFromObj(attrib);
loadFromObj(mesh);
}
Mesh::Mesh(tinyobj::attrib_t attribArr) {
Mesh::Mesh(ObjLMesh mesh) {
// loadFromObj(objMesh);
}
void Mesh::loadFromObj(tinyobj::attrib_t atrribArr) {
void Mesh::loadFromObj(ObjLMesh mesh) {
// OBJLtoGLM(objMesh.Vertices, vertices, normals, texCoords);
// indices = objMesh.Indices;
// name = objMesh.MeshName;

View File

@@ -26,13 +26,22 @@ struct Vertex {
glm::vec2 texCoord;
};
// For easy passing around of the tinyobj
// mesh structures
struct ObjLMesh {
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
};
class Mesh {
public:
Mesh();
Mesh(std::string objPath);
Mesh(tinyobj::attrib_t attribArr);
Mesh(ObjLMesh mesh);
void loadFromObj(tinyobj::attrib_t attribArr);
void loadFromObj(ObjLMesh mesh);
void setup();
void bind();