|
|
|
|
@ -18,7 +18,7 @@ void assimpLogCB(const char* message, char* user);
|
|
|
|
|
meMeshInfo* allocateMeshInfo(uint num_vertices, uint num_indices, bool has_normals, bool has_texture); |
|
|
|
|
void freeMesh(meMeshInfo* mesh); |
|
|
|
|
inline glm::vec3 copyVector(aiVector3D v_in, glm::vec3& v_out); |
|
|
|
|
meMeshInfo* copyMeshInfo(const char* data_dir, const aiScene* scene, aiMesh* mesh); |
|
|
|
|
meMeshInfo* copyMeshInfo(const aiScene* scene, aiMesh* mesh); |
|
|
|
|
bool loadDiffuseTexture(const char* data_dir, const aiScene* scene, aiMesh* mesh, meMeshInfo* mi); |
|
|
|
|
|
|
|
|
|
// interface
|
|
|
|
|
@ -55,9 +55,8 @@ meLoadFromFile(meMeshGroup& mesh_group, const char* data_dir, const char* filena
|
|
|
|
|
mesh_group.use_normals = scene->mMeshes[0]->HasNormals(); |
|
|
|
|
|
|
|
|
|
for (uint i = 0; i < scene->mNumMeshes; i++) { |
|
|
|
|
//mesh_group.meshes[i] = copyMeshInfo(data_dir, scene, scene->mMeshes[i]);
|
|
|
|
|
aiMesh* mesh = scene->mMeshes[i]; |
|
|
|
|
meMeshInfo* mi = copyMeshInfo(data_dir, scene, mesh); |
|
|
|
|
meMeshInfo* mi = copyMeshInfo(scene, mesh); |
|
|
|
|
|
|
|
|
|
if (mesh->HasTextureCoords(0)) { |
|
|
|
|
if (!loadDiffuseTexture(data_dir, scene, mesh, mi)) { |
|
|
|
|
@ -168,7 +167,7 @@ loadDiffuseTexture(const char* data_dir, const aiScene* scene, aiMesh* mesh, meM
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
meMeshInfo* |
|
|
|
|
copyMeshInfo(const char* data_dir, const aiScene* scene, aiMesh* mesh) |
|
|
|
|
copyMeshInfo(const aiScene* scene, aiMesh* mesh) |
|
|
|
|
{ |
|
|
|
|
bool has_tex = mesh->HasTextureCoords(0); |
|
|
|
|
bool has_normals = mesh->HasNormals(); |
|
|
|
|
@ -176,7 +175,6 @@ copyMeshInfo(const char* data_dir, const aiScene* scene, aiMesh* mesh)
|
|
|
|
|
|
|
|
|
|
// copy vertices, normals, and texture coords
|
|
|
|
|
for (uint i = 0; i < mi->num_vertices; i++) { |
|
|
|
|
//TODO: can probably use glm::vec3 constructor here and remove copyVector helper
|
|
|
|
|
copyVector(mesh->mVertices[i], mi->vertices[i]); |
|
|
|
|
|
|
|
|
|
if (has_normals) |
|
|
|
|
|