|
|
|
|
@ -19,7 +19,7 @@ meMeshInfo* allocateMeshInfo(uint num_vertices, uint num_indices, bool has_norma
|
|
|
|
|
void freeMesh(meMeshInfo* mesh); |
|
|
|
|
inline glm::vec3 copyVector(aiVector3D v_in, glm::vec3& v_out); |
|
|
|
|
meMeshInfo* copyMeshInfo(const aiScene* scene, aiMesh* mesh); |
|
|
|
|
bool loadDiffuseTexture(const char* data_dir, const aiScene* scene, aiMesh* mesh, meMeshInfo* mi); |
|
|
|
|
bool loadDiffuseTexture(const aiScene* scene, aiMesh* mesh, meMeshInfo* mi); |
|
|
|
|
|
|
|
|
|
// interface
|
|
|
|
|
|
|
|
|
|
@ -35,13 +35,13 @@ meInitAssimp()
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
meLoadFromFile(meMeshGroup& mesh_group, const char* data_dir, const char* filename) |
|
|
|
|
meLoadFromFile(meMeshGroup& mesh_group, const char* filepath) |
|
|
|
|
{ |
|
|
|
|
LOG(Info) << "Loading file: " << filename << "\n"; |
|
|
|
|
const aiScene* scene = aiImportFile(filename, aiProcessPreset_TargetRealtime_MaxQuality); |
|
|
|
|
LOG(Info) << "Loading file: " << filepath << "\n"; |
|
|
|
|
const aiScene* scene = aiImportFile(filepath, aiProcessPreset_TargetRealtime_MaxQuality); |
|
|
|
|
|
|
|
|
|
if (!scene) { |
|
|
|
|
LOG(Error) << "Error loading file: " << filename << "\n"; |
|
|
|
|
LOG(Error) << "Error loading file: " << filepath << "\n"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ meLoadFromFile(meMeshGroup& mesh_group, const char* data_dir, const char* filena
|
|
|
|
|
meMeshInfo* mi = copyMeshInfo(scene, mesh); |
|
|
|
|
|
|
|
|
|
if (mesh->HasTextureCoords(0)) { |
|
|
|
|
if (!loadDiffuseTexture(data_dir, scene, mesh, mi)) { |
|
|
|
|
if (!loadDiffuseTexture(scene, mesh, mi)) { |
|
|
|
|
LOG(Error) << "Error loading texture, cleaning up import\n"; |
|
|
|
|
freeMesh(mi); |
|
|
|
|
aiReleaseImport(scene); |
|
|
|
|
@ -138,7 +138,7 @@ copyVector(aiVector3D v_in, glm::vec3& v_out)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
loadDiffuseTexture(const char* data_dir, const aiScene* scene, aiMesh* mesh, meMeshInfo* mi) |
|
|
|
|
loadDiffuseTexture(const aiScene* scene, aiMesh* mesh, meMeshInfo* mi) |
|
|
|
|
{ |
|
|
|
|
aiMaterial* mat = scene->mMaterials[mesh->mMaterialIndex]; |
|
|
|
|
aiString file_name; |
|
|
|
|
@ -162,7 +162,7 @@ loadDiffuseTexture(const char* data_dir, const aiScene* scene, aiMesh* mesh, meM
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
LOG(Info) << "Loading texture file: " << file_name.C_Str() << "\n"; |
|
|
|
|
mi->diffuse_texture = utilLoadImage(data_dir, file_name.C_Str()); |
|
|
|
|
mi->diffuse_texture = utilLoadImage(file_name.C_Str()); |
|
|
|
|
mi->use_texture = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|