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

◆ save_mesh() [5/5]

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 190 of file ModelExport.cpp.

194{
195 if (!network) {
196 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO, "save_mesh: null network");
197 return false;
198 }
199
200 std::vector<Kakshya::MeshData> meshes;
201 meshes.reserve(network->slots().size());
202 for (const auto& slot : network->slots()) {
203 if (!slot.node) {
204 continue;
205 }
206 std::string diffuse_path;
207 if (slot.diffuse_texture) {
208 const auto suffix = !slot.name.empty() ? slot.name : std::to_string(slot.index);
209 diffuse_path = pack_diffuse_texture(slot.diffuse_texture, filepath, suffix);
210 }
211 if (auto packed = pack_node(slot.node, slot.world_transform, slot.name, diffuse_path)) {
212 meshes.push_back(std::move(*packed));
213 }
214 }
215
216 if (meshes.empty()) {
217 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO,
218 "save_mesh: no exportable slots in network");
219 return false;
220 }
221
222 return write_via_registry(filepath, meshes, options);
223}
#define MF_ERROR(comp, ctx,...)
std::string diffuse_path
Core::GlobalNetworkConfig network
Definition Config.cpp:39

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