MayaFlux 1.0.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 897 of file IOManager.cpp.

898{
899 auto reader = std::make_shared<ModelReader>();
900
901 if (!reader->can_read(filepath)) {
903 "IOManager::load_mesh: unsupported format '{}'", filepath);
904 return {};
905 }
906
907 if (!reader->open(filepath)) {
909 "IOManager::load_mesh: failed to open '{}' — {}",
910 filepath, reader->get_last_error());
911 return {};
912 }
913
914 if (!resolver)
915 resolver = Detail::make_default_resolver(filepath);
916
917 auto buffers = reader->create_mesh_buffers(resolver);
918 reader->close();
919
920 if (buffers.empty()) {
922 "IOManager::load_mesh: no meshes in '{}'", filepath);
923 return {};
924 }
925
927 "IOManager::load_mesh: {} mesh(es) from '{}'",
928 buffers.size(),
929 std::filesystem::path(filepath).filename().string());
930
931 return buffers;
932}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
TextureResolver make_default_resolver(const std::string &filepath)
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, MayaFlux::IO::Detail::make_default_resolver(), MF_ERROR, and MF_INFO.

+ Here is the call graph for this function: