summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llgltfmateriallist.cpp13
-rw-r--r--indra/newview/lllocalgltfmaterials.cpp2
-rw-r--r--indra/newview/lltinygltfhelper.cpp65
-rw-r--r--indra/newview/lltinygltfhelper.h1
4 files changed, 3 insertions, 78 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 5cbf853179..a5d2be2d4e 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -83,18 +83,9 @@ LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
{
std::string data = asset["data"];
- tinygltf::TinyGLTF gltf;
- tinygltf::TinyGLTF loader;
- std::string error_msg;
- std::string warn_msg;
+ std::string warn_msg, error_msg;
- tinygltf::Model model_in;
-
- if (loader.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, data.c_str(), data.length(), ""))
- {
- LLTinyGLTFHelper::setFromModel(mat, model_in, 0);
- }
- else
+ if (!mat->fromJSON(data, warn_msg, error_msg))
{
LL_WARNS() << "Failed to decode material asset: " << LL_ENDL;
LL_WARNS() << warn_msg << LL_ENDL;
diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp
index 1f16549a47..fe2b7ac816 100644
--- a/indra/newview/lllocalgltfmaterials.cpp
+++ b/indra/newview/lllocalgltfmaterials.cpp
@@ -270,7 +270,7 @@ bool LLLocalGLTFMaterial::loadMaterial(LLPointer<LLGLTFMaterial> mat, S32 index)
}
// sets everything, but textures will have inaccurate ids
- LLTinyGLTFHelper::setFromModel(mat, model_in, index);
+ mat->setFromModel(model_in, index);
std::string folder = gDirUtilp->getDirName(filename_lc);
tinygltf::Material material_in = model_in.materials[index];
diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp
index c3dc10c2a0..c80e87652a 100644
--- a/indra/newview/lltinygltfhelper.cpp
+++ b/indra/newview/lltinygltfhelper.cpp
@@ -122,71 +122,6 @@ void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material,
}
}
-void LLTinyGLTFHelper::setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model, S32 mat_index)
-{
- if (model.materials.size() <= mat_index)
- {
- return;
- }
-
- tinygltf::Material& material_in = model.materials[mat_index];
-
- // get base color texture
- S32 tex_index = material_in.pbrMetallicRoughness.baseColorTexture.index;
- if (tex_index >= 0)
- {
- mat->mBaseColorId.set(model.images[tex_index].uri);
- }
- else
- {
- mat->mBaseColorId.setNull();
- }
-
- // get normal map
- tex_index = material_in.normalTexture.index;
- if (tex_index >= 0)
- {
- mat->mNormalId.set(model.images[tex_index].uri);
- }
- else
- {
- mat->mNormalId.setNull();
- }
-
- // get metallic-roughness texture
- tex_index = material_in.pbrMetallicRoughness.metallicRoughnessTexture.index;
- if (tex_index >= 0)
- {
- mat->mMetallicRoughnessId.set(model.images[tex_index].uri);
- }
- else
- {
- mat->mMetallicRoughnessId.setNull();
- }
-
- // get emissive texture
- tex_index = material_in.emissiveTexture.index;
- if (tex_index >= 0)
- {
- mat->mEmissiveId.set(model.images[tex_index].uri);
- }
- else
- {
- mat->mEmissiveId.setNull();
- }
-
- mat->setAlphaMode(material_in.alphaMode);
- mat->mAlphaCutoff = llclamp((F32)material_in.alphaCutoff, 0.f, 1.f);
-
- mat->mBaseColor= getColor(material_in.pbrMetallicRoughness.baseColorFactor);
- mat->mEmissiveColor = getColor(material_in.emissiveFactor);
-
- mat->mMetallicFactor = llclamp((F32)material_in.pbrMetallicRoughness.metallicFactor, 0.f, 1.f);
- mat->mRoughnessFactor = llclamp((F32)material_in.pbrMetallicRoughness.roughnessFactor, 0.f, 1.f);
-
- mat->mDoubleSided = material_in.doubleSided;
-}
-
LLColor4 LLTinyGLTFHelper::getColor(const std::vector<double>& in)
{
LLColor4 out;
diff --git a/indra/newview/lltinygltfhelper.h b/indra/newview/lltinygltfhelper.h
index afe4517417..9c2e5afc17 100644
--- a/indra/newview/lltinygltfhelper.h
+++ b/indra/newview/lltinygltfhelper.h
@@ -35,7 +35,6 @@ class LLViewerFetchedTexture;
namespace LLTinyGLTFHelper
{
- void setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model, S32 index);
LLColor4 getColor(const std::vector<double>& in);
const tinygltf::Image* getImageFromTextureIndex(const tinygltf::Model& model, S32 texture_index);
LLImageRaw* getTexture(const std::string& folder, const tinygltf::Model& model, S32 texture_index, std::string& name);