Converting to GLM shit from tinyobjloader, having trouble with normals / indicies
This commit is contained in:
@@ -2,39 +2,48 @@
|
||||
|
||||
#include <logger.h>
|
||||
|
||||
void OBJLtoGLM(std::vector<objl::Vertex>& inVertArr,
|
||||
void OBJLtoGLM(ObjLMesh& mesh,
|
||||
std::vector<glm::vec3>& outVert,
|
||||
std::vector<glm::vec3>& outNorm,
|
||||
std::vector<glm::vec3>& outTexCoord) {
|
||||
std::vector<glm::vec3>& outTexCoord,
|
||||
std::vector<GLuint>& outIndices) {
|
||||
|
||||
for (int i = 0; i < inVertArr.size() - 1; i++) {
|
||||
|
||||
glm::vec3 tempVert {inVertArr[i].Position.X, inVertArr[i].Position.Y, inVertArr[i].Position.Z};
|
||||
outVert.push_back(tempVert);
|
||||
for (const auto &shape : mesh.shapes) {
|
||||
for (const auto& index : shape.mesh.indices) {
|
||||
|
||||
glm::vec3 tempNorm {inVertArr[i].Normal.X, inVertArr[i].Normal.Y, inVertArr[i].Normal.Z};
|
||||
outNorm.push_back(tempNorm);
|
||||
outVert.push_back({
|
||||
mesh.attrib.vertices[3 * index.vertex_index + 0],
|
||||
mesh.attrib.vertices[3 * index.vertex_index + 1],
|
||||
mesh.attrib.vertices[3 * index.vertex_index + 2]
|
||||
});
|
||||
|
||||
glm::vec3 tempTexCoord {inVertArr[i].TextureCoordinate.X, inVertArr[i].TextureCoordinate.Y, 1.0f};
|
||||
outTexCoord.push_back(tempTexCoord);
|
||||
outNorm.push_back({
|
||||
mesh.attrib.normals[0],
|
||||
mesh.attrib.normals[0],
|
||||
mesh.attrib.normals[0]
|
||||
});
|
||||
|
||||
outTexCoord.push_back({
|
||||
mesh.attrib.texcoords[2 * index.texcoord_index + 0],
|
||||
mesh.attrib.texcoords[2 * index.texcoord_index + 1],
|
||||
0.0f
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UintToGLuint(std::vector<unsigned int>& inIndices,
|
||||
void UintToGLuint(ObjLMesh& mesh,
|
||||
std::vector<GLuint>& outIndices) {
|
||||
|
||||
for (int i = 0; i < inIndices.size(); i++) {
|
||||
outIndices.push_back(inIndices[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OBJLVec3toGLM(objl::Vector3& inVec, glm::vec3& outVec) {
|
||||
|
||||
outVec.x = inVec.X;
|
||||
outVec.y = inVec.Y;
|
||||
outVec.z = inVec.Z;
|
||||
|
||||
}
|
||||
// void OBJLVec3toGLM(objl::Vector3& inVec, glm::vec3& outVec) {
|
||||
|
||||
// outVec.x = inVec.X;
|
||||
// outVec.y = inVec.Y;
|
||||
// outVec.z = inVec.Z;
|
||||
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user