From 1668af80b139eb40a13b2e18ed2a6d7b14ddd262 Mon Sep 17 00:00:00 2001 From: Cinders Date: Sun, 1 Dec 2013 12:35:35 -0700 Subject: [PATCH] Initial materials support for the object exporter. --- indra/newview/fsfloaterexport.cpp | 15 +++++++++++++++ indra/newview/fsfloaterimport.cpp | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/indra/newview/fsfloaterexport.cpp b/indra/newview/fsfloaterexport.cpp index 01be2d1f74..a9e9527a48 100644 --- a/indra/newview/fsfloaterexport.cpp +++ b/indra/newview/fsfloaterexport.cpp @@ -503,6 +503,21 @@ void FSFloaterObjectExport::addPrim(LLViewerObject* object, bool root) checkTE->setID(LL_DEFAULT_WOOD_UUID); // TODO: use user option of default texture. prim["texture"].append(checkTE->asLLSD()); } + + // [FS:CR] Materials support + if (checkTE->getMaterialParams().notNull()) + { + LL_DEBUGS("export") << "found materials. Checking permissions..." << LL_ENDL; + LLSD params = checkTE->getMaterialParams().get()->asLLSD(); + /// *TODO: Feeling lazy so I made it check both. This is incorrect and needs to be expanded + /// to retain exportable textures not just failing both when one is non-exportable (or unset). + if (exportTexture(params["NormMap"].asUUID()) && + exportTexture(params["SpecMap"].asUUID())) + { + LL_DEBUGS("export") << "...passed check." << LL_ENDL; + prim["materials"].append(params); + } + } } if (!object->getPhysicsShapeUnknown()) diff --git a/indra/newview/fsfloaterimport.cpp b/indra/newview/fsfloaterimport.cpp index 29050a99b8..969373284e 100644 --- a/indra/newview/fsfloaterimport.cpp +++ b/indra/newview/fsfloaterimport.cpp @@ -44,6 +44,7 @@ #include "llinventorydefines.h" #include "llinventoryfunctions.h" #include "lllineeditor.h" +#include "llmaterialmgr.h" #include "llmultigesture.h" #include "llnotificationsutil.h" #include "llparcel.h" @@ -771,6 +772,23 @@ bool FSFloaterImport::processPrimCreated(LLViewerObject* object) } } object->sendTEUpdate(); + + // [FS:CR] Materials + if(prim.has("materials")) + { + U8 te = 0; + LLSD materials = prim["materials"]; + for (LLSD::array_iterator m_itr = materials.beginArray() ; + m_itr != materials.endArray() ; + ++m_itr) + { + LL_DEBUGS("import") << "Setting materials" << LL_ENDL; + LLMaterial* mat = new LLMaterial(); + mat->fromLLSD(*m_itr); + object->setTEMaterialParams(te, mat); + ++te; + } + } if (prim.has("sculpt")) {