From fa03db60d628756868874512a674f774b3c3ed84 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 19 Jul 2018 19:07:14 +0900 Subject: [PATCH] Updated UniGLTF --- Scripts/Format/VRMExporter.cs | 2 +- Scripts/Format/VRMFormat.cs | 6 +++--- Scripts/Format/VRMImporter.cs | 4 ++-- Scripts/Format/glTF_VRM_BlendShape.cs | 8 ++++---- Scripts/Format/glTF_VRM_FirstPerson.cs | 6 +++--- Scripts/Format/glTF_VRM_Humanoid.cs | 4 ++-- Scripts/Format/glTF_VRM_Material.cs | 11 ++++++----- Scripts/Format/glTF_VRM_Meta.cs | 2 +- Scripts/Format/glTF_VRM_SecondaryAnimation.cs | 8 ++++---- UniGLTF | 2 +- 10 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Scripts/Format/VRMExporter.cs b/Scripts/Format/VRMExporter.cs index 23984bace..b393d1ac8 100644 --- a/Scripts/Format/VRMExporter.cs +++ b/Scripts/Format/VRMExporter.cs @@ -15,7 +15,6 @@ namespace VRM public static glTF_VRM Export(GameObject go) { var gltf = new glTF_VRM(); - gltf.asset.generator = string.Format("UniVRM-{0}.{1}", VRMVersion.MAJOR, VRMVersion.MINOR); using (var exporter = new VRMExporter(gltf) { #if VRM_EXPORTER_USE_SPARSE @@ -27,6 +26,7 @@ namespace VRM _Export(gltf, exporter, go); } + gltf.asset.generator = string.Format("UniVRM-{0}.{1}", VRMVersion.MAJOR, VRMVersion.MINOR); return gltf; } diff --git a/Scripts/Format/VRMFormat.cs b/Scripts/Format/VRMFormat.cs index 8121179d5..01df5792c 100644 --- a/Scripts/Format/VRMFormat.cs +++ b/Scripts/Format/VRMFormat.cs @@ -17,7 +17,7 @@ namespace VRM public glTF_VRM_SecondaryAnimation secondaryAnimation = new glTF_VRM_SecondaryAnimation(); public List materialProperties = new List(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => exporterVersion); f.KeyValue(() => meta); @@ -34,7 +34,7 @@ namespace VRM { public glTF_VRM_extensions VRM = new glTF_VRM_extensions(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => VRM); } @@ -49,7 +49,7 @@ namespace VRM "VRM", }; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => extensionsUsed); f.KeyValue(() => extensions); diff --git a/Scripts/Format/VRMImporter.cs b/Scripts/Format/VRMImporter.cs index e40c70041..f7dfcafe5 100644 --- a/Scripts/Format/VRMImporter.cs +++ b/Scripts/Format/VRMImporter.cs @@ -337,14 +337,14 @@ namespace VRM [Obsolete] private static void LoadHumanoidObsolete(VRMImporterContext context) { - var parsed = context.Json.ParseAsJson()["extensions"]["VRM"]; + var parsed = UniJSON.JsonParser.Parse(context.Json)["extensions"]["VRM"]; var skeleton = context.Root.transform.Traverse().Select(x => ToSkeletonBone(x)).ToArray(); var description = new HumanDescription { human = parsed[HUMANOID_KEY]["bones"] .ObjectItems - .Select(x => new { x.Key, Index = x.Value.GetInt32() }) + .Select(x => new { x.Key, Index = x.Value.Value.GetInt32() }) .Where(x => x.Index != -1) .Select(x => { diff --git a/Scripts/Format/glTF_VRM_BlendShape.cs b/Scripts/Format/glTF_VRM_BlendShape.cs index 2ace99d70..1026b4485 100644 --- a/Scripts/Format/glTF_VRM_BlendShape.cs +++ b/Scripts/Format/glTF_VRM_BlendShape.cs @@ -14,7 +14,7 @@ namespace VRM public string propertyName; public float[] targetValue; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => materialName); f.KeyValue(() => propertyName); @@ -29,7 +29,7 @@ namespace VRM public int index = -1; public float weight = 0; - protected override void SerializeMembers(UniGLTF.JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => mesh); f.KeyValue(() => index); @@ -90,7 +90,7 @@ namespace VRM public List binds = new List(); public List materialValues = new List(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => name); f.KeyValue(() => presetName); @@ -133,7 +133,7 @@ namespace VRM blendShapeGroups.Add(group); } - protected override void SerializeMembers(UniGLTF.JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => blendShapeGroups); } diff --git a/Scripts/Format/glTF_VRM_FirstPerson.cs b/Scripts/Format/glTF_VRM_FirstPerson.cs index 6ce2e017d..9e7be4cf2 100644 --- a/Scripts/Format/glTF_VRM_FirstPerson.cs +++ b/Scripts/Format/glTF_VRM_FirstPerson.cs @@ -15,7 +15,7 @@ namespace VRM public float xRange = 90.0f; public float yRange = 10.0f; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { if (curve != null) { @@ -48,7 +48,7 @@ namespace VRM public string firstPersonFlag; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => mesh); f.KeyValue(() => firstPersonFlag); @@ -85,7 +85,7 @@ namespace VRM public glTF_VRM_DegreeMap lookAtVerticalDown = new glTF_VRM_DegreeMap(); public glTF_VRM_DegreeMap lookAtVerticalUp = new glTF_VRM_DegreeMap(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => firstPersonBone); f.KeyValue(() => firstPersonBoneOffset); diff --git a/Scripts/Format/glTF_VRM_Humanoid.cs b/Scripts/Format/glTF_VRM_Humanoid.cs index d0426934c..50a1b3853 100644 --- a/Scripts/Format/glTF_VRM_Humanoid.cs +++ b/Scripts/Format/glTF_VRM_Humanoid.cs @@ -111,7 +111,7 @@ namespace VRM public Vector3 center; public float axisLength; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.Key("bone"); f.Value((string)bone.ToString()); f.KeyValue(() => node); @@ -158,7 +158,7 @@ namespace VRM } } - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => humanBones); f.KeyValue(() => armStretch); diff --git a/Scripts/Format/glTF_VRM_Material.cs b/Scripts/Format/glTF_VRM_Material.cs index 7e85cbdfc..3964695af 100644 --- a/Scripts/Format/glTF_VRM_Material.cs +++ b/Scripts/Format/glTF_VRM_Material.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using UniGLTF; using UnityEngine; +using UniJSON; #if UNITY_EDITOR using UnityEditor; #endif @@ -28,7 +29,7 @@ namespace VRM // "Queue", }; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => name); f.KeyValue(() => renderQueue); @@ -77,17 +78,17 @@ namespace VRM public static List Parse(string src) { - var json = src.ParseAsJson()["extensions"]["VRM"]["materialProperties"]; + var json = UniJSON.JsonParser.Parse(src)["extensions"]["VRM"]["materialProperties"]; var materials = json.DeserializeList(); - var jsonItems = json.ListItems.ToArray(); + var jsonItems = json.ArrayItems.ToArray(); for(int i=0; i x.Key, x => x.Value.GetSingle()); + jsonItems[i]["floatProperties"].ObjectItems.ToDictionary(x => x.Key, x => x.Value.Value.GetSingle()); materials[i].vectorProperties = jsonItems[i]["vectorProperties"].ObjectItems.ToDictionary(x => x.Key, x => { - return x.Value.ListItems.Select(y => y.GetSingle()).ToArray(); + return x.Value.ArrayItems.Select(y => y.Value.GetSingle()).ToArray(); }); materials[i].keywordMap = jsonItems[i]["keywordMap"].ObjectItems.ToDictionary(x => x.Key, x => x.Value.GetBoolean()); diff --git a/Scripts/Format/glTF_VRM_Meta.cs b/Scripts/Format/glTF_VRM_Meta.cs index 00fc79eb4..0907ab23a 100644 --- a/Scripts/Format/glTF_VRM_Meta.cs +++ b/Scripts/Format/glTF_VRM_Meta.cs @@ -98,7 +98,7 @@ namespace VRM public string otherLicenseUrl; #endregion - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => version); diff --git a/Scripts/Format/glTF_VRM_SecondaryAnimation.cs b/Scripts/Format/glTF_VRM_SecondaryAnimation.cs index 7e8117b84..7a35b4f31 100644 --- a/Scripts/Format/glTF_VRM_SecondaryAnimation.cs +++ b/Scripts/Format/glTF_VRM_SecondaryAnimation.cs @@ -12,7 +12,7 @@ namespace VRM public Vector3 offset; public float radius; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => offset); f.KeyValue(() => radius); @@ -25,7 +25,7 @@ namespace VRM public int node; public List colliders = new List(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => node); f.KeyValue(() => colliders); @@ -46,7 +46,7 @@ namespace VRM public int[] bones = new int[] { }; public int[] colliderGroups = new int[] { }; - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => comment); f.KeyValue(() => stiffiness); @@ -66,7 +66,7 @@ namespace VRM public List boneGroups = new List(); public List colliderGroups = new List(); - protected override void SerializeMembers(JsonFormatter f) + protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => boneGroups); f.KeyValue(() => colliderGroups); diff --git a/UniGLTF b/UniGLTF index 820d2658e..bd0899dd3 160000 --- a/UniGLTF +++ b/UniGLTF @@ -1 +1 @@ -Subproject commit 820d2658e149156b226f4137a0c94bfc93e3f305 +Subproject commit bd0899dd3e13e1fb06303a7d110cf682632bbc76