You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
592 B

4 months ago
#include "mesh.hpp"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "constraints.hpp"
Mesh::Mesh(const std::string &fileName) {
Assimp::Importer importer;
auto scene = importer.ReadFile(fileName, aiProcess_Triangulate);
auto mesh = scene->mMeshes[0];
for (size_t i = 0; i < mesh->mNumVertices; i++){
vertices.push_back({
*reinterpret_cast<glm::vec3*>(&mesh->mVertices[i]),
glm::vec3(1, 0, 0)
});
}
for (size_t i = 0; i < mesh->mNumFaces; i++){
faces.push_back(*reinterpret_cast<Face*>(mesh->mFaces[i].mIndices));
}
}