Rewrote the objl library and did some conversion helper classes
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// #include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
// Custom includes
|
||||
#define OBJL_DEFINITION
|
||||
#define LOGGER_DEFINITION
|
||||
#include <logger.h>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Mesh::Mesh(std::string objPath) {
|
||||
}
|
||||
|
||||
Mesh::Mesh(objl::Mesh objMesh) {
|
||||
OBJLtoGLM(objMesh.Vertices, vertices);
|
||||
OBJLtoGLM(objMesh.Vertices, vertices, normals, texCoords);
|
||||
// objMesh.Vertices includes normals, positions and texcoords
|
||||
// it must convert them to the neccesary GLM shit
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <OBJLoader.h>
|
||||
|
||||
#include <glad/glad.hpp>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <OBJLoader.h>
|
||||
|
||||
#include "./util/util.h"
|
||||
|
||||
class Shader;
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
#include "util.h"
|
||||
|
||||
void OBJLtoGLM(std::vector<objl::Vertex>& inVertArr,
|
||||
std::vector<glm::vec3>& outVert,
|
||||
std::vector<glm::vec3>& outNorm,
|
||||
std::vector<glm::vec2>& outTexCoord) {
|
||||
|
||||
for (int i = 0; i < inVertArr.size(); i++) {
|
||||
|
||||
glm::vec3 tempVert {inVertArr[i].Position.X, inVertArr[i].Position.Y, inVertArr[i].Position.Z};
|
||||
outVert.push_back(tempVert);
|
||||
|
||||
glm::vec3 tempNorm {inVertArr[i].Normal.X, inVertArr[i].Normal.Y, inVertArr[i].Normal.Z};
|
||||
outNorm.push_back(tempNorm);
|
||||
|
||||
glm::vec2 tempTexCoord {inVertArr[i].TextureCoordinate.X, inVertArr[i].TextureCoordinate.Y};
|
||||
outTexCoord.push_back(tempTexCoord);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UintToGLuint(std::vector<unsigned int>& inIndices,
|
||||
std::vector<GLuint>& outIndices) {
|
||||
|
||||
for (int i = 0; i < inIndices.size(); i++) {
|
||||
outIndices.push_back(inIndices[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
#ifndef SMHENGINE_SRC_UTIL_UTIL_H_
|
||||
#define SMHENGINE_SRC_UTIL_UTUL_H_
|
||||
|
||||
template <typename T, typename P>
|
||||
void OBJLtoGLM(T& inVec, P& outVec) {
|
||||
#include <glad/glad.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
#include <OBJLoader.h>
|
||||
|
||||
}
|
||||
void OBJLtoGLM(std::vector<objl::Vertex>& inVertArr,
|
||||
std::vector<glm::vec3>& outVert,
|
||||
std::vector<glm::vec3>& outNorm,
|
||||
std::vector<glm::vec2>& outTexCoord);
|
||||
|
||||
void UintToGLuint(std::vector<unsigned int>& inIndices,
|
||||
std::vector<GLuint>& outIndices);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user