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

◆ save_mesh() [5/5]

MAYAFLUX_API bool MayaFlux::IO::save_mesh ( const std::shared_ptr< Nodes::Network::MeshNetwork > &  network,
const std::string &  filepath,
const ModelWriteOptions &  options = {} 
)

Save a MeshNetwork's current slots to disk as one multi-mesh file.

Same shape as the MeshNetworkBuffer overload (each slot's vertices baked into world space from its current world_transform), but works directly on the network: slot data lives on MeshNetwork itself, not on the GPU buffer, so a network never wrapped in a MeshNetworkBuffer, or not yet rendered, is still exportable. The MeshNetworkBuffer overload forwards here via get_network().

Parameters
networkSource network.
filepathDestination path with extension.
optionsFormat-specific writer options.
Returns
True on success. Failure is logged.

Definition at line 179 of file ModelExport.cpp.

183{
184 if (!network) {
185 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO, "save_mesh: null network");
186 return false;
187 }
188
189 std::vector<Kakshya::MeshData> meshes;
190 meshes.reserve(network->slots().size());
191 for (const auto& slot : network->slots()) {
192 if (!slot.node) {
193 continue;
194 }
195 std::string diffuse_path;
196 if (slot.diffuse_texture) {
197 const auto suffix = !slot.name.empty() ? slot.name : std::to_string(slot.index);
198 diffuse_path = pack_diffuse_texture(slot.diffuse_texture, filepath, suffix);
199 }
200 if (auto packed = pack_node(slot.node, slot.world_transform, slot.name, diffuse_path)) {
201 meshes.push_back(std::move(*packed));
202 }
203 }
204
205 if (meshes.empty()) {
206 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO,
207 "save_mesh: no exportable slots in network");
208 return false;
209 }
210
211 return write_via_registry(filepath, meshes, options);
212}
#define MF_ERROR(comp, ctx,...)
std::string diffuse_path
Core::GlobalNetworkConfig network
Definition Config.cpp:43

References diffuse_path, MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, MF_ERROR, and network.