Export material names properly
authorDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Mon, 4 Sep 2017 02:11:20 +0000 (22:11 -0400)
committerDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Mon, 11 Sep 2017 15:02:13 +0000 (11:02 -0400)
code/glTF2AssetWriter.inl
code/glTF2Importer.cpp

index f794317..c10a6a0 100644 (file)
@@ -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();
         {
index 86301a3..82ea5f3 100644 (file)
@@ -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);