diff --git a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs index 3a42d7a608..c9c721cfef 100644 --- a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs +++ b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs @@ -84,10 +84,12 @@ public void ImportExportTest() var vrm = VRMExporter.Export(context.Root); // TODO: Check contents in JSON - /*var exportJson = */JsonParser.Parse(vrm.ToJson()); + /*var exportJson = */ + JsonParser.Parse(vrm.ToJson()); // TODO: Check contents in JSON - /*var newExportedJson = */JsonParser.Parse(JsonSchema.FromType().Serialize(vrm)); + /*var newExportedJson = */ + JsonParser.Parse(JsonSchema.FromType().Serialize(vrm)); /* foreach (var kv in importJson.Diff(exportJson)) @@ -117,5 +119,35 @@ public void MeshCopyTest() MeshTests.MeshEquals(src, dst); } } + + [Test] + public void SerializerCompare() + { + // Aliciaを古いデシリアライザでロードする + var path = AliciaPath; + var context = new VRMImporterContext(); + context.ParseGlb(File.ReadAllBytes(path)); + var oldJson = context.GLTF.ToJson().ParseAsJson().ToString(" "); + + // 生成シリアライザでJSON化する + var f = new JsonFormatter(); + f.GenSerialize(context.GLTF); + var parsed = f.ToString().ParseAsJson(); + var newJson = parsed.ToString(" "); + + File.WriteAllText("old.json", oldJson); + File.WriteAllText("new.json", newJson); + + // 比較 + Assert.AreEqual(oldJson, newJson); + + // 生成デシリアライザでロードする + var ff = new JsonFormatter(); + var des = GltfDeserializer.Deserialize(parsed); + ff.Clear(); + ff.GenSerialize(des); + var desJson = ff.ToString().ParseAsJson().ToString(" "); + Assert.AreEqual(oldJson, desJson); + } } } diff --git a/Assets/VRM/UniGLTF/Editor/Serialization.meta b/Assets/VRM/UniGLTF/Editor/Serialization.meta new file mode 100644 index 0000000000..0101c4e431 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 43be0cf78be61614cb840cb906de4275 +folderAsset: yes +timeCreated: 1565252168 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs new file mode 100644 index 0000000000..0dbcf723a8 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs @@ -0,0 +1,115 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class ArraySerialization : FunctionSerializationBase + { + IValueSerialization m_inner; + + public ArraySerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ARRAY"; + + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new $1[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = $3; + } + return value; +} +" +.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + } + + public class ListSerialization : FunctionSerializationBase + { + IValueSerialization m_inner; + + public ListSerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_LIST"; + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new List<$1>(); + foreach(var x in parsed.ArrayItems()) + { + value.Add($3); + } + return value; +}" +.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + } + + public class StringKeyDictionarySerialization : FunctionSerializationBase + { + IValueSerialization m_inner; + + public StringKeyDictionarySerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_DICT"; + writer.Write(@" + +public static $0 $2(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), $3); + } + return value; +} +" +.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "kv.Value")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs.meta new file mode 100644 index 0000000000..bf9f1d2a2e --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e85f0c5204f5ac3429503462ef29cdae +timeCreated: 1565259169 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs new file mode 100644 index 0000000000..c6bb8bbaea --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs @@ -0,0 +1,61 @@ +using System.IO; +using System.Reflection; +using System.Text; +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + public static class DeserializerGenerator + { + public const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; + + static string OutPath + { + get + { + return Path.Combine(UnityEngine.Application.dataPath, + "VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs"); + } + } + + /// + /// AOT向けにデシリアライザを生成する + /// + [MenuItem(VRM.VRMVersion.MENU + "/Generate Deserializer")] + static void GenerateSerializer() + { + var info = new ObjectSerialization(typeof(glTF), "gltf"); + Debug.Log(info); + + using (var s = File.Open(OutPath, FileMode.Create)) + using (var w = new StreamWriter(s, Encoding.UTF8)) + { + // header + w.Write(@" +using UniJSON; +using System; +using System.Collections.Generic; +using VRM; +using UnityEngine; + +namespace UniGLTF { + +public static class GltfDeserializer +{ + +"); + + info.GenerateDeserializer(w, "Deserialize"); + + // footer + w.Write(@" +} // GltfDeserializer +} // UniGLTF +"); + + Debug.LogFormat("write: {0}", OutPath); + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs.meta new file mode 100644 index 0000000000..0adf14659b --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c2f242dff8534b1409257c4e7fe8a21d +timeCreated: 1564983410 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs b/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs new file mode 100644 index 0000000000..3ca000776f --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using UniJSON; + +namespace UniGLTF +{ + public class FieldSerializationInfo + { + FieldInfo m_fi; + public FieldInfo FieldInfo + { + get { return m_fi; } + } + + public string Name + { + get { return FieldInfo.Name; } + } + + public string Path + { + get; + private set; + } + + public string FunctionName + { + get + { + return "Deserialize_" + Path + .Replace("/", "_") + .Replace("[]", "_") + ; + } + } + + JsonSchemaAttribute m_attr; + + public IValueSerialization Serialization + { + get; + private set; + } + + public FieldSerializationInfo(FieldInfo fi, string path) + { + m_fi = fi; + Path = path + "/" + fi.Name; + m_attr = fi.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(JsonSchemaAttribute)) as JsonSchemaAttribute; + + Serialization = GetSerialization(m_fi.FieldType, Path); + } + + static IValueSerialization GetSerialization(Type t, string path) + { + if (t.IsArray) + { + return new ArraySerialization(t, + GetSerialization(t.GetElementType(), path + "[]")); + } + else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>)) + { + return new ListSerialization(t, + GetSerialization(t.GetGenericArguments()[0], path + "[]")); + } + else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>) + && t.GetGenericArguments()[0] == typeof(string)) + { + return new StringKeyDictionarySerialization(t, + GetSerialization(t.GetGenericArguments()[1], path)); + } + + // GetCollectionType(fi.FieldType, out suffix, out t); + if (t == typeof(sbyte)) + { + return new Int8Serialization(); + } + else if (t == typeof(short)) + { + return new Int16Serialization(); + } + else if (t == typeof(int)) + { + return new Int32Serialization(); + } + else if (t == typeof(long)) + { + return new Int64Serialization(); + } + else if (t == typeof(byte)) + { + return new UInt8Serialization(); + } + else if (t == typeof(ushort)) + { + return new UInt16Serialization(); + } + else if (t == typeof(uint)) + { + return new UInt32Serialization(); + } + else if (t == typeof(ulong)) + { + return new UInt64Serialization(); + } + else if (t == typeof(float)) + { + return new SingleSerialization(); + } + else if (t == typeof(double)) + { + return new DoubleSerialization(); + } + else if (t == typeof(string)) + { + return new StringSerialization(); + } + else if (t == typeof(bool)) + { + return new BooleanSerialization(); + } + else if (t.IsEnum) + { + return new EnumIntSerialization(t); + } + + return new ObjectSerialization(t, path); + } + + public override string ToString() + { + var sb = new StringBuilder(); + + var typeName = BaseJsonSchemaAttribute.GetTypeName(m_fi.FieldType); + + if (m_attr != null) + { + sb.AppendLine(string.Format("{0}: {1}", Path, m_attr.GetInfo(m_fi))); + } + else + { + sb.AppendLine(string.Format("{0}: {1}", Path, typeName)); + } + + sb.Append(Serialization.ToString()); + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs.meta new file mode 100644 index 0000000000..d02384d162 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3c26deb26a3941642a30691d374199da +timeCreated: 1565256318 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs new file mode 100644 index 0000000000..dba6d82b94 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs @@ -0,0 +1,17 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + // Use this for initialization + public interface IValueSerialization + { + Type ValueType { get; } + + bool IsInline { get; } + + string GenerateDeserializerCall(string callName, string argName); + + void GenerateDeserializer(StreamWriter writer, string callName); + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs.meta new file mode 100644 index 0000000000..8bcb914ef9 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 199c91bbade4ea043928e29946a28502 +timeCreated: 1565256001 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs new file mode 100644 index 0000000000..6f9d20da84 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs @@ -0,0 +1,112 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; + +namespace UniGLTF +{ + public abstract class FunctionSerializationBase : IValueSerialization + { + public Type ValueType + { + get; + protected set; + } + + public bool IsInline + { + get { return false; } + } + + public abstract void GenerateDeserializer(StreamWriter writer, string callName); + + public string GenerateDeserializerCall(string callName, string argName) + { + return string.Format("{0}({1})", callName, argName); + } + } + + public class ObjectSerialization : FunctionSerializationBase + { + string m_path; + FieldSerializationInfo[] m_fsi; + + public ObjectSerialization(Type t, string path) + { + ValueType = t; + m_path = path; + m_fsi = t.GetFields(DeserializerGenerator.FIELD_FLAGS) + .Where(x => + { + if (x.FieldType == typeof(object)) + { + // object. coannot serialize + return false; + } + if (x.IsLiteral && !x.IsInitOnly) + { + // const + return false; + } + return true; + }) + .Select(x => + { + return new FieldSerializationInfo(x, path); + }).ToArray(); + } + + public override string ToString() + { + var sb = new StringBuilder(); + foreach (var x in m_fsi) + { + sb.Append(x.ToString()); + } + return sb.ToString(); + } + + public override void GenerateDeserializer(StreamWriter writer, string parentName) + { + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new $0(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); +" +.Replace("$0", ValueType.Name) +.Replace("$2", parentName) +); + + foreach (var f in m_fsi) + { + writer.Write(@" + if(key==""$0""){ + value.$0 = $1; + continue; + } +" +.Replace("$0", f.Name) +.Replace("$1", f.Serialization.GenerateDeserializerCall(f.FunctionName, "kv.Value")) +); + } + + writer.Write(@" + } + return value; +} +"); + + foreach (var f in m_fsi) + { + if (!f.Serialization.IsInline) + { + f.Serialization.GenerateDeserializer(writer, f.FunctionName); + } + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs.meta new file mode 100644 index 0000000000..7b41b7514d --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 87a20b1fb7336e34bbc61c9d7476c6db +timeCreated: 1565256016 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs new file mode 100644 index 0000000000..396aa483f0 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs @@ -0,0 +1,198 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public abstract class PrimitiveSerializationBase : IValueSerialization + { + public bool IsInline + { + get { return true; } + } + + public abstract Type ValueType { get; } + + public void GenerateDeserializer(StreamWriter writer, string callName) + { + throw new System.NotImplementedException(); + } + + public abstract string GenerateDeserializerCall(string callName, string argName); + } + + public class Int8Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(SByte); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetInt8()"; + } + } + + public class Int16Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Int16); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetInt16()"; + } + } + + public class Int32Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Int32); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetInt32()"; + } + } + + public class Int64Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Int64); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetInt64()"; + } + } + + public class UInt8Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Byte); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetUInt8()"; + } + } + + public class UInt16Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(UInt16); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetUInt16()"; + } + } + + public class UInt32Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(UInt32); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetUInt32()"; + } + } + + public class UInt64Serialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(UInt64); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetUInt64()"; + } + } + + public class SingleSerialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Single); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetSingle()"; + } + } + + public class DoubleSerialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Double); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetDouble()"; + } + } + + public class BooleanSerialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(Boolean); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetBoolean()"; + } + } + + public class StringSerialization : PrimitiveSerializationBase + { + public override Type ValueType + { + get { return typeof(String); } + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return argName + ".GetString()"; + } + } + + public class EnumIntSerialization : PrimitiveSerializationBase + { + Type m_type; + + public override Type ValueType + { + get { return m_type; } + } + + public EnumIntSerialization(Type t) + { + m_type = t; + } + + public override string GenerateDeserializerCall(string callName, string argName) + { + return string.Format("({0}){1}.GetInt32()", m_type.Name, argName); + } + } +} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs.meta new file mode 100644 index 0000000000..8ee2f6f096 --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8ddae9fc19efaec43a6d3aacad1c8d56 +timeCreated: 1565256889 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs new file mode 100644 index 0000000000..b0da0f38ad --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs @@ -0,0 +1,293 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using UniJSON; +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + public static class SerializerGenerator + { + const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; + + static string OutPath + { + get + { + return Path.Combine(UnityEngine.Application.dataPath, + "VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs"); + } + } + + /// + /// AOT向けにシリアライザを生成する + /// + [MenuItem(VRM.VRMVersion.MENU + "/Generate Serializer")] + static void GenerateSerializer() + { + var path = OutPath; + + using (var g = new Generator(path)) + { + var rootType = typeof(glTF); + g.Generate(rootType, "gltf"); + } + } + + class Generator : IDisposable + { + String m_path; + Stream m_s; + StreamWriter m_w; + + static Dictionary s_snipets = new Dictionary + { + {"gltf/animations", "if(value.animations!=null && value.animations.Count>0)" }, + {"gltf/cameras", "if(value.cameras!=null && value.cameras.Count>0)" }, + {"gltf/bufferViews[]/byteStride", "if(false)" }, + {"gltf/bufferViews[]/target", "if(value.target!=0)" }, + {"gltf/animations[]/channels[]/target", "if(value!=null)" }, + {"gltf/accessors[]/sparse", "if(value.sparse!=null && value.sparse.count>0)"}, + {"gltf/meshes[]/primitives[]/targets", "if(value.targets.Count>0)" }, + + {"gltf/meshes[]/primitives[]/targets[]/POSITION", "if(value.POSITION!=-1)" }, + {"gltf/meshes[]/primitives[]/targets[]/NORMAL", "if(value.NORMAL!=-1)" }, + {"gltf/meshes[]/primitives[]/targets[]/TANGENT", "if(value.TANGENT!=-1)" }, + + {"gltf/meshes[]/primitives[]/attributes/POSITION", "if(value.POSITION!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/NORMAL", "if(value.NORMAL!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/TANGENT", "if(value.TANGENT!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/TEXCOORD_0", "if(value.TEXCOORD_0!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/COLOR_0", "if(value.COLOR_0!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/JOINTS_0", "if(value.JOINTS_0!=-1)"}, + {"gltf/meshes[]/primitives[]/attributes/WEIGHTS_0", "if(value.WEIGHTS_0!=-1)"}, + + {"gltf/meshes[]/primitives[]/extras", "if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)"}, + {"gltf/materials[]/alphaCutoff", "if(!string.IsNullOrEmpty(value.alphaMode))" }, + {"gltf/nodes[]/camera", "if(value.camera!=-1)"}, + {"gltf/nodes[]/mesh", "if(value.mesh!=-1)"}, + {"gltf/nodes[]/skin", "if(value.skin!=-1)"}, + {"gltf/skins[]/skeleton", "if(value.skeleton!=-1)"}, + {"gltf/extensionsRequired", "if(false)"}, + {"gltf/extensions/VRM/humanoid/humanBones[]/axisLength", "if(value.axisLength>0)"}, + {"gltf/extensions/VRM/humanoid/humanBones[]/center", "if(value.center!=Vector3.zero)"}, + {"gltf/extensions/VRM/humanoid/humanBones[]/max", "if(value.max!=Vector3.zero)"}, + {"gltf/extensions/VRM/humanoid/humanBones[]/min", "if(value.min!=Vector3.zero)"}, + }; + + public Generator(string path) + { + m_path = path; + m_s = File.Open(path, FileMode.Create); + m_w = new StreamWriter(m_s, Encoding.UTF8); + + // begin + m_w.Write(@" +using System; +using System.Collections.Generic; +using UniJSON; +using UnityEngine; +using VRM; + +namespace UniGLTF { + + static public class IFormatterExtensionsGltf + { + +"); + } + + public void Dispose() + { + // end + m_w.Write(@" + } // class +} // namespace +"); + + m_w.Dispose(); + m_s.Dispose(); + UnityPath.FromFullpath(m_path).ImportAsset(); + } + + HashSet m_used = new HashSet + { + typeof(object), + }; + + public void Generate(Type t, string path, int level = 0) + { + if (m_used.Contains(t)) + { + // 処理済み + return; + } + m_used.Add(t); + + // primitive + try + { + var mi = typeof(IFormatter).GetMethod("Value", new Type[] { t }); + if (mi != null) + { + m_w.Write(@" + public static void GenSerialize(this IFormatter f, $0 value) + { + f.Value(value); + } +".Replace("$0", t.Name)); + + return; + } + } + catch (AmbiguousMatchException) + { + // skip + } + + if (t.IsEnum) + { + m_w.Write(@" + public static void GenSerialize(this IFormatter f, $0 value) + { + f.Value((int)value); + } +".Replace("$0", t.Name)); + } + else if (t.IsArray) + { + var et = t.GetElementType(); + m_w.Write(@" + /// $1 + public static void GenSerialize(this IFormatter f, $0[] value) + { + f.BeginList(value.Length); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + " + .Replace("$0", et.Name) + .Replace("$1", path) + ); + Generate(et, path + "[]", level + 1); + } + else if (t.IsGenericType) + { + if (t.GetGenericTypeDefinition() == typeof(List<>)) + { + var et = t.GetGenericArguments()[0]; + m_w.Write(@" + /// $1 + public static void GenSerialize(this IFormatter f, List<$0> value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } +" +.Replace("$0", et.Name) +.Replace("$1", path)); + Generate(et, path + "[]", level + 1); + } + else if (t.GetGenericTypeDefinition() == typeof(Dictionary<,>) + && t.GetGenericArguments()[0] == typeof(string)) + { + var et = t.GetGenericArguments()[1]; + m_w.Write(@" + /// $1 + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + +" +.Replace("$0", et.Name) +.Replace("$1", path)); + Generate(et, path + "{}", level + 1); + } + else + { + Debug.LogWarningFormat("unknown type: {0}", t); + } + } + else + { + Debug.LogFormat("{0}({1})", path, t.Name); + + m_w.Write(@" + /// $1 + public static void GenSerialize(this IFormatter f, $0 value) + { + f.BeginMap(0); // dummy +" +.Replace("$0", t.Name) +.Replace("$1", path) +); + + foreach (var fi in t.GetFields(FIELD_FLAGS)) + { + if (fi.FieldType == typeof(object)) + { + continue; + } + if (fi.IsLiteral && !fi.IsInitOnly) + { + continue; + } + if (fi.FieldType == typeof(string) || fi.FieldType.IsEnum || fi.FieldType.IsArray || fi.FieldType.IsGenericType) + { + + } + else if (fi.FieldType.IsClass && fi.FieldType.GetFields(FIELD_FLAGS).Length == 0) + { + continue; + } + + var snipet = fi.FieldType.IsClass ? "if(value." + fi.Name + "!=null)" : ""; + var value = default(string); + if (s_snipets.TryGetValue(path + "/" + fi.Name, out value)) + { + snipet = value; + } + + m_w.Write(@" + $1 + { + f.Key(""$0""); f.GenSerialize(value.$0); + } +" +.Replace("$0", fi.Name) +.Replace("$1", snipet) +); + } + + m_w.Write(@" + f.EndMap(); + } +"); + + foreach (var fi in t.GetFields(FIELD_FLAGS)) + { + Generate(fi.FieldType, path + "/" + fi.Name, level + 1); + } + } + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs.meta b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs.meta new file mode 100644 index 0000000000..ffc8762ccb --- /dev/null +++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a9c53a1e9bb8c9244927b7a7041e8e3a +timeCreated: 1564983410 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef b/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef index 3fdf352342..61ff6c4bf2 100644 --- a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef +++ b/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef @@ -2,12 +2,17 @@ "name": "UniGLTF.Editor", "references": [ "VRM", - "ShaderProperty.Runtime" + "ShaderProperty.Runtime", + "UniJSON" ], "optionalUnityReferences": [], "includePlatforms": [ "Editor" ], "excludePlatforms": [], - "allowUnsafeCode": false + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] } \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs new file mode 100644 index 0000000000..e1174d3470 --- /dev/null +++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs @@ -0,0 +1,2123 @@ + +using System; +using System.Collections.Generic; +using UniJSON; +using UnityEngine; +using VRM; + +namespace UniGLTF { + + static public class IFormatterExtensionsGltf + { + + + /// gltf + public static void GenSerialize(this IFormatter f, glTF value) + { + f.BeginMap(0); // dummy + + if(value.asset!=null) + { + f.Key("asset"); f.GenSerialize(value.asset); + } + + if(value.buffers!=null) + { + f.Key("buffers"); f.GenSerialize(value.buffers); + } + + if(value.bufferViews!=null) + { + f.Key("bufferViews"); f.GenSerialize(value.bufferViews); + } + + if(value.accessors!=null) + { + f.Key("accessors"); f.GenSerialize(value.accessors); + } + + if(value.textures!=null) + { + f.Key("textures"); f.GenSerialize(value.textures); + } + + if(value.samplers!=null) + { + f.Key("samplers"); f.GenSerialize(value.samplers); + } + + if(value.images!=null) + { + f.Key("images"); f.GenSerialize(value.images); + } + + if(value.materials!=null) + { + f.Key("materials"); f.GenSerialize(value.materials); + } + + if(value.meshes!=null) + { + f.Key("meshes"); f.GenSerialize(value.meshes); + } + + if(value.nodes!=null) + { + f.Key("nodes"); f.GenSerialize(value.nodes); + } + + if(value.skins!=null) + { + f.Key("skins"); f.GenSerialize(value.skins); + } + + + { + f.Key("scene"); f.GenSerialize(value.scene); + } + + if(value.scenes!=null) + { + f.Key("scenes"); f.GenSerialize(value.scenes); + } + + if(value.animations!=null && value.animations.Count>0) + { + f.Key("animations"); f.GenSerialize(value.animations); + } + + if(value.cameras!=null && value.cameras.Count>0) + { + f.Key("cameras"); f.GenSerialize(value.cameras); + } + + if(value.extensionsUsed!=null) + { + f.Key("extensionsUsed"); f.GenSerialize(value.extensionsUsed); + } + + if(false) + { + f.Key("extensionsRequired"); f.GenSerialize(value.extensionsRequired); + } + + if(value.extensions!=null) + { + f.Key("extensions"); f.GenSerialize(value.extensions); + } + + f.EndMap(); + } + + /// gltf/asset + public static void GenSerialize(this IFormatter f, glTFAssets value) + { + f.BeginMap(0); // dummy + + if(value.generator!=null) + { + f.Key("generator"); f.GenSerialize(value.generator); + } + + if(value.version!=null) + { + f.Key("version"); f.GenSerialize(value.version); + } + + if(value.copyright!=null) + { + f.Key("copyright"); f.GenSerialize(value.copyright); + } + + if(value.minVersion!=null) + { + f.Key("minVersion"); f.GenSerialize(value.minVersion); + } + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, String value) + { + f.Value(value); + } + + /// gltf/buffers + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/buffers[] + public static void GenSerialize(this IFormatter f, glTFBuffer value) + { + f.BeginMap(0); // dummy + + if(value.uri!=null) + { + f.Key("uri"); f.GenSerialize(value.uri); + } + + + { + f.Key("byteLength"); f.GenSerialize(value.byteLength); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, Int32 value) + { + f.Value(value); + } + + /// gltf/bufferViews + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/bufferViews[] + public static void GenSerialize(this IFormatter f, glTFBufferView value) + { + f.BeginMap(0); // dummy + + + { + f.Key("buffer"); f.GenSerialize(value.buffer); + } + + + { + f.Key("byteOffset"); f.GenSerialize(value.byteOffset); + } + + + { + 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); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, glBufferTarget value) + { + f.Value((int)value); + } + + /// gltf/accessors + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/accessors[] + public static void GenSerialize(this IFormatter f, glTFAccessor value) + { + f.BeginMap(0); // dummy + + + { + f.Key("bufferView"); f.GenSerialize(value.bufferView); + } + + + { + f.Key("byteOffset"); f.GenSerialize(value.byteOffset); + } + + if(value.type!=null) + { + f.Key("type"); f.GenSerialize(value.type); + } + + + { + f.Key("componentType"); f.GenSerialize(value.componentType); + } + + + { + f.Key("count"); f.GenSerialize(value.count); + } + + if(value.max!=null) + { + f.Key("max"); f.GenSerialize(value.max); + } + + if(value.min!=null) + { + f.Key("min"); f.GenSerialize(value.min); + } + + + { + f.Key("normalized"); f.GenSerialize(value.normalized); + } + + if(value.sparse!=null && value.sparse.count>0) + { + f.Key("sparse"); f.GenSerialize(value.sparse); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, glComponentType value) + { + f.Value((int)value); + } + + /// gltf/accessors[]/max + public static void GenSerialize(this IFormatter f, Single[] value) + { + f.BeginList(value.Length); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + public static void GenSerialize(this IFormatter f, Single value) + { + f.Value(value); + } + + public static void GenSerialize(this IFormatter f, Boolean value) + { + f.Value(value); + } + + /// gltf/accessors[]/sparse + public static void GenSerialize(this IFormatter f, glTFSparse value) + { + f.BeginMap(0); // dummy + + + { + f.Key("count"); f.GenSerialize(value.count); + } + + if(value.indices!=null) + { + f.Key("indices"); f.GenSerialize(value.indices); + } + + if(value.values!=null) + { + f.Key("values"); f.GenSerialize(value.values); + } + + f.EndMap(); + } + + /// gltf/accessors[]/sparse/indices + public static void GenSerialize(this IFormatter f, glTFSparseIndices value) + { + f.BeginMap(0); // dummy + + + { + f.Key("bufferView"); f.GenSerialize(value.bufferView); + } + + + { + f.Key("byteOffset"); f.GenSerialize(value.byteOffset); + } + + + { + f.Key("componentType"); f.GenSerialize(value.componentType); + } + + f.EndMap(); + } + + /// gltf/accessors[]/sparse/values + public static void GenSerialize(this IFormatter f, glTFSparseValues value) + { + f.BeginMap(0); // dummy + + + { + f.Key("bufferView"); f.GenSerialize(value.bufferView); + } + + + { + f.Key("byteOffset"); f.GenSerialize(value.byteOffset); + } + + f.EndMap(); + } + + /// gltf/textures + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/textures[] + public static void GenSerialize(this IFormatter f, glTFTexture value) + { + f.BeginMap(0); // dummy + + + { + f.Key("sampler"); f.GenSerialize(value.sampler); + } + + + { + f.Key("source"); f.GenSerialize(value.source); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + /// gltf/samplers + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/samplers[] + public static void GenSerialize(this IFormatter f, glTFTextureSampler value) + { + f.BeginMap(0); // dummy + + + { + f.Key("magFilter"); f.GenSerialize(value.magFilter); + } + + + { + f.Key("minFilter"); f.GenSerialize(value.minFilter); + } + + + { + f.Key("wrapS"); f.GenSerialize(value.wrapS); + } + + + { + f.Key("wrapT"); f.GenSerialize(value.wrapT); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, glFilter value) + { + f.Value((int)value); + } + + public static void GenSerialize(this IFormatter f, glWrap value) + { + f.Value((int)value); + } + + /// gltf/images + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/images[] + public static void GenSerialize(this IFormatter f, glTFImage value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.uri!=null) + { + f.Key("uri"); f.GenSerialize(value.uri); + } + + + { + f.Key("bufferView"); f.GenSerialize(value.bufferView); + } + + if(value.mimeType!=null) + { + f.Key("mimeType"); f.GenSerialize(value.mimeType); + } + + f.EndMap(); + } + + /// gltf/materials + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/materials[] + public static void GenSerialize(this IFormatter f, glTFMaterial value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.pbrMetallicRoughness!=null) + { + f.Key("pbrMetallicRoughness"); f.GenSerialize(value.pbrMetallicRoughness); + } + + if(value.normalTexture!=null) + { + f.Key("normalTexture"); f.GenSerialize(value.normalTexture); + } + + if(value.occlusionTexture!=null) + { + f.Key("occlusionTexture"); f.GenSerialize(value.occlusionTexture); + } + + if(value.emissiveTexture!=null) + { + f.Key("emissiveTexture"); f.GenSerialize(value.emissiveTexture); + } + + if(value.emissiveFactor!=null) + { + f.Key("emissiveFactor"); f.GenSerialize(value.emissiveFactor); + } + + if(value.alphaMode!=null) + { + f.Key("alphaMode"); f.GenSerialize(value.alphaMode); + } + + if(!string.IsNullOrEmpty(value.alphaMode)) + { + f.Key("alphaCutoff"); f.GenSerialize(value.alphaCutoff); + } + + + { + f.Key("doubleSided"); f.GenSerialize(value.doubleSided); + } + + if(value.extensions!=null) + { + f.Key("extensions"); f.GenSerialize(value.extensions); + } + + f.EndMap(); + } + + /// gltf/materials[]/pbrMetallicRoughness + public static void GenSerialize(this IFormatter f, glTFPbrMetallicRoughness value) + { + f.BeginMap(0); // dummy + + if(value.baseColorTexture!=null) + { + f.Key("baseColorTexture"); f.GenSerialize(value.baseColorTexture); + } + + if(value.baseColorFactor!=null) + { + f.Key("baseColorFactor"); f.GenSerialize(value.baseColorFactor); + } + + if(value.metallicRoughnessTexture!=null) + { + f.Key("metallicRoughnessTexture"); f.GenSerialize(value.metallicRoughnessTexture); + } + + + { + f.Key("metallicFactor"); f.GenSerialize(value.metallicFactor); + } + + + { + f.Key("roughnessFactor"); f.GenSerialize(value.roughnessFactor); + } + + f.EndMap(); + } + + /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture + public static void GenSerialize(this IFormatter f, glTFMaterialBaseColorTextureInfo value) + { + f.BeginMap(0); // dummy + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("texCoord"); f.GenSerialize(value.texCoord); + } + + f.EndMap(); + } + + /// gltf/materials[]/pbrMetallicRoughness/metallicRoughnessTexture + public static void GenSerialize(this IFormatter f, glTFMaterialMetallicRoughnessTextureInfo value) + { + f.BeginMap(0); // dummy + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("texCoord"); f.GenSerialize(value.texCoord); + } + + f.EndMap(); + } + + /// gltf/materials[]/normalTexture + public static void GenSerialize(this IFormatter f, glTFMaterialNormalTextureInfo value) + { + f.BeginMap(0); // dummy + + + { + f.Key("scale"); f.GenSerialize(value.scale); + } + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("texCoord"); f.GenSerialize(value.texCoord); + } + + f.EndMap(); + } + + /// gltf/materials[]/occlusionTexture + public static void GenSerialize(this IFormatter f, glTFMaterialOcclusionTextureInfo value) + { + f.BeginMap(0); // dummy + + + { + f.Key("strength"); f.GenSerialize(value.strength); + } + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("texCoord"); f.GenSerialize(value.texCoord); + } + + f.EndMap(); + } + + /// gltf/materials[]/emissiveTexture + public static void GenSerialize(this IFormatter f, glTFMaterialEmissiveTextureInfo value) + { + f.BeginMap(0); // dummy + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("texCoord"); f.GenSerialize(value.texCoord); + } + + f.EndMap(); + } + + /// gltf/materials[]/extensions + public static void GenSerialize(this IFormatter f, glTFMaterial_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/materials[]/extensions/KHR_materials_unlit + public static void GenSerialize(this IFormatter f, glTF_KHR_materials_unlit value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/meshes + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/meshes[] + public static void GenSerialize(this IFormatter f, glTFMesh value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.primitives!=null) + { + f.Key("primitives"); f.GenSerialize(value.primitives); + } + + if(value.weights!=null) + { + f.Key("weights"); f.GenSerialize(value.weights); + } + + f.EndMap(); + } + + /// gltf/meshes[]/primitives + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/meshes[]/primitives[] + public static void GenSerialize(this IFormatter f, glTFPrimitives value) + { + f.BeginMap(0); // dummy + + + { + f.Key("mode"); f.GenSerialize(value.mode); + } + + + { + f.Key("indices"); f.GenSerialize(value.indices); + } + + if(value.attributes!=null) + { + f.Key("attributes"); f.GenSerialize(value.attributes); + } + + + { + f.Key("material"); f.GenSerialize(value.material); + } + + if(value.targets.Count>0) + { + f.Key("targets"); f.GenSerialize(value.targets); + } + + if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0) + { + f.Key("extras"); f.GenSerialize(value.extras); + } + + f.EndMap(); + } + + /// gltf/meshes[]/primitives[]/attributes + public static void GenSerialize(this IFormatter f, glTFAttributes value) + { + f.BeginMap(0); // dummy + + if(value.POSITION!=-1) + { + f.Key("POSITION"); f.GenSerialize(value.POSITION); + } + + if(value.NORMAL!=-1) + { + f.Key("NORMAL"); f.GenSerialize(value.NORMAL); + } + + if(value.TANGENT!=-1) + { + f.Key("TANGENT"); f.GenSerialize(value.TANGENT); + } + + if(value.TEXCOORD_0!=-1) + { + f.Key("TEXCOORD_0"); f.GenSerialize(value.TEXCOORD_0); + } + + if(value.COLOR_0!=-1) + { + f.Key("COLOR_0"); f.GenSerialize(value.COLOR_0); + } + + if(value.JOINTS_0!=-1) + { + f.Key("JOINTS_0"); f.GenSerialize(value.JOINTS_0); + } + + if(value.WEIGHTS_0!=-1) + { + f.Key("WEIGHTS_0"); f.GenSerialize(value.WEIGHTS_0); + } + + f.EndMap(); + } + + /// gltf/meshes[]/primitives[]/targets + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/meshes[]/primitives[]/targets[] + public static void GenSerialize(this IFormatter f, gltfMorphTarget value) + { + f.BeginMap(0); // dummy + + if(value.POSITION!=-1) + { + f.Key("POSITION"); f.GenSerialize(value.POSITION); + } + + if(value.NORMAL!=-1) + { + f.Key("NORMAL"); f.GenSerialize(value.NORMAL); + } + + if(value.TANGENT!=-1) + { + f.Key("TANGENT"); f.GenSerialize(value.TANGENT); + } + + f.EndMap(); + } + + /// gltf/meshes[]/primitives[]/extras + public static void GenSerialize(this IFormatter f, glTFPrimitives_extras value) + { + f.BeginMap(0); // dummy + + if(value.targetNames!=null) + { + f.Key("targetNames"); f.GenSerialize(value.targetNames); + } + + f.EndMap(); + } + + /// gltf/meshes[]/primitives[]/extras/targetNames + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/meshes[]/primitives[]/extensions + public static void GenSerialize(this IFormatter f, glTFPrimitives_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/nodes + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/nodes[] + public static void GenSerialize(this IFormatter f, glTFNode value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.children!=null) + { + f.Key("children"); f.GenSerialize(value.children); + } + + if(value.matrix!=null) + { + f.Key("matrix"); f.GenSerialize(value.matrix); + } + + if(value.translation!=null) + { + f.Key("translation"); f.GenSerialize(value.translation); + } + + if(value.rotation!=null) + { + f.Key("rotation"); f.GenSerialize(value.rotation); + } + + if(value.scale!=null) + { + f.Key("scale"); f.GenSerialize(value.scale); + } + + if(value.mesh!=-1) + { + f.Key("mesh"); f.GenSerialize(value.mesh); + } + + if(value.skin!=-1) + { + f.Key("skin"); f.GenSerialize(value.skin); + } + + if(value.weights!=null) + { + f.Key("weights"); f.GenSerialize(value.weights); + } + + if(value.camera!=-1) + { + f.Key("camera"); f.GenSerialize(value.camera); + } + + f.EndMap(); + } + + /// gltf/nodes[]/children + public static void GenSerialize(this IFormatter f, Int32[] value) + { + f.BeginList(value.Length); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/nodes[]/extensions + public static void GenSerialize(this IFormatter f, glTFNode_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/nodes[]/extras + public static void GenSerialize(this IFormatter f, glTFNode_extra value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/skins + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/skins[] + public static void GenSerialize(this IFormatter f, glTFSkin value) + { + f.BeginMap(0); // dummy + + + { + f.Key("inverseBindMatrices"); f.GenSerialize(value.inverseBindMatrices); + } + + if(value.joints!=null) + { + f.Key("joints"); f.GenSerialize(value.joints); + } + + if(value.skeleton!=-1) + { + f.Key("skeleton"); f.GenSerialize(value.skeleton); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + /// gltf/scenes + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/scenes[] + public static void GenSerialize(this IFormatter f, gltfScene value) + { + f.BeginMap(0); // dummy + + if(value.nodes!=null) + { + f.Key("nodes"); f.GenSerialize(value.nodes); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + /// gltf/animations + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/animations[] + public static void GenSerialize(this IFormatter f, glTFAnimation value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.channels!=null) + { + f.Key("channels"); f.GenSerialize(value.channels); + } + + if(value.samplers!=null) + { + f.Key("samplers"); f.GenSerialize(value.samplers); + } + + f.EndMap(); + } + + /// gltf/animations[]/channels + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/animations[]/channels[] + public static void GenSerialize(this IFormatter f, glTFAnimationChannel value) + { + f.BeginMap(0); // dummy + + + { + f.Key("sampler"); f.GenSerialize(value.sampler); + } + + if(value!=null) + { + f.Key("target"); f.GenSerialize(value.target); + } + + f.EndMap(); + } + + /// gltf/animations[]/channels[]/target + public static void GenSerialize(this IFormatter f, glTFAnimationTarget value) + { + f.BeginMap(0); // dummy + + + { + f.Key("node"); f.GenSerialize(value.node); + } + + if(value.path!=null) + { + f.Key("path"); f.GenSerialize(value.path); + } + + f.EndMap(); + } + + /// gltf/animations[]/samplers + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/animations[]/samplers[] + public static void GenSerialize(this IFormatter f, glTFAnimationSampler value) + { + f.BeginMap(0); // dummy + + + { + f.Key("input"); f.GenSerialize(value.input); + } + + if(value.interpolation!=null) + { + f.Key("interpolation"); f.GenSerialize(value.interpolation); + } + + + { + f.Key("output"); f.GenSerialize(value.output); + } + + f.EndMap(); + } + + /// gltf/cameras + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/cameras[] + public static void GenSerialize(this IFormatter f, glTFCamera value) + { + f.BeginMap(0); // dummy + + if(value.orthographic!=null) + { + f.Key("orthographic"); f.GenSerialize(value.orthographic); + } + + if(value.perspective!=null) + { + f.Key("perspective"); f.GenSerialize(value.perspective); + } + + + { + f.Key("type"); f.GenSerialize(value.type); + } + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + f.EndMap(); + } + + /// gltf/cameras[]/orthographic + public static void GenSerialize(this IFormatter f, glTFOrthographic value) + { + f.BeginMap(0); // dummy + + + { + f.Key("xmag"); f.GenSerialize(value.xmag); + } + + + { + f.Key("ymag"); f.GenSerialize(value.ymag); + } + + + { + f.Key("zfar"); f.GenSerialize(value.zfar); + } + + + { + f.Key("znear"); f.GenSerialize(value.znear); + } + + f.EndMap(); + } + + /// gltf/cameras[]/orthographic/extensions + public static void GenSerialize(this IFormatter f, glTFOrthographic_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/cameras[]/orthographic/extras + public static void GenSerialize(this IFormatter f, glTFOrthographic_extras value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/cameras[]/perspective + public static void GenSerialize(this IFormatter f, glTFPerspective value) + { + f.BeginMap(0); // dummy + + + { + f.Key("aspectRatio"); f.GenSerialize(value.aspectRatio); + } + + + { + f.Key("yfov"); f.GenSerialize(value.yfov); + } + + + { + f.Key("zfar"); f.GenSerialize(value.zfar); + } + + + { + f.Key("znear"); f.GenSerialize(value.znear); + } + + f.EndMap(); + } + + /// gltf/cameras[]/perspective/extensions + public static void GenSerialize(this IFormatter f, glTFPerspective_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/cameras[]/perspective/extras + public static void GenSerialize(this IFormatter f, glTFPerspective_extras value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + public static void GenSerialize(this IFormatter f, ProjectionType value) + { + f.Value((int)value); + } + + /// gltf/cameras[]/extensions + public static void GenSerialize(this IFormatter f, glTFCamera_extensions value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/cameras[]/extras + public static void GenSerialize(this IFormatter f, glTFCamera_extras value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + /// gltf/extensions + public static void GenSerialize(this IFormatter f, glTF_extensions value) + { + f.BeginMap(0); // dummy + + if(value.VRM!=null) + { + f.Key("VRM"); f.GenSerialize(value.VRM); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM + public static void GenSerialize(this IFormatter f, glTF_VRM_extensions value) + { + f.BeginMap(0); // dummy + + if(value.exporterVersion!=null) + { + f.Key("exporterVersion"); f.GenSerialize(value.exporterVersion); + } + + if(value.specVersion!=null) + { + f.Key("specVersion"); f.GenSerialize(value.specVersion); + } + + if(value.meta!=null) + { + f.Key("meta"); f.GenSerialize(value.meta); + } + + if(value.humanoid!=null) + { + f.Key("humanoid"); f.GenSerialize(value.humanoid); + } + + if(value.firstPerson!=null) + { + f.Key("firstPerson"); f.GenSerialize(value.firstPerson); + } + + if(value.blendShapeMaster!=null) + { + f.Key("blendShapeMaster"); f.GenSerialize(value.blendShapeMaster); + } + + if(value.secondaryAnimation!=null) + { + f.Key("secondaryAnimation"); f.GenSerialize(value.secondaryAnimation); + } + + if(value.materialProperties!=null) + { + f.Key("materialProperties"); f.GenSerialize(value.materialProperties); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/meta + public static void GenSerialize(this IFormatter f, glTF_VRM_Meta value) + { + f.BeginMap(0); // dummy + + if(value.title!=null) + { + f.Key("title"); f.GenSerialize(value.title); + } + + if(value.version!=null) + { + f.Key("version"); f.GenSerialize(value.version); + } + + if(value.author!=null) + { + f.Key("author"); f.GenSerialize(value.author); + } + + if(value.contactInformation!=null) + { + f.Key("contactInformation"); f.GenSerialize(value.contactInformation); + } + + if(value.reference!=null) + { + f.Key("reference"); f.GenSerialize(value.reference); + } + + + { + f.Key("texture"); f.GenSerialize(value.texture); + } + + if(value.allowedUserName!=null) + { + f.Key("allowedUserName"); f.GenSerialize(value.allowedUserName); + } + + if(value.violentUssageName!=null) + { + f.Key("violentUssageName"); f.GenSerialize(value.violentUssageName); + } + + if(value.sexualUssageName!=null) + { + f.Key("sexualUssageName"); f.GenSerialize(value.sexualUssageName); + } + + if(value.commercialUssageName!=null) + { + f.Key("commercialUssageName"); f.GenSerialize(value.commercialUssageName); + } + + if(value.otherPermissionUrl!=null) + { + f.Key("otherPermissionUrl"); f.GenSerialize(value.otherPermissionUrl); + } + + if(value.licenseName!=null) + { + f.Key("licenseName"); f.GenSerialize(value.licenseName); + } + + if(value.otherLicenseUrl!=null) + { + f.Key("otherLicenseUrl"); f.GenSerialize(value.otherLicenseUrl); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/humanoid + public static void GenSerialize(this IFormatter f, glTF_VRM_Humanoid value) + { + f.BeginMap(0); // dummy + + if(value.humanBones!=null) + { + f.Key("humanBones"); f.GenSerialize(value.humanBones); + } + + + { + f.Key("armStretch"); f.GenSerialize(value.armStretch); + } + + + { + f.Key("legStretch"); f.GenSerialize(value.legStretch); + } + + + { + f.Key("upperArmTwist"); f.GenSerialize(value.upperArmTwist); + } + + + { + f.Key("lowerArmTwist"); f.GenSerialize(value.lowerArmTwist); + } + + + { + f.Key("upperLegTwist"); f.GenSerialize(value.upperLegTwist); + } + + + { + f.Key("lowerLegTwist"); f.GenSerialize(value.lowerLegTwist); + } + + + { + f.Key("feetSpacing"); f.GenSerialize(value.feetSpacing); + } + + + { + f.Key("hasTranslationDoF"); f.GenSerialize(value.hasTranslationDoF); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/humanoid/humanBones + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/humanoid/humanBones[] + public static void GenSerialize(this IFormatter f, glTF_VRM_HumanoidBone value) + { + f.BeginMap(0); // dummy + + if(value.bone!=null) + { + f.Key("bone"); f.GenSerialize(value.bone); + } + + + { + f.Key("node"); f.GenSerialize(value.node); + } + + + { + f.Key("useDefaultValues"); f.GenSerialize(value.useDefaultValues); + } + + if(value.min!=Vector3.zero) + { + f.Key("min"); f.GenSerialize(value.min); + } + + if(value.max!=Vector3.zero) + { + f.Key("max"); f.GenSerialize(value.max); + } + + if(value.center!=Vector3.zero) + { + f.Key("center"); f.GenSerialize(value.center); + } + + if(value.axisLength>0) + { + f.Key("axisLength"); f.GenSerialize(value.axisLength); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/humanoid/humanBones[]/min + public static void GenSerialize(this IFormatter f, Vector3 value) + { + f.BeginMap(0); // dummy + + + { + f.Key("x"); f.GenSerialize(value.x); + } + + + { + f.Key("y"); f.GenSerialize(value.y); + } + + + { + f.Key("z"); f.GenSerialize(value.z); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/firstPerson + public static void GenSerialize(this IFormatter f, glTF_VRM_Firstperson value) + { + f.BeginMap(0); // dummy + + + { + f.Key("firstPersonBone"); f.GenSerialize(value.firstPersonBone); + } + + + { + f.Key("firstPersonBoneOffset"); f.GenSerialize(value.firstPersonBoneOffset); + } + + if(value.meshAnnotations!=null) + { + f.Key("meshAnnotations"); f.GenSerialize(value.meshAnnotations); + } + + if(value.lookAtTypeName!=null) + { + f.Key("lookAtTypeName"); f.GenSerialize(value.lookAtTypeName); + } + + if(value.lookAtHorizontalInner!=null) + { + f.Key("lookAtHorizontalInner"); f.GenSerialize(value.lookAtHorizontalInner); + } + + if(value.lookAtHorizontalOuter!=null) + { + f.Key("lookAtHorizontalOuter"); f.GenSerialize(value.lookAtHorizontalOuter); + } + + if(value.lookAtVerticalDown!=null) + { + f.Key("lookAtVerticalDown"); f.GenSerialize(value.lookAtVerticalDown); + } + + if(value.lookAtVerticalUp!=null) + { + f.Key("lookAtVerticalUp"); f.GenSerialize(value.lookAtVerticalUp); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/firstPerson/meshAnnotations + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/firstPerson/meshAnnotations[] + public static void GenSerialize(this IFormatter f, glTF_VRM_MeshAnnotation value) + { + f.BeginMap(0); // dummy + + + { + f.Key("mesh"); f.GenSerialize(value.mesh); + } + + if(value.firstPersonFlag!=null) + { + f.Key("firstPersonFlag"); f.GenSerialize(value.firstPersonFlag); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/firstPerson/lookAtHorizontalInner + public static void GenSerialize(this IFormatter f, glTF_VRM_DegreeMap value) + { + f.BeginMap(0); // dummy + + if(value.curve!=null) + { + f.Key("curve"); f.GenSerialize(value.curve); + } + + + { + f.Key("xRange"); f.GenSerialize(value.xRange); + } + + + { + f.Key("yRange"); f.GenSerialize(value.yRange); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/blendShapeMaster + public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeMaster value) + { + f.BeginMap(0); // dummy + + if(value.blendShapeGroups!=null) + { + f.Key("blendShapeGroups"); f.GenSerialize(value.blendShapeGroups); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[] + public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeGroup value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.presetName!=null) + { + f.Key("presetName"); f.GenSerialize(value.presetName); + } + + if(value.binds!=null) + { + f.Key("binds"); f.GenSerialize(value.binds); + } + + if(value.materialValues!=null) + { + f.Key("materialValues"); f.GenSerialize(value.materialValues); + } + + + { + f.Key("isBinary"); f.GenSerialize(value.isBinary); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds[] + public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeBind value) + { + f.BeginMap(0); // dummy + + + { + f.Key("mesh"); f.GenSerialize(value.mesh); + } + + + { + f.Key("index"); f.GenSerialize(value.index); + } + + + { + f.Key("weight"); f.GenSerialize(value.weight); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues[] + public static void GenSerialize(this IFormatter f, glTF_VRM_MaterialValueBind value) + { + f.BeginMap(0); // dummy + + if(value.materialName!=null) + { + f.Key("materialName"); f.GenSerialize(value.materialName); + } + + if(value.propertyName!=null) + { + f.Key("propertyName"); f.GenSerialize(value.propertyName); + } + + if(value.targetValue!=null) + { + f.Key("targetValue"); f.GenSerialize(value.targetValue); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/secondaryAnimation + public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimation value) + { + f.BeginMap(0); // dummy + + if(value.boneGroups!=null) + { + f.Key("boneGroups"); f.GenSerialize(value.boneGroups); + } + + if(value.colliderGroups!=null) + { + f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/secondaryAnimation/boneGroups + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/secondaryAnimation/boneGroups[] + public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationGroup value) + { + f.BeginMap(0); // dummy + + if(value.comment!=null) + { + f.Key("comment"); f.GenSerialize(value.comment); + } + + + { + f.Key("stiffiness"); f.GenSerialize(value.stiffiness); + } + + + { + f.Key("gravityPower"); f.GenSerialize(value.gravityPower); + } + + + { + f.Key("gravityDir"); f.GenSerialize(value.gravityDir); + } + + + { + f.Key("dragForce"); f.GenSerialize(value.dragForce); + } + + + { + f.Key("center"); f.GenSerialize(value.center); + } + + + { + f.Key("hitRadius"); f.GenSerialize(value.hitRadius); + } + + if(value.bones!=null) + { + f.Key("bones"); f.GenSerialize(value.bones); + } + + if(value.colliderGroups!=null) + { + f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/secondaryAnimation/colliderGroups + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[] + public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationColliderGroup value) + { + f.BeginMap(0); // dummy + + + { + f.Key("node"); f.GenSerialize(value.node); + } + + if(value.colliders!=null) + { + f.Key("colliders"); f.GenSerialize(value.colliders); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders[] + public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationCollider value) + { + f.BeginMap(0); // dummy + + + { + f.Key("offset"); f.GenSerialize(value.offset); + } + + + { + f.Key("radius"); f.GenSerialize(value.radius); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/materialProperties + public static void GenSerialize(this IFormatter f, List value) + { + f.BeginList(value.Count); + foreach (var x in value) + { + f.GenSerialize(x); + } + f.EndList(); + } + + /// gltf/extensions/VRM/materialProperties[] + public static void GenSerialize(this IFormatter f, glTF_VRM_Material value) + { + f.BeginMap(0); // dummy + + if(value.name!=null) + { + f.Key("name"); f.GenSerialize(value.name); + } + + if(value.shader!=null) + { + f.Key("shader"); f.GenSerialize(value.shader); + } + + + { + f.Key("renderQueue"); f.GenSerialize(value.renderQueue); + } + + if(value.floatProperties!=null) + { + f.Key("floatProperties"); f.GenSerialize(value.floatProperties); + } + + if(value.vectorProperties!=null) + { + f.Key("vectorProperties"); f.GenSerialize(value.vectorProperties); + } + + if(value.textureProperties!=null) + { + f.Key("textureProperties"); f.GenSerialize(value.textureProperties); + } + + if(value.keywordMap!=null) + { + f.Key("keywordMap"); f.GenSerialize(value.keywordMap); + } + + if(value.tagMap!=null) + { + f.Key("tagMap"); f.GenSerialize(value.tagMap); + } + + f.EndMap(); + } + + /// gltf/extensions/VRM/materialProperties[]/floatProperties + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + + + /// gltf/extensions/VRM/materialProperties[]/vectorProperties + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + + + /// gltf/extensions/VRM/materialProperties[]/textureProperties + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + + + /// gltf/extensions/VRM/materialProperties[]/keywordMap + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + + + /// gltf/extensions/VRM/materialProperties[]/tagMap + public static void GenSerialize(this IFormatter f, Dictionary value) + { + f.BeginMap(value.Count); + foreach (var kv in value) + { + f.Key(kv.Key); + f.GenSerialize(kv.Value); + } + f.EndMap(); + } + + + /// gltf/extras + public static void GenSerialize(this IFormatter f, gltf_extras value) + { + f.BeginMap(0); // dummy + + f.EndMap(); + } + + } // class +} // namespace diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta new file mode 100644 index 0000000000..71ef3c0ad4 --- /dev/null +++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 972f1c538db788042863a4ac753dbc04 +timeCreated: 1564987956 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs new file mode 100644 index 0000000000..585905f0f5 --- /dev/null +++ b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs @@ -0,0 +1,2764 @@ + +using UniJSON; +using System; +using System.Collections.Generic; +using VRM; +using UnityEngine; + +namespace UniGLTF { + +public static class GltfDeserializer +{ + + +public static glTF Deserialize(ListTreeNode parsed) +{ + var value = new glTF(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="asset"){ + value.asset = Deserialize_gltf_asset(kv.Value); + continue; + } + + if(key=="buffers"){ + value.buffers = Deserialize_gltf_buffers(kv.Value); + continue; + } + + if(key=="bufferViews"){ + value.bufferViews = Deserialize_gltf_bufferViews(kv.Value); + continue; + } + + if(key=="accessors"){ + value.accessors = Deserialize_gltf_accessors(kv.Value); + continue; + } + + if(key=="textures"){ + value.textures = Deserialize_gltf_textures(kv.Value); + continue; + } + + if(key=="samplers"){ + value.samplers = Deserialize_gltf_samplers(kv.Value); + continue; + } + + if(key=="images"){ + value.images = Deserialize_gltf_images(kv.Value); + continue; + } + + if(key=="materials"){ + value.materials = Deserialize_gltf_materials(kv.Value); + continue; + } + + if(key=="meshes"){ + value.meshes = Deserialize_gltf_meshes(kv.Value); + continue; + } + + if(key=="nodes"){ + value.nodes = Deserialize_gltf_nodes(kv.Value); + continue; + } + + if(key=="skins"){ + value.skins = Deserialize_gltf_skins(kv.Value); + continue; + } + + if(key=="scene"){ + value.scene = kv.Value.GetInt32(); + continue; + } + + if(key=="scenes"){ + value.scenes = Deserialize_gltf_scenes(kv.Value); + continue; + } + + if(key=="animations"){ + value.animations = Deserialize_gltf_animations(kv.Value); + continue; + } + + if(key=="cameras"){ + value.cameras = Deserialize_gltf_cameras(kv.Value); + continue; + } + + if(key=="extensionsUsed"){ + value.extensionsUsed = Deserialize_gltf_extensionsUsed(kv.Value); + continue; + } + + if(key=="extensionsRequired"){ + value.extensionsRequired = Deserialize_gltf_extensionsRequired(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_extensions(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_extras(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAssets Deserialize_gltf_asset(ListTreeNode parsed) +{ + var value = new glTFAssets(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="generator"){ + value.generator = kv.Value.GetString(); + continue; + } + + if(key=="version"){ + value.version = kv.Value.GetString(); + continue; + } + + if(key=="copyright"){ + value.copyright = kv.Value.GetString(); + continue; + } + + if(key=="minVersion"){ + value.minVersion = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_buffers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_buffers_LIST(x)); + } + return value; +} +public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode parsed) +{ + var value = new glTFBuffer(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="uri"){ + value.uri = kv.Value.GetString(); + continue; + } + + if(key=="byteLength"){ + value.byteLength = kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_bufferViews(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_bufferViews_LIST(x)); + } + return value; +} +public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode parsed) +{ + var value = new glTFBufferView(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="buffer"){ + value.buffer = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="byteLength"){ + value.byteLength = kv.Value.GetInt32(); + continue; + } + + if(key=="byteStride"){ + value.byteStride = kv.Value.GetInt32(); + continue; + } + + if(key=="target"){ + value.target = (glBufferTarget)kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_accessors(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_accessors_LIST(x)); + } + return value; +} +public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode parsed) +{ + var value = new glTFAccessor(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="type"){ + value.type = kv.Value.GetString(); + continue; + } + + if(key=="componentType"){ + value.componentType = (glComponentType)kv.Value.GetInt32(); + continue; + } + + if(key=="count"){ + value.count = kv.Value.GetInt32(); + continue; + } + + if(key=="max"){ + value.max = Deserialize_gltf_accessors__max(kv.Value); + continue; + } + + if(key=="min"){ + value.min = Deserialize_gltf_accessors__min(kv.Value); + continue; + } + + if(key=="normalized"){ + value.normalized = kv.Value.GetBoolean(); + continue; + } + + if(key=="sparse"){ + value.sparse = Deserialize_gltf_accessors__sparse(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_accessors__max(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_accessors__min(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 glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode parsed) +{ + var value = new glTFSparse(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="count"){ + value.count = kv.Value.GetInt32(); + continue; + } + + if(key=="indices"){ + value.indices = Deserialize_gltf_accessors__sparse_indices(kv.Value); + continue; + } + + if(key=="values"){ + value.values = Deserialize_gltf_accessors__sparse_values(kv.Value); + continue; + } + + } + return value; +} + +public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListTreeNode parsed) +{ + var value = new glTFSparseIndices(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="componentType"){ + value.componentType = (glComponentType)kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTreeNode parsed) +{ + var value = new glTFSparseValues(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_textures(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_textures_LIST(x)); + } + return value; +} +public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode parsed) +{ + var value = new glTFTexture(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="sampler"){ + value.sampler = kv.Value.GetInt32(); + continue; + } + + if(key=="source"){ + value.source = kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_samplers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_samplers_LIST(x)); + } + return value; +} +public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode parsed) +{ + var value = new glTFTextureSampler(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="magFilter"){ + value.magFilter = (glFilter)kv.Value.GetInt32(); + continue; + } + + if(key=="minFilter"){ + value.minFilter = (glFilter)kv.Value.GetInt32(); + continue; + } + + if(key=="wrapS"){ + value.wrapS = (glWrap)kv.Value.GetInt32(); + continue; + } + + if(key=="wrapT"){ + value.wrapT = (glWrap)kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_images(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_images_LIST(x)); + } + return value; +} +public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode parsed) +{ + var value = new glTFImage(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="uri"){ + value.uri = kv.Value.GetString(); + continue; + } + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="mimeType"){ + value.mimeType = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_materials(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_materials_LIST(x)); + } + return value; +} +public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode parsed) +{ + var value = new glTFMaterial(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="pbrMetallicRoughness"){ + value.pbrMetallicRoughness = Deserialize_gltf_materials__pbrMetallicRoughness(kv.Value); + continue; + } + + if(key=="normalTexture"){ + value.normalTexture = Deserialize_gltf_materials__normalTexture(kv.Value); + continue; + } + + if(key=="occlusionTexture"){ + value.occlusionTexture = Deserialize_gltf_materials__occlusionTexture(kv.Value); + continue; + } + + if(key=="emissiveTexture"){ + value.emissiveTexture = Deserialize_gltf_materials__emissiveTexture(kv.Value); + continue; + } + + if(key=="emissiveFactor"){ + value.emissiveFactor = Deserialize_gltf_materials__emissiveFactor(kv.Value); + continue; + } + + if(key=="alphaMode"){ + value.alphaMode = kv.Value.GetString(); + continue; + } + + if(key=="alphaCutoff"){ + value.alphaCutoff = kv.Value.GetSingle(); + continue; + } + + if(key=="doubleSided"){ + value.doubleSided = kv.Value.GetBoolean(); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_materials__extensions(kv.Value); + continue; + } + + } + return value; +} + +public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRoughness(ListTreeNode parsed) +{ + var value = new glTFPbrMetallicRoughness(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="baseColorTexture"){ + value.baseColorTexture = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(kv.Value); + continue; + } + + if(key=="baseColorFactor"){ + value.baseColorFactor = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(kv.Value); + continue; + } + + if(key=="metallicRoughnessTexture"){ + value.metallicRoughnessTexture = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(kv.Value); + continue; + } + + if(key=="metallicFactor"){ + value.metallicFactor = kv.Value.GetSingle(); + continue; + } + + if(key=="roughnessFactor"){ + value.roughnessFactor = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialBaseColorTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(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 glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialMetallicRoughnessTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialNormalTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="scale"){ + value.scale = kv.Value.GetSingle(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialOcclusionTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="strength"){ + value.strength = kv.Value.GetSingle(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialEmissiveTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__emissiveFactor(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 glTFMaterial_extensions Deserialize_gltf_materials__extensions(ListTreeNode parsed) +{ + var value = new glTFMaterial_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="KHR_materials_unlit"){ + value.KHR_materials_unlit = Deserialize_gltf_materials__extensions_KHR_materials_unlit(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_KHR_materials_unlit Deserialize_gltf_materials__extensions_KHR_materials_unlit(ListTreeNode parsed) +{ + var value = new glTF_KHR_materials_unlit(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static List Deserialize_gltf_meshes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes_LIST(x)); + } + return value; +} +public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode parsed) +{ + var value = new glTFMesh(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="primitives"){ + value.primitives = Deserialize_gltf_meshes__primitives(kv.Value); + continue; + } + + if(key=="weights"){ + value.weights = Deserialize_gltf_meshes__weights(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__primitives(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes__primitives_LIST(x)); + } + return value; +} +public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNode parsed) +{ + var value = new glTFPrimitives(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mode"){ + value.mode = kv.Value.GetInt32(); + continue; + } + + if(key=="indices"){ + value.indices = kv.Value.GetInt32(); + continue; + } + + if(key=="attributes"){ + value.attributes = Deserialize_gltf_meshes__primitives__attributes(kv.Value); + continue; + } + + if(key=="material"){ + value.material = kv.Value.GetInt32(); + continue; + } + + if(key=="targets"){ + value.targets = Deserialize_gltf_meshes__primitives__targets(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_meshes__primitives__extras(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_meshes__primitives__extensions(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(ListTreeNode parsed) +{ + var value = new glTFAttributes(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="POSITION"){ + value.POSITION = kv.Value.GetInt32(); + continue; + } + + if(key=="NORMAL"){ + value.NORMAL = kv.Value.GetInt32(); + continue; + } + + if(key=="TANGENT"){ + value.TANGENT = kv.Value.GetInt32(); + continue; + } + + if(key=="TEXCOORD_0"){ + value.TEXCOORD_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="COLOR_0"){ + value.COLOR_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="JOINTS_0"){ + value.JOINTS_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="WEIGHTS_0"){ + value.WEIGHTS_0 = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__primitives__targets(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes__primitives__targets_LIST(x)); + } + return value; +} +public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(ListTreeNode parsed) +{ + var value = new gltfMorphTarget(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="POSITION"){ + value.POSITION = kv.Value.GetInt32(); + continue; + } + + if(key=="NORMAL"){ + value.NORMAL = kv.Value.GetInt32(); + continue; + } + + if(key=="TANGENT"){ + value.TANGENT = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static glTFPrimitives_extras Deserialize_gltf_meshes__primitives__extras(ListTreeNode parsed) +{ + var value = new glTFPrimitives_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="targetNames"){ + value.targetNames = Deserialize_gltf_meshes__primitives__extras_targetNames(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__primitives__extras_targetNames(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} +public static glTFPrimitives_extensions Deserialize_gltf_meshes__primitives__extensions(ListTreeNode parsed) +{ + var value = new glTFPrimitives_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static Single[] Deserialize_gltf_meshes__weights(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 List Deserialize_gltf_nodes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_nodes_LIST(x)); + } + return value; +} +public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode parsed) +{ + var value = new glTFNode(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="children"){ + value.children = Deserialize_gltf_nodes__children(kv.Value); + continue; + } + + if(key=="matrix"){ + value.matrix = Deserialize_gltf_nodes__matrix(kv.Value); + continue; + } + + if(key=="translation"){ + value.translation = Deserialize_gltf_nodes__translation(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = Deserialize_gltf_nodes__rotation(kv.Value); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_nodes__scale(kv.Value); + continue; + } + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="skin"){ + value.skin = kv.Value.GetInt32(); + continue; + } + + if(key=="weights"){ + value.weights = Deserialize_gltf_nodes__weights(kv.Value); + continue; + } + + if(key=="camera"){ + value.camera = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_nodes__extensions(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_nodes__extras(kv.Value); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_nodes__children(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__matrix(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_nodes__translation(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_nodes__rotation(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_nodes__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_nodes__weights(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 glTFNode_extensions Deserialize_gltf_nodes__extensions(ListTreeNode parsed) +{ + var value = new glTFNode_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFNode_extra Deserialize_gltf_nodes__extras(ListTreeNode parsed) +{ + var value = new glTFNode_extra(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static List Deserialize_gltf_skins(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_skins_LIST(x)); + } + return value; +} +public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode parsed) +{ + var value = new glTFSkin(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="inverseBindMatrices"){ + value.inverseBindMatrices = kv.Value.GetInt32(); + continue; + } + + if(key=="joints"){ + value.joints = Deserialize_gltf_skins__joints(kv.Value); + continue; + } + + if(key=="skeleton"){ + value.skeleton = kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_skins__joints(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_gltf_scenes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_scenes_LIST(x)); + } + return value; +} +public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode parsed) +{ + var value = new gltfScene(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="nodes"){ + value.nodes = Deserialize_gltf_scenes__nodes(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_scenes__nodes(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_gltf_animations(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations_LIST(x)); + } + return value; +} +public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="channels"){ + value.channels = Deserialize_gltf_animations__channels(kv.Value); + continue; + } + + if(key=="samplers"){ + value.samplers = Deserialize_gltf_animations__samplers(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_animations__channels(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations__channels_LIST(x)); + } + return value; +} +public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimationChannel(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="sampler"){ + value.sampler = kv.Value.GetInt32(); + continue; + } + + if(key=="target"){ + value.target = Deserialize_gltf_animations__channels__target(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(ListTreeNode parsed) +{ + var value = new glTFAnimationTarget(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="path"){ + value.path = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_animations__samplers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations__samplers_LIST(x)); + } + return value; +} +public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimationSampler(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="input"){ + value.input = kv.Value.GetInt32(); + continue; + } + + if(key=="interpolation"){ + value.interpolation = kv.Value.GetString(); + continue; + } + + if(key=="output"){ + value.output = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_cameras(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_cameras_LIST(x)); + } + return value; +} +public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode parsed) +{ + var value = new glTFCamera(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="orthographic"){ + value.orthographic = Deserialize_gltf_cameras__orthographic(kv.Value); + continue; + } + + if(key=="perspective"){ + value.perspective = Deserialize_gltf_cameras__perspective(kv.Value); + continue; + } + + if(key=="type"){ + value.type = (ProjectionType)kv.Value.GetInt32(); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_cameras__extensions(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_cameras__extras(kv.Value); + continue; + } + + } + return value; +} + +public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNode parsed) +{ + var value = new glTFOrthographic(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="xmag"){ + value.xmag = kv.Value.GetSingle(); + continue; + } + + if(key=="ymag"){ + value.ymag = kv.Value.GetSingle(); + continue; + } + + if(key=="zfar"){ + value.zfar = kv.Value.GetSingle(); + continue; + } + + if(key=="znear"){ + value.znear = kv.Value.GetSingle(); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_cameras__orthographic_extensions(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_cameras__orthographic_extras(kv.Value); + continue; + } + + } + return value; +} + +public static glTFOrthographic_extensions Deserialize_gltf_cameras__orthographic_extensions(ListTreeNode parsed) +{ + var value = new glTFOrthographic_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFOrthographic_extras Deserialize_gltf_cameras__orthographic_extras(ListTreeNode parsed) +{ + var value = new glTFOrthographic_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode parsed) +{ + var value = new glTFPerspective(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="aspectRatio"){ + value.aspectRatio = kv.Value.GetSingle(); + continue; + } + + if(key=="yfov"){ + value.yfov = kv.Value.GetSingle(); + continue; + } + + if(key=="zfar"){ + value.zfar = kv.Value.GetSingle(); + continue; + } + + if(key=="znear"){ + value.znear = kv.Value.GetSingle(); + continue; + } + + if(key=="extensions"){ + value.extensions = Deserialize_gltf_cameras__perspective_extensions(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = Deserialize_gltf_cameras__perspective_extras(kv.Value); + continue; + } + + } + return value; +} + +public static glTFPerspective_extensions Deserialize_gltf_cameras__perspective_extensions(ListTreeNode parsed) +{ + var value = new glTFPerspective_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFPerspective_extras Deserialize_gltf_cameras__perspective_extras(ListTreeNode parsed) +{ + var value = new glTFPerspective_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFCamera_extensions Deserialize_gltf_cameras__extensions(ListTreeNode parsed) +{ + var value = new glTFCamera_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static glTFCamera_extras Deserialize_gltf_cameras__extras(ListTreeNode parsed) +{ + var value = new glTFCamera_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +public static List Deserialize_gltf_extensionsUsed(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} +public static List Deserialize_gltf_extensionsRequired(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} +public static glTF_extensions Deserialize_gltf_extensions(ListTreeNode parsed) +{ + var value = new glTF_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="VRM"){ + value.VRM = Deserialize_gltf_extensions_VRM(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_VRM_extensions Deserialize_gltf_extensions_VRM(ListTreeNode parsed) +{ + var value = new glTF_VRM_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="exporterVersion"){ + value.exporterVersion = kv.Value.GetString(); + continue; + } + + if(key=="specVersion"){ + value.specVersion = kv.Value.GetString(); + continue; + } + + if(key=="meta"){ + value.meta = Deserialize_gltf_extensions_VRM_meta(kv.Value); + continue; + } + + if(key=="humanoid"){ + value.humanoid = Deserialize_gltf_extensions_VRM_humanoid(kv.Value); + continue; + } + + if(key=="firstPerson"){ + value.firstPerson = Deserialize_gltf_extensions_VRM_firstPerson(kv.Value); + continue; + } + + if(key=="blendShapeMaster"){ + value.blendShapeMaster = Deserialize_gltf_extensions_VRM_blendShapeMaster(kv.Value); + continue; + } + + if(key=="secondaryAnimation"){ + value.secondaryAnimation = Deserialize_gltf_extensions_VRM_secondaryAnimation(kv.Value); + continue; + } + + if(key=="materialProperties"){ + value.materialProperties = Deserialize_gltf_extensions_VRM_materialProperties(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_VRM_Meta Deserialize_gltf_extensions_VRM_meta(ListTreeNode parsed) +{ + var value = new glTF_VRM_Meta(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="title"){ + value.title = kv.Value.GetString(); + continue; + } + + if(key=="version"){ + value.version = kv.Value.GetString(); + continue; + } + + if(key=="author"){ + value.author = kv.Value.GetString(); + continue; + } + + if(key=="contactInformation"){ + value.contactInformation = kv.Value.GetString(); + continue; + } + + if(key=="reference"){ + value.reference = kv.Value.GetString(); + continue; + } + + if(key=="texture"){ + value.texture = kv.Value.GetInt32(); + continue; + } + + if(key=="allowedUserName"){ + value.allowedUserName = kv.Value.GetString(); + continue; + } + + if(key=="violentUssageName"){ + value.violentUssageName = kv.Value.GetString(); + continue; + } + + if(key=="sexualUssageName"){ + value.sexualUssageName = kv.Value.GetString(); + continue; + } + + if(key=="commercialUssageName"){ + value.commercialUssageName = kv.Value.GetString(); + continue; + } + + if(key=="otherPermissionUrl"){ + value.otherPermissionUrl = kv.Value.GetString(); + continue; + } + + if(key=="licenseName"){ + value.licenseName = kv.Value.GetString(); + continue; + } + + if(key=="otherLicenseUrl"){ + value.otherLicenseUrl = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static glTF_VRM_Humanoid Deserialize_gltf_extensions_VRM_humanoid(ListTreeNode parsed) +{ + var value = new glTF_VRM_Humanoid(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="humanBones"){ + value.humanBones = Deserialize_gltf_extensions_VRM_humanoid_humanBones(kv.Value); + continue; + } + + if(key=="armStretch"){ + value.armStretch = kv.Value.GetSingle(); + continue; + } + + if(key=="legStretch"){ + value.legStretch = kv.Value.GetSingle(); + continue; + } + + if(key=="upperArmTwist"){ + value.upperArmTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="lowerArmTwist"){ + value.lowerArmTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="upperLegTwist"){ + value.upperLegTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="lowerLegTwist"){ + value.lowerLegTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="feetSpacing"){ + value.feetSpacing = kv.Value.GetSingle(); + continue; + } + + if(key=="hasTranslationDoF"){ + value.hasTranslationDoF = kv.Value.GetBoolean(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_humanoid_humanBones(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_humanoid_humanBones_LIST(x)); + } + return value; +} +public static glTF_VRM_HumanoidBone Deserialize_gltf_extensions_VRM_humanoid_humanBones_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_HumanoidBone(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bone"){ + value.bone = kv.Value.GetString(); + continue; + } + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="useDefaultValues"){ + value.useDefaultValues = kv.Value.GetBoolean(); + continue; + } + + if(key=="min"){ + value.min = Deserialize_gltf_extensions_VRM_humanoid_humanBones__min(kv.Value); + continue; + } + + if(key=="max"){ + value.max = Deserialize_gltf_extensions_VRM_humanoid_humanBones__max(kv.Value); + continue; + } + + if(key=="center"){ + value.center = Deserialize_gltf_extensions_VRM_humanoid_humanBones__center(kv.Value); + continue; + } + + if(key=="axisLength"){ + value.axisLength = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__min(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__max(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__center(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static glTF_VRM_Firstperson Deserialize_gltf_extensions_VRM_firstPerson(ListTreeNode parsed) +{ + var value = new glTF_VRM_Firstperson(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="firstPersonBone"){ + value.firstPersonBone = kv.Value.GetInt32(); + continue; + } + + if(key=="firstPersonBoneOffset"){ + value.firstPersonBoneOffset = Deserialize_gltf_extensions_VRM_firstPerson_firstPersonBoneOffset(kv.Value); + continue; + } + + if(key=="meshAnnotations"){ + value.meshAnnotations = Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations(kv.Value); + continue; + } + + if(key=="lookAtTypeName"){ + value.lookAtTypeName = kv.Value.GetString(); + continue; + } + + if(key=="lookAtHorizontalInner"){ + value.lookAtHorizontalInner = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner(kv.Value); + continue; + } + + if(key=="lookAtHorizontalOuter"){ + value.lookAtHorizontalOuter = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter(kv.Value); + continue; + } + + if(key=="lookAtVerticalDown"){ + value.lookAtVerticalDown = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown(kv.Value); + continue; + } + + if(key=="lookAtVerticalUp"){ + value.lookAtVerticalUp = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp(kv.Value); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_firstPerson_firstPersonBoneOffset(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations_LIST(x)); + } + return value; +} +public static glTF_VRM_MeshAnnotation Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_MeshAnnotation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="firstPersonFlag"){ + value.firstPersonFlag = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner_curve(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 glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter_curve(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 glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown_curve(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 glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp_curve(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 glTF_VRM_BlendShapeMaster Deserialize_gltf_extensions_VRM_blendShapeMaster(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeMaster(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="blendShapeGroups"){ + value.blendShapeGroups = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_BlendShapeGroup Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="presetName"){ + value.presetName = kv.Value.GetString(); + continue; + } + + if(key=="binds"){ + value.binds = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds(kv.Value); + continue; + } + + if(key=="materialValues"){ + value.materialValues = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues(kv.Value); + continue; + } + + if(key=="isBinary"){ + value.isBinary = kv.Value.GetBoolean(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds_LIST(x)); + } + return value; +} +public static glTF_VRM_BlendShapeBind Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeBind(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="weight"){ + value.weight = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues_LIST(x)); + } + return value; +} +public static glTF_VRM_MaterialValueBind Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_MaterialValueBind(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="materialName"){ + value.materialName = kv.Value.GetString(); + continue; + } + + if(key=="propertyName"){ + value.propertyName = kv.Value.GetString(); + continue; + } + + if(key=="targetValue"){ + value.targetValue = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues__targetValue(kv.Value); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues__targetValue(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 glTF_VRM_SecondaryAnimation Deserialize_gltf_extensions_VRM_secondaryAnimation(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="boneGroups"){ + value.boneGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups(kv.Value); + continue; + } + + if(key=="colliderGroups"){ + value.colliderGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationGroup Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="comment"){ + value.comment = kv.Value.GetString(); + continue; + } + + if(key=="stiffiness"){ + value.stiffiness = kv.Value.GetSingle(); + continue; + } + + if(key=="gravityPower"){ + value.gravityPower = kv.Value.GetSingle(); + continue; + } + + if(key=="gravityDir"){ + value.gravityDir = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__gravityDir(kv.Value); + continue; + } + + if(key=="dragForce"){ + value.dragForce = kv.Value.GetSingle(); + continue; + } + + if(key=="center"){ + value.center = kv.Value.GetInt32(); + continue; + } + + if(key=="hitRadius"){ + value.hitRadius = kv.Value.GetSingle(); + continue; + } + + if(key=="bones"){ + value.bones = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__bones(kv.Value); + continue; + } + + if(key=="colliderGroups"){ + value.colliderGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__colliderGroups(kv.Value); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__gravityDir(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__bones(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static Int32[] Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__colliderGroups(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationColliderGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="colliders"){ + value.colliders = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationCollider Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationCollider(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders__offset(kv.Value); + continue; + } + + if(key=="radius"){ + value.radius = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders__offset(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensions_VRM_materialProperties(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_extensions_VRM_materialProperties_LIST(x)); + } + return value; +} +public static glTF_VRM_Material Deserialize_gltf_extensions_VRM_materialProperties_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_Material(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="shader"){ + value.shader = kv.Value.GetString(); + continue; + } + + if(key=="renderQueue"){ + value.renderQueue = kv.Value.GetInt32(); + continue; + } + + if(key=="floatProperties"){ + value.floatProperties = Deserialize_gltf_extensions_VRM_materialProperties__floatProperties(kv.Value); + continue; + } + + if(key=="vectorProperties"){ + value.vectorProperties = Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties(kv.Value); + continue; + } + + if(key=="textureProperties"){ + value.textureProperties = Deserialize_gltf_extensions_VRM_materialProperties__textureProperties(kv.Value); + continue; + } + + if(key=="keywordMap"){ + value.keywordMap = Deserialize_gltf_extensions_VRM_materialProperties__keywordMap(kv.Value); + continue; + } + + if(key=="tagMap"){ + value.tagMap = Deserialize_gltf_extensions_VRM_materialProperties__tagMap(kv.Value); + continue; + } + + } + return value; +} + + +public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__floatProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetSingle()); + } + return value; +} + + +public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties_DICT(kv.Value)); + } + return value; +} + +public static Single[] Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties_DICT(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 Dictionary Deserialize_gltf_extensions_VRM_materialProperties__textureProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetInt32()); + } + return value; +} + + +public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__keywordMap(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetBoolean()); + } + return value; +} + + +public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__tagMap(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetString()); + } + return value; +} + +public static gltf_extras Deserialize_gltf_extras(ListTreeNode parsed) +{ + var value = new gltf_extras(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + } + return value; +} + +} // GltfDeserializer +} // UniGLTF diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs.meta b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs.meta new file mode 100644 index 0000000000..557bd37b39 --- /dev/null +++ b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fd51f973e67cbb448bab93da7ea596a8 +timeCreated: 1565245501 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs b/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs index 4e44ebea2d..21e13f5b9d 100644 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs +++ b/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs @@ -1,5 +1,8 @@ using System; - +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; namespace UniJSON { @@ -76,9 +79,109 @@ public void Merge(BaseJsonSchemaAttribute rhs) Title = rhs.Title; } } + + public virtual string GetInfo(FieldInfo fi) + { + return ""; + } + + public static bool IsNumber(Type t) + { + if (t == typeof(sbyte) + || t == typeof(short) + || t == typeof(int) + || t == typeof(long) + || t == typeof(byte) + || t == typeof(ushort) + || t == typeof(uint) + || t == typeof(ulong) + || t == typeof(float) + || t == typeof(double) + ) + { + return true; + } + + return false; + } + + public static string GetTypeName(Type t) + { + if (t.IsArray) + { + return t.GetElementType().Name + "[]"; + } + else if (t.IsGenericType) + { + if (t.GetGenericTypeDefinition() == typeof(List<>)) + { + return "List<" + t.GetGenericArguments()[0] + ">"; + } + else if (t.GetGenericTypeDefinition() == typeof(Dictionary<,>)) + { + return "Dictionary<" + string.Join(", ", t.GetGenericArguments().Select(x => x.Name).ToArray()) + ">"; + } + } + + return t.Name; + } + + } + + public class JsonSchemaAttribute : BaseJsonSchemaAttribute + { + public override string GetInfo(FieldInfo fi) + { + if (IsNumber(fi.FieldType)) + { + var sb = new StringBuilder(); + if (!double.IsNaN(Minimum) && !double.IsNaN(Maximum)) + { + sb.Append(string.Format("{0} <= N <= {1}", Minimum, Maximum)); + } + else if (!double.IsNaN(Minimum)) + { + sb.Append(string.Format("{0} <= N", Minimum)); + } + else if (!double.IsNaN(Maximum)) + { + sb.Append(string.Format("N <= {0}", Maximum)); + } + return sb.ToString(); + } + else + { + if (EnumValues != null) + { + return string.Join(", ", EnumValues.Select(x => x.ToString()).ToArray()); + } + else + { + return GetTypeName(fi.FieldType); + } + } + } } - public class JsonSchemaAttribute : BaseJsonSchemaAttribute { } + public class ItemJsonSchemaAttribute : BaseJsonSchemaAttribute + { + public override string GetInfo(FieldInfo fi) + { + var sb = new StringBuilder(); + sb.Append(GetTypeName(fi.FieldType)); + if (!double.IsNaN(MinItems) && !double.IsNaN(MaxItems)) + { + sb.Append(string.Format("{0} < N < {1}", MinItems, MaxItems)); + } + else if (!double.IsNaN(MinItems)) + { + sb.Append(string.Format("{0}< N", MinItems)); + } + else if (!double.IsNaN(MaxItems)) + { - public class ItemJsonSchemaAttribute : BaseJsonSchemaAttribute { } + } + return sb.ToString(); + } + } } diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs b/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs index 1b3428a4dd..f469daed4d 100644 --- a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs +++ b/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs @@ -157,7 +157,7 @@ IEnumerable ToString(string indent, int level, bool value = false) var isFirst = true; var childLevel = level + 1; - foreach (var kv in this.ObjectItems()) + foreach (var kv in this.ObjectItems().OrderBy(x => x.Key.ToString())) { if (isFirst) { diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs index eb3699b8e4..8b1caac2eb 100644 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs +++ b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs @@ -213,7 +213,7 @@ public void HumanoidTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json,json2); + Assert.AreEqual(json, json2); } [Test] @@ -283,7 +283,7 @@ public void MetaTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}",json2); + Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json2); } [Test] @@ -544,7 +544,7 @@ public void SecondaryAnimationColliderTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json,json2); + Assert.AreEqual(json, json2); } [Test] @@ -562,7 +562,7 @@ public void SecondaryAnimationColliderGroupTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json,json2); + Assert.AreEqual(json, json2); } [Test] @@ -598,7 +598,7 @@ public void SecondaryAnimationGroupTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json,json2); + Assert.AreEqual(json, json2); } [Test] @@ -652,7 +652,7 @@ public void SecondaryAnimationTest() }; var json2 = JsonSchema.FromType().Serialize(model, c); // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json,json2); + Assert.AreEqual(json, json2); } [Test] @@ -675,7 +675,7 @@ public void ExtensionsTest() var json2 = JsonSchema.FromType().Serialize(model, c); var expected = String.Format(@"{{""exporterVersion"":""{0}"",""specVersion"":""0.0""}}", VRMVersion.VRM_VERSION); - Assert.AreEqual(expected,json2); + Assert.AreEqual(expected, json2); } // TODO: Move to another suitable location diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 74d7b532b0..d74737e5ec 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -35,6 +35,7 @@ GraphicsSettings: - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index fb50395581..20ca387bf7 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -70,6 +70,8 @@ PlayerSettings: captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 @@ -99,6 +101,8 @@ PlayerSettings: n3dsEnableVSync: 0 ignoreAlphaClear: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 videoMemoryForVertexBuffers: 0 @@ -172,15 +176,21 @@ PlayerSettings: iPhone47inSplashScreen: {fileID: 0} iPhone55inPortraitSplashScreen: {fileID: 0} iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} iPadPortraitSplashScreen: {fileID: 0} iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -277,6 +287,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -289,6 +302,9 @@ PlayerSettings: switchPublisherNames_9: switchPublisherNames_10: switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -301,6 +317,9 @@ PlayerSettings: switchIcons_9: {fileID: 0} switchIcons_10: {fileID: 0} switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -313,6 +332,9 @@ PlayerSettings: switchSmallIcons_9: {fileID: 0} switchSmallIcons_10: {fileID: 0} switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -354,6 +376,7 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 switchDataLossConfirmation: 0 switchSupportedNpadStyles: 3 switchSocketConfigEnabled: 0 @@ -496,7 +519,8 @@ PlayerSettings: webGLUseEmbeddedResources: 0 webGLUseWasm: 0 webGLCompressionFormat: 1 - scriptingDefineSymbols: {} + scriptingDefineSymbols: + 1: VRM_DEVELOP platformArchitecture: {} scriptingBackend: {} incrementalIl2cppBuild: {}