Added a little loading
This commit is contained in:
24
src/mesh.cpp
24
src/mesh.cpp
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user