summaryrefslogtreecommitdiff
path: root/indra/newview/gltfscenemanager.cpp
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2024-04-30 21:57:42 -0500
committerRunitaiLinden <davep@lindenlab.com>2024-04-30 21:57:42 -0500
commit170765fd3505410dced83b342f87030fd9151e35 (patch)
treef3665586f2d731a04bf645bc1155bbddc6c5f7e8 /indra/newview/gltfscenemanager.cpp
parent5e2bac01cb6e8d3de3cc0e496d94a729e4740247 (diff)
#1357 Proof of concept on decomposing a GLTF scene into its component parts
Diffstat (limited to 'indra/newview/gltfscenemanager.cpp')
-rw-r--r--indra/newview/gltfscenemanager.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp
index f9f1240469..0aedcd653d 100644
--- a/indra/newview/gltfscenemanager.cpp
+++ b/indra/newview/gltfscenemanager.cpp
@@ -100,6 +100,51 @@ void GLTFSceneManager::saveAs()
}
}
+void GLTFSceneManager::decomposeSelection()
+{
+ LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
+ if (obj && obj->mGLTFAsset.notNull())
+ {
+ LLFilePickerReplyThread::startPicker(
+ [](const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter)
+ {
+ if (LLAppViewer::instance()->quitRequested())
+ {
+ return;
+ }
+ if (filenames.size() > 0)
+ {
+ GLTFSceneManager::instance().decomposeSelection(filenames[0]);
+ }
+ },
+ LLFilePicker::FFSAVE_GLTF,
+ "scene.gltf");
+ }
+ else
+ {
+ LLNotificationsUtil::add("GLTFSaveSelection");
+ }
+}
+
+void GLTFSceneManager::decomposeSelection(const std::string& filename)
+{
+ LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
+ if (obj && obj->mGLTFAsset.notNull())
+ {
+ // copy asset out for decomposition
+ Asset asset = *obj->mGLTFAsset;
+
+ // decompose the asset into component parts
+ asset.decompose(filename);
+
+ // copy decomposed asset into tinygltf for serialization
+ tinygltf::Model model;
+ asset.save(model);
+
+ LLTinyGLTFHelper::saveModel(filename, model);
+ }
+}
+
void GLTFSceneManager::save(const std::string& filename)
{
LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();