From e76e2f9671fddd9e22fb7f09855c286fdd04f9e7 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 14:53:14 +0900 Subject: [PATCH 1/6] use SerializerTypes.Generated --- Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs | 5 +---- .../VRM/UniGLTF/Scripts/Format/SerializerTypes.cs | 4 ++-- Assets/VRM/UniGLTF/Scripts/Format/glTF.cs | 13 +++++++------ Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs | 3 ++- .../VRM/UniVRM/Editor/Format/VRMEditorExporter.cs | 2 +- .../VRM/UniVRM/Editor/Format/VRMExportSettings.cs | 6 ------ 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs b/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs index 067cdb83f..1db2c13fa 100644 --- a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs +++ b/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs @@ -666,10 +666,7 @@ namespace UniGLTF // import new version { - var context = new ImporterContext - { - SerializerType = SerializerTypes.UniJSON - }; + var context = new ImporterContext(); context.ParseJson(json, new SimpleStorage(new ArraySegment(new byte[1024 * 1024]))); //Debug.LogFormat("{0}", context.Json); context.Load(); diff --git a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs b/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs index 9dc459c36..fcdee0804 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs +++ b/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs @@ -2,8 +2,8 @@ { public enum SerializerTypes { + Generated, // generated, No AOT Problem JsonSerializable, // manual, Obsolete - UniJSON, // reflection - Generated, // generated, experimental for mobile + UniJSON, // reflection, Obsolete } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs index f7de69655..b9be6d1b6 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs +++ b/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs @@ -427,10 +427,10 @@ namespace UniGLTF void Traverse(ListTreeNode node, JsonFormatter f, Utf8String parentKey) { - if(node.IsMap()) + if (node.IsMap()) { f.BeginMap(); - foreach(var kv in node.ObjectItems()) + foreach (var kv in node.ObjectItems()) { if (parentKey == s_extensions) { @@ -444,10 +444,10 @@ namespace UniGLTF } f.EndMap(); } - else if(node.IsArray()) + else if (node.IsArray()) { f.BeginList(); - foreach(var x in node.ArrayItems()) + foreach (var x in node.ArrayItems()) { Traverse(x, f, default(Utf8String)); } @@ -468,11 +468,12 @@ namespace UniGLTF return f.ToString(); } - public byte[] ToGlbBytes(SerializerTypes serializer = SerializerTypes.UniJSON) + public byte[] ToGlbBytes(SerializerTypes serializer = SerializerTypes.Generated) { string json; if (serializer == SerializerTypes.UniJSON) { + // Obsolete var c = new JsonSchemaValidationContext(this) { EnableDiagnosisForNotRequiredFields = true, @@ -485,7 +486,7 @@ namespace UniGLTF f.GenSerialize(this); json = f.ToString().ParseAsJson().ToString(" "); } - else if(serializer == SerializerTypes.JsonSerializable) + else if (serializer == SerializerTypes.JsonSerializable) { // Obsolete json = ToJson(); diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs b/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs index b1dcafbad..0da87dba6 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs @@ -271,7 +271,7 @@ namespace UniGLTF } } - private SerializerTypes _serializerType = SerializerTypes.UniJSON; + private SerializerTypes _serializerType = SerializerTypes.Generated; public SerializerTypes SerializerType { get { return _serializerType; } set { _serializerType = value; } } public virtual void ParseJson(string json, IStorage storage) @@ -281,6 +281,7 @@ namespace UniGLTF if (_serializerType == SerializerTypes.UniJSON) { + // Obsolete Json.ParseAsJson().Deserialize(ref GLTF); } else if (_serializerType == SerializerTypes.Generated) diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs index 0e5902c8a..d74dd2cc5 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs @@ -231,7 +231,7 @@ namespace VRM // vrm.extensions.VRM.meta.contactInformation = settings.ContactInformation; // vrm.extensions.VRM.meta.reference = settings.Reference; - var bytes = vrm.ToGlbBytes(settings.UseExperimentalExporter ? SerializerTypes.Generated : SerializerTypes.UniJSON); + var bytes = vrm.ToGlbBytes(); File.WriteAllBytes(path, bytes); Debug.LogFormat("Export elapsed {0}", sw.Elapsed); } diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs index 9c2dc96e5..154443c4a 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs @@ -18,12 +18,6 @@ namespace VRM [Tooltip("Require only first time")] public bool PoseFreeze = true; - /// - /// エクスポート時に新しいJsonSerializerを使う - /// - [Tooltip("Use new JSON serializer")] - public bool UseExperimentalExporter = false; - /// /// BlendShapeのシリアライズにSparseAccessorを使う /// From 361954aa9deafd09133f22c9f19be58d58ff034e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 15:19:31 +0900 Subject: [PATCH 2/6] fix warning Alpha cutoff is supported only for 'MASK' alpha mode. --- Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs | 2 +- Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs index 27a81c1bb..e1ea54345 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs +++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs @@ -80,7 +80,7 @@ namespace UniGLTF {"gltf/meshes[]/primitives[]/extras", "if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)"}, {"gltf/meshes[]/weights", "if(value.weights!=null && value.weights.Length>0)" }, {"gltf/materials", "if(value.materials!=null && value.materials.Count>0)" }, - {"gltf/materials[]/alphaCutoff", "if(!string.IsNullOrEmpty(value.alphaMode))" }, + {"gltf/materials[]/alphaCutoff", "if(value.alphaMode == \"MASK\")" }, {"gltf/nodes", "if(value.nodes!=null && value.nodes.Count>0)" }, {"gltf/nodes[]/camera", "if(value.camera!=-1)"}, {"gltf/nodes[]/mesh", "if(value.mesh!=-1)"}, diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs index 246f88b09..4a4065a66 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs @@ -572,7 +572,7 @@ namespace UniGLTF { f.Key("alphaMode"); f.GenSerialize(value.alphaMode); } - if(!string.IsNullOrEmpty(value.alphaMode)) + if(value.alphaMode == "MASK") { f.Key("alphaCutoff"); f.GenSerialize(value.alphaCutoff); } From 3bdc932f0d5704c357f3eb7185026feb96c73b7f Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 15:47:34 +0900 Subject: [PATCH 3/6] remove byteStride #461 --- .../Serialization/SerializerGenerator.cs | 23 ++++++++++++------- .../Scripts/IO/FormatterExtensionsGltf.g.cs | 5 ---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs index e1ea54345..a1d1c0130 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs +++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs @@ -44,13 +44,13 @@ namespace UniGLTF Stream m_s; StreamWriter m_w; - static Dictionary s_snipets = new Dictionary + static Dictionary s_snippets = new Dictionary { {"gltf/animations", "if(value.animations!=null && value.animations.Count>0)" }, {"gltf/cameras", "if(value.cameras!=null && value.cameras.Count>0)" }, {"gltf/buffers", "if(value.buffers!=null && value.buffers.Count>0)" }, {"gltf/bufferViews", "if(value.bufferViews!=null && value.bufferViews.Count>0)" }, - {"gltf/bufferViews[]/byteStride", "if(false)" }, + {"gltf/bufferViews[]/byteStride", "" }, {"gltf/bufferViews[]/target", "if(value.target!=0)" }, {"gltf/animations[]/channels", "if(value.channels!=null && value.channels.Count>0)" }, {"gltf/animations[]/channels[]/target", "if(value!=null)" }, @@ -276,7 +276,7 @@ namespace UniGLTF { { } - else if(fi.FieldType == typeof(glTF_KHR_materials_unlit)) + else if (fi.FieldType == typeof(glTF_KHR_materials_unlit)) { } @@ -287,20 +287,27 @@ namespace UniGLTF { var snipet = fi.FieldType.IsClass ? "if(value." + fi.Name + "!=null)" : ""; var value = default(string); - if (s_snipets.TryGetValue(path + "/" + fi.Name, out value)) + if (s_snippets.TryGetValue(path + "/" + fi.Name, out value)) { snipet = value; } - m_w.Write(@" + if (value == "") + { + // found, but empty + } + else + { + m_w.Write(@" $1 { f.Key(""$0""); f.GenSerialize(value.$0); } " -.Replace("$0", fi.Name) -.Replace("$1", snipet) -); + .Replace("$0", fi.Name) + .Replace("$1", snipet) + ); + } } m_w.Write(@" diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs index 4a4065a66..11bdaf98d 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs @@ -212,11 +212,6 @@ namespace UniGLTF { f.Key("byteLength"); f.GenSerialize(value.byteLength); } - if(false) - { - f.Key("byteStride"); f.GenSerialize(value.byteStride); - } - if(value.target!=0) { f.Key("target"); f.GenSerialize(value.target); From eb7d39b376ead5f4a17b0c2e7142fb8b79e558bb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 15:49:13 +0900 Subject: [PATCH 4/6] regenerate GltfDeserializer --- .../UniGLTF/Scripts/IO/GltfDeserializer.g.cs | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs index 585905f0f..a2bf59bb8 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs @@ -655,10 +655,86 @@ public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMe continue; } + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(kv.Value); + continue; + } + } return value; } +public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(ListTreeNode parsed) +{ + var value = new glTFTextureInfo_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_texture_transform"){ + value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(ListTreeNode parsed) +{ + var value = new glTF_KHR_texture_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_offset(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = kv.Value.GetSingle(); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_scale(kv.Value); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(ListTreeNode parsed) { var value = new Single[parsed.GetArrayCount()]; @@ -688,10 +764,86 @@ public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_material continue; } + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(kv.Value); + continue; + } + } return value; } +public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(ListTreeNode parsed) +{ + var value = new glTFTextureInfo_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_texture_transform"){ + value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(ListTreeNode parsed) +{ + var value = new glTF_KHR_texture_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_offset(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = kv.Value.GetSingle(); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_scale(kv.Value); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(ListTreeNode parsed) { var value = new glTFMaterialNormalTextureInfo(); @@ -715,10 +867,86 @@ public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTe continue; } + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__normalTexture_extensions(kv.Value); + continue; + } + } return value; } +public static glTFTextureInfo_extensions Deserialize_gltf_materials__normalTexture_extensions(ListTreeNode parsed) +{ + var value = new glTFTextureInfo_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_texture_transform"){ + value.KHR_texture_transform = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_texture_transform Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(ListTreeNode parsed) +{ + var value = new glTF_KHR_texture_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_offset(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = kv.Value.GetSingle(); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_scale(kv.Value); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(ListTreeNode parsed) { var value = new glTFMaterialOcclusionTextureInfo(); @@ -742,10 +970,86 @@ public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlu continue; } + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__occlusionTexture_extensions(kv.Value); + continue; + } + } return value; } +public static glTFTextureInfo_extensions Deserialize_gltf_materials__occlusionTexture_extensions(ListTreeNode parsed) +{ + var value = new glTFTextureInfo_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_texture_transform"){ + value.KHR_texture_transform = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_texture_transform Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(ListTreeNode parsed) +{ + var value = new glTF_KHR_texture_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_offset(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = kv.Value.GetSingle(); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_scale(kv.Value); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(ListTreeNode parsed) { var value = new glTFMaterialEmissiveTextureInfo(); @@ -764,10 +1068,86 @@ public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissi continue; } + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__emissiveTexture_extensions(kv.Value); + continue; + } + } return value; } +public static glTFTextureInfo_extensions Deserialize_gltf_materials__emissiveTexture_extensions(ListTreeNode parsed) +{ + var value = new glTFTextureInfo_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_texture_transform"){ + value.KHR_texture_transform = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_texture_transform Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(ListTreeNode parsed) +{ + var value = new glTF_KHR_texture_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_offset(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = kv.Value.GetSingle(); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_scale(kv.Value); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode parsed) { var value = new Single[parsed.GetArrayCount()]; @@ -840,6 +1220,11 @@ public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode pars continue; } + if(key=="extras"){ + value.extras = Deserialize_gltf_meshes__extras(kv.Value); + continue; + } + } return value; } @@ -1032,6 +1417,32 @@ public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode return value; } +public static glTFMesh_extras Deserialize_gltf_meshes__extras(ListTreeNode parsed) +{ + var value = new glTFMesh_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="targetNames"){ + value.targetNames = Deserialize_gltf_meshes__extras_targetNames(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__extras_targetNames(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} public static List Deserialize_gltf_nodes(ListTreeNode parsed) { var value = new List(); From c3e8e2f391ad1c38a8aeca525a9c8bd45eb93ad3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 15:52:22 +0900 Subject: [PATCH 5/6] remove m_useExcperimentalExporter --- Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs index 5b05edae9..11db19e15 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs @@ -86,7 +86,6 @@ namespace VRM CheckBoxProp m_forceTPose; CheckBoxProp m_poseFreeze; - CheckBoxProp m_useExcperimentalExporter; CheckBoxProp m_useSparseAccessor; CheckBoxProp m_onlyBlendShapePosition; CheckBoxProp m_reduceBlendShape; @@ -137,7 +136,6 @@ namespace VRM { m_forceTPose = new CheckBoxProp(serializedObject.FindProperty(nameof(ForceTPose)), Options.FORCE_T_POSE); m_poseFreeze = new CheckBoxProp(serializedObject.FindProperty(nameof(PoseFreeze)), Options.NORMALIZE); - m_useExcperimentalExporter = new CheckBoxProp(serializedObject.FindProperty(nameof(UseExperimentalExporter)), Options.USE_GENERATED_SERIALIZER); m_useSparseAccessor = new CheckBoxProp(serializedObject.FindProperty(nameof(UseSparseAccessor)), Options.BLENDSHAPE_USE_SPARSE); m_onlyBlendShapePosition = new CheckBoxProp(serializedObject.FindProperty(nameof(OnlyBlendshapePosition)), Options.BLENDSHAPE_EXCLUDE_NORMAL_AND_TANGENT); m_reduceBlendShape = new CheckBoxProp(serializedObject.FindProperty(nameof(ReduceBlendshape)), Options.BLENDSHAPE_ONLY_CLIP_USE); @@ -151,7 +149,6 @@ namespace VRM serializedObject.Update(); m_forceTPose.Draw(); m_poseFreeze.Draw(); - m_useExcperimentalExporter.Draw(); m_useSparseAccessor.Draw(); m_onlyBlendShapePosition.Draw(); m_reduceBlendShape.Draw(); From 09af53a3f976e56dbcd5001dcc41b097caedc48b Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Sep 2020 17:27:07 +0900 Subject: [PATCH 6/6] fix sparse export --- .../VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs | 3 +++ Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs index a1d1c0130..783afcec8 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs +++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs @@ -59,6 +59,9 @@ namespace UniGLTF {"gltf/accessors[]/max", "if(value.max!=null && value.max.Length>0)"}, {"gltf/accessors[]/min", "if(value.min!=null && value.min.Length>0)"}, {"gltf/accessors[]/sparse", "if(value.sparse!=null && value.sparse.count>0)"}, + {"gltf/accessors[]/bufferView", "if(value.bufferView>=0)"}, + {"gltf/accessors[]/byteOffset", "if(value.bufferView>=0)"}, + {"gltf/images", "if(value.images!=null && value.images.Count>0)" }, {"gltf/meshes", "if(value.meshes!=null && value.meshes.Count>0)" }, diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs index 11bdaf98d..7bd0d6a47 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs @@ -246,12 +246,12 @@ namespace UniGLTF { { f.BeginMap(0); // dummy - + if(value.bufferView>=0) { f.Key("bufferView"); f.GenSerialize(value.bufferView); } - + if(value.bufferView>=0) { f.Key("byteOffset"); f.GenSerialize(value.byteOffset); }