diff options
author | Aki <please@ignore.pl> | 2024-04-08 01:21:41 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-04-08 01:21:41 +0200 |
commit | 3cc6b923edb69907794c3dc6daa61a445b3a56c0 (patch) | |
tree | 2e9c736042ef364bba0957052e9fddf0fae41097 /MagicEx/src/convert.inl.h | |
parent | 3b1776352524c9f24b478260e18cb04d2d27efb5 (diff) | |
download | starshatter-3cc6b923edb69907794c3dc6daa61a445b3a56c0.zip starshatter-3cc6b923edb69907794c3dc6daa61a445b3a56c0.tar.gz starshatter-3cc6b923edb69907794c3dc6daa61a445b3a56c0.tar.bz2 |
Added 3ds2mag converter
Solidified the converters a bit to prevent selected segvs/page faults.
Diffstat (limited to 'MagicEx/src/convert.inl.h')
-rw-r--r-- | MagicEx/src/convert.inl.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/MagicEx/src/convert.inl.h b/MagicEx/src/convert.inl.h new file mode 100644 index 0000000..7bf29ee --- /dev/null +++ b/MagicEx/src/convert.inl.h @@ -0,0 +1,39 @@ +/* Starshatter: The Open Source Project + Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors + Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors + Copyright (c) 1997-2006, Destroyer Studios LLC. +*/ + +#include <memory> +#include <string> + +#include <DataLoader.h> +#include <Solid.h> + +#include <MagicLoad.h> + + +namespace starshatter +{ + + +template <typename Input, typename Output> +int +convert(const std::string& input, const std::string& output) +{ + DataLoader::Initialize(); + auto solid = std::make_unique<Solid>(); + if (!ImportInto<Input>(input.c_str(), solid.get())) + return 1; + Output exporter {output.c_str()}; + auto* model = solid->GetModel(); + if (model == nullptr) + return 1; + if (!exporter.Save(model)) + return 1; + DataLoader::Close(); + return 0; +} + + +} // namespace starshatter |