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 629 of file IOManager.cpp.

630{
631 auto reader = std::make_shared<ModelReader>();
632
633 if (!reader->can_read(filepath)) {
635 "IOManager::load_mesh: unsupported format '{}'", filepath);
636 return {};
637 }
638
639 if (!reader->open(filepath)) {
641 "IOManager::load_mesh: failed to open '{}' — {}",
642 filepath, reader->get_last_error());
643 return {};
644 }
645
646 if (!resolver)
647 resolver = make_default_resolver(filepath);
648
649 auto buffers = reader->create_mesh_buffers(resolver);
650 reader->close();
651
652 if (buffers.empty()) {
654 "IOManager::load_mesh: no meshes in '{}'", filepath);
655 return {};
656 }
657
659 "IOManager::load_mesh: {} mesh(es) from '{}'",
660 buffers.size(),
661 std::filesystem::path(filepath).filename().string());
662
663 return buffers;
664}
#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.