MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ load_mesh()

std::vector< std::shared_ptr< Buffers::MeshBuffer > > MayaFlux::IO::IOManager::load_mesh ( const std::string &  filepath,
TextureResolver  resolver = nullptr 
)

Load all meshes from a 3D model file into MeshBuffer instances.

Opens the file via ModelReader, extracts all aiMesh entries as MeshData, constructs one MeshBuffer per mesh, calls setup_processors() on each, and returns them. setup_rendering() is left to the caller.

If resolver is null, the default resolver is used: paths resolved relative to the model file's directory via ImageReader::load_texture. Unresolvable textures are logged and skipped.

Parameters
filepathPath to the model file (glTF, FBX, OBJ, PLY, etc.).
resolverOptional texture resolver.
Returns
One MeshBuffer per mesh in scene order, or empty on failure.

Definition at line 381 of file IOManager.cpp.

382{
383 auto reader = std::make_shared<ModelReader>();
384
385 if (!reader->can_read(filepath)) {
387 "IOManager::load_mesh: unsupported format '{}'", filepath);
388 return {};
389 }
390
391 if (!reader->open(filepath)) {
393 "IOManager::load_mesh: failed to open '{}' — {}",
394 filepath, reader->get_last_error());
395 return {};
396 }
397
398 if (!resolver)
399 resolver = make_default_resolver(filepath);
400
401 auto buffers = reader->create_mesh_buffers(resolver);
402 reader->close();
403
404 if (buffers.empty()) {
406 "IOManager::load_mesh: no meshes in '{}'", filepath);
407 return {};
408 }
409
411 "IOManager::load_mesh: {} mesh(es) from '{}'",
412 buffers.size(),
413 std::filesystem::path(filepath).filename().string());
414
415 return buffers;
416}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, MF_ERROR, and MF_INFO.