|
|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
|
|
|
|
|
// forward declarations
|
|
|
|
|
void assimpLogCB(const char* message, char* user); |
|
|
|
|
meMeshInfo* allocateMeshInfo(uint num_vertices, uint num_indices, bool has_normals, bool has_texture); |
|
|
|
|
meMeshInfo* allocateMeshInfo(uint num_vertices, uint num_indices); |
|
|
|
|
void freeMesh(meMeshInfo* mesh); |
|
|
|
|
inline glm::vec3 copyVector(aiVector3D v_in, glm::vec3& v_out); |
|
|
|
|
meMeshInfo* copyMeshInfo(const aiScene* scene, aiMesh* mesh); |
|
|
|
|
@ -96,7 +96,7 @@ assimpLogCB(const char* message, char* user)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
meMeshInfo* |
|
|
|
|
allocateMeshInfo(uint num_vertices, uint num_indices, bool has_normals, bool has_texture) |
|
|
|
|
allocateMeshInfo(uint num_vertices, uint num_indices) |
|
|
|
|
{ |
|
|
|
|
meMeshInfo* mi = UTIL_ALLOC(1, meMeshInfo); |
|
|
|
|
mi->model_transform = glm::mat4(1); |
|
|
|
|
@ -106,8 +106,8 @@ allocateMeshInfo(uint num_vertices, uint num_indices, bool has_normals, bool has
|
|
|
|
|
mi->vertices = UTIL_ALLOC(mi->num_vertices, glm::vec3); |
|
|
|
|
mi->num_indices = num_indices; |
|
|
|
|
mi->indices = UTIL_ALLOC(num_indices, uint); |
|
|
|
|
if (has_normals) mi->normals = UTIL_ALLOC(mi->num_vertices, glm::vec3); |
|
|
|
|
if (has_texture) mi->texture_coords = UTIL_ALLOC(mi->num_vertices, glm::vec3); |
|
|
|
|
mi->normals = UTIL_ALLOC(mi->num_vertices, glm::vec3); |
|
|
|
|
mi->texture_coords = UTIL_ALLOC(mi->num_vertices, glm::vec3); |
|
|
|
|
|
|
|
|
|
return mi; |
|
|
|
|
} |
|
|
|
|
@ -169,21 +169,15 @@ loadDiffuseTexture(const aiScene* scene, aiMesh* mesh, meMeshInfo* mi)
|
|
|
|
|
meMeshInfo* |
|
|
|
|
copyMeshInfo(const aiScene* scene, aiMesh* mesh) |
|
|
|
|
{ |
|
|
|
|
bool has_tex = mesh->HasTextureCoords(0); |
|
|
|
|
bool has_normals = mesh->HasNormals(); |
|
|
|
|
meMeshInfo* mi = allocateMeshInfo(mesh->mNumVertices, mesh->mNumFaces * 3, has_normals, has_tex); |
|
|
|
|
meMeshInfo* mi = allocateMeshInfo(mesh->mNumVertices, mesh->mNumFaces * 3); |
|
|
|
|
|
|
|
|
|
// copy vertices, normals, and texture coords
|
|
|
|
|
for (uint i = 0; i < mi->num_vertices; i++) { |
|
|
|
|
copyVector(mesh->mVertices[i], mi->vertices[i]); |
|
|
|
|
|
|
|
|
|
if (has_normals) |
|
|
|
|
copyVector(mesh->mNormals[i], mi->normals[i]); |
|
|
|
|
|
|
|
|
|
if (has_tex) { |
|
|
|
|
mi->texture_coords[i].x = mesh->mTextureCoords[0][i].x; |
|
|
|
|
mi->texture_coords[i].y = mesh->mTextureCoords[0][i].y; |
|
|
|
|
} |
|
|
|
|
copyVector(mesh->mNormals[i], mi->normals[i]); |
|
|
|
|
mi->texture_coords[i].x = mesh->mTextureCoords[0][i].x; |
|
|
|
|
mi->texture_coords[i].y = mesh->mTextureCoords[0][i].y; |
|
|
|
|
mi->texture_coords[i].z = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// copy indices
|
|
|
|
|
|