diff options
author | cosmic-linden <111533034+cosmic-linden@users.noreply.github.com> | 2024-05-02 10:31:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 10:31:52 -0700 |
commit | 37972cb76cd0459cd4105bbb09eb8f6cd1aa87f9 (patch) | |
tree | bfd85d36db258f46b74aa9989c1615d9bd7faf72 /indra/newview/lltinygltfhelper.cpp | |
parent | 7fc5f7e649c564fa8479a72a45459d0cc427d0f8 (diff) | |
parent | e8219cb0509d5aacc75cf862c6b8cad026590958 (diff) |
Merge pull request #1371 from secondlife/1357-gltf-asset-prototype
#1357 GLTF Export Prototype
Diffstat (limited to 'indra/newview/lltinygltfhelper.cpp')
-rw-r--r-- | indra/newview/lltinygltfhelper.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp index 49c35165e6..c8a9a36ad1 100644 --- a/indra/newview/lltinygltfhelper.cpp +++ b/indra/newview/lltinygltfhelper.cpp @@ -248,6 +248,43 @@ bool LLTinyGLTFHelper::loadModel(const std::string& filename, tinygltf::Model& m return false; } +bool LLTinyGLTFHelper::saveModel(const std::string& filename, tinygltf::Model& model_in) +{ + std::string exten = gDirUtilp->getExtension(filename); + + bool success = false; + + if (exten == "gltf" || exten == "glb") + { + tinygltf::TinyGLTF writer; + + std::string filename_lc = filename; + LLStringUtil::toLower(filename_lc); + + + bool embed_images = false; + bool embed_buffers = false; + bool pretty_print = true; + bool write_binary = false; + + + if (std::string::npos == filename_lc.rfind(".gltf")) + { // file is binary + embed_images = embed_buffers = write_binary = true; + } + + success = writer.WriteGltfSceneToFile(&model_in, filename, embed_images, embed_buffers, pretty_print, write_binary); + + if (!success) + { + LL_WARNS("GLTF") << "Failed to save" << LL_ENDL; + return false; + } + } + + return success; +} + bool LLTinyGLTFHelper::getMaterialFromModel( const std::string& filename, const tinygltf::Model& model_in, |