Extracts from the currently imported scene. Returns empty if no scene is loaded. Does not call close().
74{
77 return {};
78 }
79
80 const aiScene* s =
m_impl->scene;
81 std::vector<Kakshya::MeshData> result;
82 result.reserve(s->mNumMeshes);
83
84 for (unsigned int i = 0; i < s->mNumMeshes; ++i) {
85 const aiMesh* mesh = s->mMeshes[i];
86
87 std::string mesh_name(mesh->mName.C_Str());
88
89 std::string mat_name;
90 if (s->mNumMaterials > 0 && mesh->mMaterialIndex < s->mNumMaterials) {
91 aiString ai_mat;
92 s->mMaterials[mesh->mMaterialIndex]->Get(AI_MATKEY_NAME, ai_mat);
93 mat_name = ai_mat.C_Str();
94 }
95
97 if (mesh_data.is_valid()) {
98 result.push_back(std::move(mesh_data));
99 } else {
101 "ModelReader: mesh '{}' produced invalid MeshData, skipped",
102 mesh_name.empty() ? "<unnamed>" : mesh_name);
103 }
104 }
105
107 "ModelReader: extracted {}/{} meshes",
108 result.size(), s->mNumMeshes);
109
110 return result;
111}
#define MF_INFO(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::unique_ptr< Impl > m_impl
Kakshya::MeshData extract_single_mesh(const void *ai_mesh, const void *ai_scene, std::string_view mesh_name, std::string_view material_name) const
void set_error(std::string msg) const
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.