Added a little loading

This commit is contained in:
Ben
2019-02-27 14:58:43 +00:00
parent 55531371e3
commit c9a1d535a6
4 changed files with 101 additions and 109 deletions

View File

@@ -6,24 +6,34 @@ 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;
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string warn;
std::string err;
bool canLoad = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, objPath.c_str());
if (!err.empty() || !canLoad) {
logger << LOGGER_ERROR << "Cannot load obj '" << objPath << "' :" << err << LOGGER_ENDL;
return;
}
if (!warn.empty()) {
logger << LOGGER_WARN << "Warning from obj loader while loading obj '" << objPath << "' :" << warn << LOGGER_ENDL;
}
logger << LOGGER_INFO << "Loaded: " << objPath << LOGGER_ENDL;
// loadFromObj(loader.LoadedMeshes[0]);
loadFromObj(attrib);
}
Mesh::Mesh(objl::Mesh objMesh) {
Mesh::Mesh(tinyobj::attrib_t attribArr) {
// loadFromObj(objMesh);
}
void Mesh::loadFromObj(objl::Mesh objMesh) {
void Mesh::loadFromObj(tinyobj::attrib_t atrribArr) {
// OBJLtoGLM(objMesh.Vertices, vertices, normals, texCoords);
// indices = objMesh.Indices;
// name = objMesh.MeshName;

View File

@@ -11,13 +11,15 @@
#include <glm/gtc/type_ptr.hpp>
#include <tiny_obj_loader.h>
// #include <objectLoader.h>
#include <logger.h>
#include "shader.h"
#include "./util/util.h"
// Not in use yet
// Will be used as a vector, enabling
// the use of strides when sending the
// vertex data to the GPU
struct Vertex {
glm::vec3 vertice;
glm::vec3 normal;
@@ -28,9 +30,9 @@ class Mesh {
public:
Mesh();
Mesh(std::string objPath);
Mesh(objl::Mesh objMesh);
Mesh(tinyobj::attrib_t attribArr);
void loadFromObj(objl::Mesh objMesh);
void loadFromObj(tinyobj::attrib_t attribArr);
void setup();
void bind();

View File

@@ -4,7 +4,8 @@
#include <glad/glad.hpp>
#include <glm/glm.hpp>
#include <vector>
#include <OBJLoader.h>
#include <tiny_obj_loader.h>
void OBJLtoGLM(std::vector<objl::Vertex>& inVertArr,
std::vector<glm::vec3>& outVert,