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

◆ load_mesh_network()

std::shared_ptr< Nodes::Network::MeshNetwork > MayaFlux::IO::IOManager::load_mesh_network ( const std::string &  filepath,
TextureResolver  resolver = nullptr 
)

Load a 3D model file as a MeshNetwork.

One MeshSlot per aiMesh. Per-slot diffuse textures resolved via resolver. Null resolver uses the default: ImageReader::load_texture relative to the model file's directory.

Parameters
filepathPath to the model file.
resolverOptional texture resolver.
Returns
Populated MeshNetwork, or nullptr on failure.

Definition at line 667 of file IOManager.cpp.

668{
669 auto reader = std::make_shared<ModelReader>();
670
671 if (!reader->can_read(filepath)) {
673 "IOManager::load_mesh_network: unsupported format '{}'", filepath);
674 return nullptr;
675 }
676
677 if (!reader->open(filepath)) {
679 "IOManager::load_mesh_network: failed to open '{}' — {}",
680 filepath, reader->get_last_error());
681 return nullptr;
682 }
683
684 if (!resolver)
685 resolver = make_default_resolver(filepath);
686
687 auto net = reader->create_mesh_network(resolver);
688 reader->close();
689
690 if (!net) {
692 "IOManager::load_mesh_network: no network from '{}'", filepath);
693 return nullptr;
694 }
695
697 "IOManager::load_mesh_network: {} slots from '{}'",
698 net->slot_count(),
699 std::filesystem::path(filepath).filename().string());
700
701 return net;
702}
#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.