From 37527849b771552c9003dc488a5a97d76a196123 Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Sun, 3 Sep 2017 22:11:20 -0400 Subject: [PATCH] Export material names properly --- code/glTF2AssetWriter.inl | 4 ---- code/glTF2Importer.cpp | 8 +++++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index f7943172e..c10a6a08b 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -284,10 +284,6 @@ namespace glTF2 { inline void Write(Value& obj, Material& m, AssetWriter& w) { - if (!m.name.empty()) { - obj.AddMember("name", m.name, w.mAl); - } - Value pbrMetallicRoughness; pbrMetallicRoughness.SetObject(); { diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 86301a3f4..82ea5f3e7 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -125,7 +125,6 @@ bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool } - //static void CopyValue(const glTF2::vec3& v, aiColor3D& out) //{ // out.r = v[0]; out.g = v[1]; out.b = v[2]; @@ -228,8 +227,11 @@ void glTF2Importer::ImportMaterials(glTF2::Asset& r) Material& mat = r.materials[i]; - aiString str(mat.id); - aimat->AddProperty(&str, AI_MATKEY_NAME); + if (!mat.name.empty()) { + aiString str(mat.name); + + aimat->AddProperty(&str, AI_MATKEY_NAME); + } SetMaterialColorProperty(r, mat.pbrMetallicRoughness.baseColorFactor, aimat, AI_MATKEY_COLOR_DIFFUSE); SetMaterialTextureProperty(embeddedTexIdxs, r, mat.pbrMetallicRoughness.baseColorTexture, aimat, aiTextureType_DIFFUSE);