60 [[nodiscard]]
virtual bool can_write(
const std::string& filepath)
const = 0;
70 const std::string& filepath,
71 const std::vector<Kakshya::MeshData>& meshes,
106 const std::vector<std::string>& extensions,
109 for (
const auto& ext : extensions) {
110 m_factories[ext] = factory;
114 [[nodiscard]] std::unique_ptr<ModelWriter>
create_writer(
const std::string& filepath)
const
116 auto ext = std::filesystem::path(filepath).extension().string();
117 if (!ext.empty() && ext[0] ==
'.') {
121 auto it = m_factories.find(ext);
122 if (it != m_factories.end()) {
130 std::vector<std::string> exts;
131 exts.reserve(m_factories.size());
132 for (
const auto& [ext, _] : m_factories) {
std::unordered_map< std::string, ModelWriterFactory > m_factories
std::unique_ptr< ModelWriter > create_writer(const std::string &filepath) const
void register_writer(const std::vector< std::string > &extensions, const ModelWriterFactory &factory)
std::vector< std::string > get_registered_extensions() const
static ModelWriterRegistry & instance()
Singleton registry dispatching model writes by file extension.
virtual ~ModelWriter()=default
virtual std::vector< std::string > get_supported_extensions() const =0
File extensions handled by this writer (without dot).
virtual bool can_write(const std::string &filepath) const =0
Check whether this writer handles the given filepath.
virtual std::string get_last_error() const =0
Last error message or empty string.
virtual bool write(const std::string &filepath, const std::vector< Kakshya::MeshData > &meshes, const ModelWriteOptions &options={})=0
Write one or more meshes to disk as a single scene.
Abstract base for 3D model format writers.
std::function< std::unique_ptr< ModelWriter >()> ModelWriterFactory
std::string material_name_override
Name to embed for the exported material, if the target format carries one.
std::string format_id
Assimp export format id, e.g.
Configuration for model writing.