summaryrefslogtreecommitdiff
path: root/indra/newview/llmaterialeditor.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-06-23 16:21:53 -0500
committerDave Parks <davep@lindenlab.com>2022-06-23 16:21:53 -0500
commit394479d7cc48a0170854e07f14267e28ba247990 (patch)
tree4e68623cf90138e851e082619d52b04c26949ea0 /indra/newview/llmaterialeditor.cpp
parent54edd8ba8b824241f3d6df9e3ffff7a7c926665d (diff)
SL-17653 WIP - Apply GLTF material in Material Editor to selected object when you click "Save"
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
-rw-r--r--indra/newview/llmaterialeditor.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 05e7ff524a..5a0c23d59b 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -31,6 +31,8 @@
#include "llviewermenufile.h"
#include "llappviewer.h"
#include "llviewertexture.h"
+#include "llselectmgr.h"
+#include "llvovolume.h"
#include "tinygltf/tiny_gltf.h"
@@ -195,6 +197,8 @@ static U32 write_texture(const LLUUID& id, tinygltf::Model& model)
void LLMaterialEditor::onClickSave()
{
+ applyToSelection();
+
tinygltf::Model model;
model.materials.resize(1);
tinygltf::PbrMetallicRoughness& pbrMaterial = model.materials[0].pbrMetallicRoughness;
@@ -450,4 +454,35 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename)
void LLMaterialEditor::importMaterial()
{
(new LLMaterialFilePicker(this))->getFile();
-} \ No newline at end of file
+}
+
+void LLMaterialEditor::applyToSelection()
+{
+ LLViewerObject* objectp = LLSelectMgr::instance().getSelection()->getFirstObject();
+ if (objectp && objectp->getVolume())
+ {
+ LLGLTFMaterial* mat = new LLGLTFMaterial();
+ mat->mAlbedoColor = getAlbedoColor();
+ mat->mAlbedoColor.mV[3] = getTransparency();
+ mat->mAlbedoId = getAlbedoId();
+
+ mat->mNormalId = getNormalId();
+
+ mat->mMetallicRoughnessId = getMetallicRoughnessId();
+ mat->mMetallicFactor = getMetalnessFactor();
+ mat->mRoughnessFactor = getRoughnessFactor();
+
+ mat->mEmissiveColor = getEmissiveColor();
+ mat->mEmissiveId = getEmissiveId();
+
+ mat->mDoubleSided = getDoubleSided();
+ mat->setAlphaMode(getAlphaMode());
+
+ LLVOVolume* vobjp = (LLVOVolume*)objectp;
+ for (int i = 0; i < vobjp->getNumTEs(); ++i)
+ {
+ vobjp->getTE(i)->setGLTFMaterial(mat);
+ vobjp->updateTEMaterialTextures(i);
+ }
+ }
+}