mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-16 01:56:47 -05:00
update VRMSerializerGenerator
This commit is contained in:
parent
c94315c786
commit
40c27f2ec4
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class ArraySerialization : FunctionSerializationBase
|
||||
public class ArraySerialization : SerializationBase
|
||||
{
|
||||
IValueSerialization m_inner;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ namespace UniGLTF
|
|||
}
|
||||
public override void GenerateDeserializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_ARRAY";
|
||||
var itemCallName = callName + "_ITEM";
|
||||
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
|
|
@ -28,7 +28,7 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
"
|
||||
.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$1", m_inner.ValueType.Name)
|
||||
.Replace("$2", callName)
|
||||
.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x"))
|
||||
|
|
@ -39,5 +39,32 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
m_inner.GenerateDeserializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write($@"
|
||||
public static void {callName}(JsonFormatter f, {m_inner.ValueType.Name}[] value)
|
||||
{{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{{
|
||||
"
|
||||
);
|
||||
|
||||
writer.Write($"{m_inner.GenerateSerializerCall(itemCallName, "item")};\n");
|
||||
|
||||
writer.Write(@"
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
");
|
||||
|
||||
if (!m_inner.IsInline)
|
||||
{
|
||||
m_inner.GenerateSerializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public static class GltfDeserializer
|
|||
[MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Deserializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new ObjectSerialization(typeof(glTF), "gltf");
|
||||
var info = new ObjectSerialization(typeof(glTF), "gltf", "Deserialize_");
|
||||
Debug.Log(info);
|
||||
|
||||
using (var s = File.Open(OutPath, FileMode.Create))
|
||||
|
|
@ -54,6 +54,7 @@ public static class GltfDeserializer
|
|||
}
|
||||
|
||||
Debug.LogFormat("write: {0}", OutPath);
|
||||
UnityPath.FromFullpath(OutPath).ImportAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class EnumIntSerialization : IValueSerialization
|
||||
{
|
||||
Type m_type;
|
||||
EnumSerializationType m_serializationType;
|
||||
|
||||
public Type ValueType
|
||||
{
|
||||
get { return m_type; }
|
||||
}
|
||||
|
||||
public bool IsInline
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ValueType.ToString();
|
||||
}
|
||||
|
||||
|
||||
public EnumIntSerialization(Type t, EnumSerializationType serializationType)
|
||||
{
|
||||
m_type = t;
|
||||
m_serializationType = serializationType;
|
||||
}
|
||||
|
||||
public void GenerateDeserializer(StreamWriter writer, string callName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public string GenerateDeserializerCall(string callName, string argName)
|
||||
{
|
||||
switch (m_serializationType)
|
||||
{
|
||||
case EnumSerializationType.AsInt:
|
||||
return string.Format("({0}){1}.GetInt32()", m_type.Name, argName);
|
||||
|
||||
case EnumSerializationType.AsLowerString:
|
||||
// (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true)
|
||||
return $"({m_type.Name})Enum.Parse(typeof({m_type.Name}), {argName}.GetString(), true)";
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GenerateSerializerCall(string callName, string argName)
|
||||
{
|
||||
switch (m_serializationType)
|
||||
{
|
||||
case EnumSerializationType.AsInt:
|
||||
return $"f.Value((int){argName})";
|
||||
|
||||
case EnumSerializationType.AsLowerString:
|
||||
return $"f.Value({argName}.ToString().ToLower())";
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 280f4d5430b0b04449ef06d6f1b4db36
|
||||
guid: 135bb9bd3d924ea4abe8fc6219355a6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -18,5 +18,15 @@ namespace UniGLTF
|
|||
{
|
||||
return $"new glTFExtensionImport({argName})";
|
||||
}
|
||||
|
||||
public void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GenerateSerializerCall(string callName, string argName)
|
||||
{
|
||||
return "value.extras.Serialize(f)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,13 @@ namespace UniGLTF
|
|||
private set;
|
||||
}
|
||||
|
||||
readonly string m_prefix;
|
||||
|
||||
public string FunctionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Deserialize_" + Path
|
||||
return m_prefix + Path
|
||||
.Replace("/", "_")
|
||||
.Replace("[]", "_")
|
||||
;
|
||||
|
|
@ -45,32 +47,33 @@ namespace UniGLTF
|
|||
private set;
|
||||
}
|
||||
|
||||
public FieldSerializationInfo(FieldInfo fi, string path)
|
||||
public FieldSerializationInfo(FieldInfo fi, string path, string prefix)
|
||||
{
|
||||
m_prefix = prefix;
|
||||
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, m_attr);
|
||||
Serialization = GetSerialization(m_fi.FieldType, Path, m_attr, prefix);
|
||||
}
|
||||
|
||||
static IValueSerialization GetSerialization(Type t, string path, JsonSchemaAttribute attr)
|
||||
static IValueSerialization GetSerialization(Type t, string path, JsonSchemaAttribute attr, string prefix)
|
||||
{
|
||||
if (t.IsArray)
|
||||
{
|
||||
return new ArraySerialization(t,
|
||||
GetSerialization(t.GetElementType(), path + "[]", attr));
|
||||
GetSerialization(t.GetElementType(), path + "[]", attr, prefix));
|
||||
}
|
||||
else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>))
|
||||
{
|
||||
return new ListSerialization(t,
|
||||
GetSerialization(t.GetGenericArguments()[0], path + "[]", attr));
|
||||
GetSerialization(t.GetGenericArguments()[0], path + "[]", attr, prefix));
|
||||
}
|
||||
else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>)
|
||||
&& t.GetGenericArguments()[0] == typeof(string))
|
||||
{
|
||||
return new StringKeyDictionarySerialization(t,
|
||||
GetSerialization(t.GetGenericArguments()[1], path, attr));
|
||||
GetSerialization(t.GetGenericArguments()[1], path, attr, prefix));
|
||||
}
|
||||
|
||||
// GetCollectionType(fi.FieldType, out suffix, out t);
|
||||
|
|
@ -131,7 +134,7 @@ namespace UniGLTF
|
|||
return new ExtensionSerialization();
|
||||
}
|
||||
|
||||
return new ObjectSerialization(t, path);
|
||||
return new ObjectSerialization(t, path, prefix);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
|
|
@ -13,5 +13,9 @@ namespace UniGLTF
|
|||
string GenerateDeserializerCall(string callName, string argName);
|
||||
|
||||
void GenerateDeserializer(StreamWriter writer, string callName);
|
||||
|
||||
string GenerateSerializerCall(string callName, string argName);
|
||||
|
||||
void GenerateSerializer(StreamWriter writer, string callName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class ListSerialization : FunctionSerializationBase
|
||||
public class ListSerialization : SerializationBase
|
||||
{
|
||||
IValueSerialization m_inner;
|
||||
|
||||
|
|
@ -21,7 +20,7 @@ namespace UniGLTF
|
|||
|
||||
public override void GenerateDeserializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_LIST";
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
{
|
||||
|
|
@ -32,7 +31,7 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
}
|
||||
return value;
|
||||
}"
|
||||
.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$1", m_inner.ValueType.Name)
|
||||
.Replace("$2", callName)
|
||||
.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x"))
|
||||
|
|
@ -43,5 +42,32 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
m_inner.GenerateDeserializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write($@"
|
||||
public static void {callName}(JsonFormatter f, List<{m_inner.ValueType.Name}> value)
|
||||
{{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{{
|
||||
"
|
||||
);
|
||||
|
||||
writer.Write($"{m_inner.GenerateSerializerCall(itemCallName, "item")};\n");
|
||||
|
||||
writer.Write(@"
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
");
|
||||
|
||||
if (!m_inner.IsInline)
|
||||
{
|
||||
m_inner.GenerateSerializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public abstract class FunctionSerializationBase : IValueSerialization
|
||||
public abstract class SerializationBase : IValueSerialization
|
||||
{
|
||||
public Type ValueType
|
||||
{
|
||||
|
|
@ -22,16 +22,23 @@ namespace UniGLTF
|
|||
|
||||
public string GenerateDeserializerCall(string callName, string argName)
|
||||
{
|
||||
return string.Format("{0}({1})", callName, argName);
|
||||
return $"{callName}({argName})";
|
||||
}
|
||||
|
||||
public abstract void GenerateSerializer(StreamWriter writer, string callName);
|
||||
|
||||
public string GenerateSerializerCall(string callName, string argName)
|
||||
{
|
||||
return $"{callName}(f, {argName})";
|
||||
}
|
||||
}
|
||||
|
||||
public class ObjectSerialization : FunctionSerializationBase
|
||||
public class ObjectSerialization : SerializationBase
|
||||
{
|
||||
string m_path;
|
||||
FieldSerializationInfo[] m_fsi;
|
||||
|
||||
public ObjectSerialization(Type t, string path)
|
||||
public ObjectSerialization(Type t, string path, string prefix)
|
||||
{
|
||||
ValueType = t;
|
||||
m_path = path;
|
||||
|
|
@ -47,7 +54,7 @@ namespace UniGLTF
|
|||
})
|
||||
.Select(x =>
|
||||
{
|
||||
return new FieldSerializationInfo(x, path);
|
||||
return new FieldSerializationInfo(x, path, prefix);
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
|
|
@ -103,5 +110,36 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
writer.Write($@"
|
||||
public static void {callName}(JsonFormatter f, {ValueType.Name} value)
|
||||
{{
|
||||
f.BeginMap();
|
||||
|
||||
"
|
||||
);
|
||||
|
||||
foreach (var f in m_fsi)
|
||||
{
|
||||
writer.Write($" f.Key(\"{f.Name}\");\n");
|
||||
writer.Write($" {f.Serialization.GenerateSerializerCall(f.FunctionName, $"value.{f.Name}")};\n");
|
||||
writer.Write("\n");
|
||||
}
|
||||
|
||||
writer.Write(@"
|
||||
f.EndMap();
|
||||
}
|
||||
");
|
||||
|
||||
foreach (var f in m_fsi)
|
||||
{
|
||||
if (!f.Serialization.IsInline)
|
||||
{
|
||||
f.Serialization.GenerateSerializer(writer, f.FunctionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ namespace UniGLTF
|
|||
|
||||
public abstract string GenerateDeserializerCall(string callName, string argName);
|
||||
|
||||
public void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GenerateSerializerCall(string callName, string argName)
|
||||
{
|
||||
return $"f.Value({argName})";
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ValueType.ToString();
|
||||
|
|
@ -180,37 +190,4 @@ namespace UniGLTF
|
|||
return argName + ".GetString()";
|
||||
}
|
||||
}
|
||||
|
||||
public class EnumIntSerialization : PrimitiveSerializationBase
|
||||
{
|
||||
Type m_type;
|
||||
UniJSON.EnumSerializationType m_serializationType;
|
||||
|
||||
public override Type ValueType
|
||||
{
|
||||
get { return m_type; }
|
||||
}
|
||||
|
||||
public EnumIntSerialization(Type t, UniJSON.EnumSerializationType serializationType)
|
||||
{
|
||||
m_type = t;
|
||||
m_serializationType = serializationType;
|
||||
}
|
||||
|
||||
public override string GenerateDeserializerCall(string callName, string argName)
|
||||
{
|
||||
switch (m_serializationType)
|
||||
{
|
||||
case UniJSON.EnumSerializationType.AsInt:
|
||||
return string.Format("({0}){1}.GetInt32()", m_type.Name, argName);
|
||||
|
||||
case UniJSON.EnumSerializationType.AsLowerString:
|
||||
// (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true)
|
||||
return $"({m_type.Name})Enum.Parse(typeof({m_type.Name}), {argName}.GetString(), true)";
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
@ -14,341 +13,47 @@ namespace UniGLTF
|
|||
{
|
||||
const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
static string OutPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(UnityEngine.Application.dataPath,
|
||||
"UniGLTF/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AOT向けにシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(UniGLTFVersion.MENU + "/GLTF: 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<string, string> s_snippets = new Dictionary<string, string>
|
||||
{
|
||||
{"gltf/animations", "if(value.animations!=null && value.animations.Count>0)" },
|
||||
{"gltf/cameras", "if(value.cameras!=null && value.cameras.Count>0)" },
|
||||
{"gltf/buffers", "if(value.buffers!=null && value.buffers.Count>0)" },
|
||||
{"gltf/bufferViews", "if(value.bufferViews!=null && value.bufferViews.Count>0)" },
|
||||
{"gltf/bufferViews[]/byteStride", "" },
|
||||
{"gltf/bufferViews[]/target", "if(value.target!=0)" },
|
||||
{"gltf/animations[]/channels", "if(value.channels!=null && value.channels.Count>0)" },
|
||||
{"gltf/animations[]/channels[]/target", "if(value!=null)" },
|
||||
{"gltf/animations[]/samplers", "if(value.samplers!=null && value.samplers.Count>0)" },
|
||||
{"gltf/accessors", "if(value.accessors!=null && value.accessors.Count>0)" },
|
||||
{"gltf/accessors[]/max", "if(value.max!=null && value.max.Length>0)"},
|
||||
{"gltf/accessors[]/min", "if(value.min!=null && value.min.Length>0)"},
|
||||
{"gltf/accessors[]/sparse", "if(value.sparse!=null && value.sparse.count>0)"},
|
||||
{"gltf/accessors[]/bufferView", "if(value.bufferView>=0)"},
|
||||
{"gltf/accessors[]/byteOffset", "if(value.bufferView>=0)"},
|
||||
|
||||
{"gltf/images", "if(value.images!=null && value.images.Count>0)" },
|
||||
|
||||
{"gltf/meshes", "if(value.meshes!=null && value.meshes.Count>0)" },
|
||||
{"gltf/meshes[]/primitives", "if(value.primitives!=null && value.primitives.Count>0)" },
|
||||
{"gltf/meshes[]/primitives[]/targets", "if(value.targets!=null && 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/TEXCOORD_1", "if(value.TEXCOORD_1!=-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[]/weights", "if(value.weights!=null && value.weights.Length>0)" },
|
||||
{"gltf/materials", "if(value.materials!=null && value.materials.Count>0)" },
|
||||
{"gltf/materials[]/alphaCutoff", "if(value.alphaMode == \"MASK\")" },
|
||||
{"gltf/nodes", "if(value.nodes!=null && value.nodes.Count>0)" },
|
||||
{"gltf/nodes[]/camera", "if(value.camera!=-1)"},
|
||||
{"gltf/nodes[]/mesh", "if(value.mesh!=-1)"},
|
||||
{"gltf/nodes[]/skin", "if(value.skin!=-1)"},
|
||||
{"gltf/nodes[]/children", "if(value.children != null && value.children.Length>0)"},
|
||||
{"gltf/samplers", "if(value.samplers!=null && value.samplers.Count>0)" },
|
||||
{"gltf/scenes", "if(value.scenes!=null && value.scenes.Count>0)" },
|
||||
{"gltf/scenes[]/nodes", "if(value.nodes!=null && value.nodes.Length>0)" },
|
||||
{"gltf/skins", "if(value.skins!=null && value.skins.Count>0)" },
|
||||
{"gltf/skins[]/skeleton", "if(value.skeleton!=-1)"},
|
||||
{"gltf/skins[]/joints", "if(value.joints!=null && value.joints.Length>0)"},
|
||||
{"gltf/extensionsUsed", "if(value.extensionsUsed!=null && value.extensionsUsed.Count>0)"}, // dummy
|
||||
{"gltf/extensionsRequired", "if(false && value.extensionsRequired!=null && value.extensionsRequired.Count>0)"},
|
||||
{"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)"},
|
||||
{"gltf/textures", "if(value.textures!=null && value.textures.Count>0)" },
|
||||
};
|
||||
|
||||
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;
|
||||
const string Begin = @"using System;
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF {
|
||||
|
||||
static public class IFormatterExtensionsGltf
|
||||
static public class GltfSerializer
|
||||
{
|
||||
|
||||
");
|
||||
}
|
||||
";
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// end
|
||||
m_w.Write(@"
|
||||
const string End = @"
|
||||
} // class
|
||||
} // namespace
|
||||
");
|
||||
";
|
||||
|
||||
m_w.Dispose();
|
||||
m_s.Dispose();
|
||||
UnityPath.FromFullpath(m_path).ImportAsset();
|
||||
static string OutPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(UnityEngine.Application.dataPath,
|
||||
"UniGLTF/UniGLTF/Scripts/IO/GltfSerializer.g.cs");
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Serializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new ObjectSerialization(typeof(glTF), "gltf", "Serialize_");
|
||||
Debug.Log(info);
|
||||
|
||||
using (var s = File.Open(OutPath, FileMode.Create))
|
||||
using (var w = new StreamWriter(s, new UTF8Encoding(false)))
|
||||
{
|
||||
w.Write(Begin);
|
||||
info.GenerateSerializer(w, "Serialize");
|
||||
w.Write(End);
|
||||
}
|
||||
|
||||
HashSet<Type> m_used = new HashSet<Type>
|
||||
{
|
||||
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(JsonFormatter).GetMethod("Value", new Type[] { t });
|
||||
if (mi != null)
|
||||
{
|
||||
m_w.Write(@"
|
||||
public static void GenSerialize(this JsonFormatter f, $0 value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
".Replace("$0", t.Name));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (AmbiguousMatchException)
|
||||
{
|
||||
// skip
|
||||
}
|
||||
|
||||
if (t.IsEnum)
|
||||
{
|
||||
//
|
||||
// enum
|
||||
//
|
||||
m_w.Write(@"
|
||||
public static void GenSerialize(this JsonFormatter 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 JsonFormatter 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<>))
|
||||
{
|
||||
//
|
||||
// array
|
||||
//
|
||||
var et = t.GetGenericArguments()[0];
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter 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))
|
||||
{
|
||||
//
|
||||
// object
|
||||
//
|
||||
var et = t.GetGenericArguments()[1];
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, $0> 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 if (t == typeof(glTFExtension))
|
||||
{
|
||||
// skip
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// reflection
|
||||
//
|
||||
Debug.LogFormat("{0}({1})", path, t.Name);
|
||||
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter 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 == typeof(glTFExtension))
|
||||
{
|
||||
|
||||
}
|
||||
else if (fi.FieldType.IsClass && fi.FieldType.GetFields(FIELD_FLAGS).Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var snipet = "";
|
||||
if (fi.FieldType == typeof(string))
|
||||
{
|
||||
snipet = $"if(!string.IsNullOrEmpty(value.{fi.Name}))";
|
||||
}
|
||||
else if (fi.FieldType.IsClass)
|
||||
{
|
||||
snipet = $"if(value.{fi.Name}!=null)";
|
||||
}
|
||||
|
||||
var value = default(string);
|
||||
if (s_snippets.TryGetValue($"{path}/{fi.Name}", out value))
|
||||
{
|
||||
snipet = value;
|
||||
}
|
||||
|
||||
if (value == "")
|
||||
{
|
||||
// found, but empty
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug.LogFormat("write: {0}", OutPath);
|
||||
UnityPath.FromFullpath(OutPath).ImportAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class StringKeyDictionarySerialization : FunctionSerializationBase
|
||||
public class StringKeyDictionarySerialization : SerializationBase
|
||||
{
|
||||
IValueSerialization m_inner;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ namespace UniGLTF
|
|||
}
|
||||
public override void GenerateDeserializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_DICT";
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write(@"
|
||||
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
|
|
@ -27,7 +27,7 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
"
|
||||
.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType))
|
||||
.Replace("$1", m_inner.ValueType.Name)
|
||||
.Replace("$2", callName)
|
||||
.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "kv.Value"))
|
||||
|
|
@ -38,5 +38,27 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
m_inner.GenerateDeserializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GenerateSerializer(StreamWriter writer, string callName)
|
||||
{
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write($@"
|
||||
public static void {callName}(JsonFormatter f, Dictionary<string, {m_inner.ValueType.Name}> value)
|
||||
{{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{{
|
||||
f.Key(kv.Key);
|
||||
{m_inner.GenerateSerializerCall(itemCallName, "kv.Value")};
|
||||
}}
|
||||
f.EndMap();
|
||||
}}
|
||||
");
|
||||
|
||||
if (!m_inner.IsInline)
|
||||
{
|
||||
m_inner.GenerateSerializer(writer, itemCallName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,49 +13,49 @@ namespace UniGLTF
|
|||
public static string ToJson(this glTF self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMesh self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFPrimitives self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes__primitives_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFAttributes self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes__primitives__attributes(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMaterialBaseColorTextureInfo self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMaterial self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_materials_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFNode self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_nodes_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFSkin self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_skins_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace UniJSON
|
||||
namespace UniGLTF
|
||||
{
|
||||
public enum EnumSerializationType
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@ namespace UniJSON
|
|||
#endregion
|
||||
|
||||
#region object
|
||||
public ValueNodeType ValueType;
|
||||
public UniJSON.ValueNodeType ValueType;
|
||||
public int MinProperties;
|
||||
public bool Required;
|
||||
public string[] Dependencies;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e79a9be81d4b0fc4ebd9ca47d0f20a04
|
||||
timeCreated: 1526058096
|
||||
licenseType: Free
|
||||
guid: 648733606660ecc4d8b8b25e37c1194f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
|
|
@ -380,7 +380,7 @@ namespace UniGLTF
|
|||
public byte[] ToGlbBytes()
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(this);
|
||||
GltfSerializer.Serialize(f, this);
|
||||
|
||||
var json = f.ToString().ParseAsJson().ToString(" ");
|
||||
|
||||
|
|
@ -404,7 +404,7 @@ namespace UniGLTF
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
f.GenSerialize(this);
|
||||
GltfSerializer.Serialize(f, this);
|
||||
var json = f.ToString().ParseAsJson().ToString(" ");
|
||||
RemoveUnusedExtensions(json);
|
||||
return (json, buffers);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
1261
Assets/UniGLTF/UniGLTF/Scripts/IO/GltfSerializer.g.cs
Normal file
1261
Assets/UniGLTF/UniGLTF/Scripts/IO/GltfSerializer.g.cs
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 972f1c538db788042863a4ac753dbc04
|
||||
timeCreated: 1564987956
|
||||
licenseType: Free
|
||||
guid: 0421d021918de864aab65cce94937b61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System;
|
|||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UniGLTF;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace VRM.Samples
|
|||
public static string ToJson(this glTF self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ namespace VRM.Samples
|
|||
|
||||
// 生成シリアライザでJSON化する
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(context.GLTF);
|
||||
GltfSerializer.Serialize(f, context.GLTF);
|
||||
var parsed = f.ToString().ParseAsJson();
|
||||
var newJson = parsed.ToString(" ");
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ namespace VRM.Samples
|
|||
var ff = new JsonFormatter();
|
||||
var des = GltfDeserializer.Deserialize(parsed);
|
||||
ff.Clear();
|
||||
ff.GenSerialize(des);
|
||||
GltfSerializer.Serialize(ff, des);
|
||||
var desJson = ff.ToString().ParseAsJson().ToString(" ");
|
||||
Assert.AreEqual(oldJson.ParseAsJson().ToString(), desJson.ParseAsJson().ToString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,136 +12,136 @@ namespace VRM
|
|||
public static string ToJson(this glTF self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMesh self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFPrimitives self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes__primitives_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFAttributes self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_meshes__primitives__attributes(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMaterialBaseColorTextureInfo self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFMaterial self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_materials_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFNode self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_nodes_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTFSkin self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
GltfSerializer.Serialize_gltf_skins_LIST(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
|
||||
public static string ToJson(this glTF_VRM_MaterialValueBind self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_BlendShapeBind self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_BlendShapeGroup self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_DegreeMap self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_firstPerson_lookAtHorizontalInner(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_MeshAnnotation self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_firstPerson_meshAnnotations_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_Firstperson self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_firstPerson(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_HumanoidBone self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_humanoid_humanBones_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_Humanoid self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_humanoid(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_Material self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_materialProperties_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_Meta self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_meta(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_SecondaryAnimationCollider self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
public static string ToJson(this glTF_VRM_SecondaryAnimationColliderGroup self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
|
||||
public static string ToJson(this glTF_VRM_SecondaryAnimationGroup self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_secondaryAnimation_boneGroups_ITEM(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
|
||||
public static string ToJson(this glTF_VRM_SecondaryAnimation self)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(self);
|
||||
VRMSerializer.Serialize_vrm_secondaryAnimation(f, self);
|
||||
return f.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace VRM
|
|||
[MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Deserializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new UniGLTF.ObjectSerialization(typeof(glTF_VRM_extensions), "vrm");
|
||||
var info = new UniGLTF.ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "_Deserialize");
|
||||
Debug.Log(info);
|
||||
|
||||
using (var s = File.Open(OutPath, FileMode.Create))
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UniGLTF;
|
||||
using UniJSON;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -20,47 +16,11 @@ namespace VRM
|
|||
get
|
||||
{
|
||||
return Path.Combine(UnityEngine.Application.dataPath,
|
||||
"VRM/UniVRM/Scripts/Format/VRMFormatterExtensionsGltf.g.cs");
|
||||
"VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AOT向けにシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Serializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var path = OutPath;
|
||||
|
||||
using (var g = new Generator(path))
|
||||
{
|
||||
var rootType = typeof(glTF_VRM_extensions);
|
||||
g.Generate(rootType, "vrm");
|
||||
}
|
||||
}
|
||||
|
||||
class Generator : IDisposable
|
||||
{
|
||||
String m_path;
|
||||
Stream m_s;
|
||||
StreamWriter m_w;
|
||||
|
||||
static Dictionary<string, string> s_snippets = new Dictionary<string, string>
|
||||
{
|
||||
{"vrm/humanoid/humanBones[]/axisLength", "if(value.axisLength>0)"},
|
||||
{"vrm/humanoid/humanBones[]/center", "if(value.center!=Vector3.zero)"},
|
||||
{"vrm/humanoid/humanBones[]/max", "if(value.max!=Vector3.zero)"},
|
||||
{"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(@"
|
||||
const string Begin = @"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
|
|
@ -69,228 +29,34 @@ using VRM;
|
|||
|
||||
namespace VRM {
|
||||
|
||||
static public class IFormatterExtensionsGltf
|
||||
static public class VrmSerializer
|
||||
{
|
||||
|
||||
");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// end
|
||||
m_w.Write(@"
|
||||
";
|
||||
const string End = @"
|
||||
} // class
|
||||
} // namespace
|
||||
");
|
||||
";
|
||||
|
||||
m_w.Dispose();
|
||||
m_s.Dispose();
|
||||
UnityPath.FromFullpath(m_path).ImportAsset();
|
||||
/// <summary>
|
||||
/// AOT向けにシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Serializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "Serialize_");
|
||||
Debug.Log(info);
|
||||
|
||||
using (var s = File.Open(OutPath, FileMode.Create))
|
||||
using (var w = new StreamWriter(s, new UTF8Encoding(false)))
|
||||
{
|
||||
w.Write(Begin);
|
||||
info.GenerateSerializer(w, "Serialize");
|
||||
w.Write(End);
|
||||
}
|
||||
|
||||
HashSet<Type> m_used = new HashSet<Type>
|
||||
{
|
||||
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(JsonFormatter).GetMethod("Value", new Type[] { t });
|
||||
if (mi != null)
|
||||
{
|
||||
m_w.Write(@"
|
||||
public static void GenSerialize(this JsonFormatter f, $0 value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
".Replace("$0", t.Name));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (AmbiguousMatchException)
|
||||
{
|
||||
// skip
|
||||
}
|
||||
|
||||
if (t.IsEnum)
|
||||
{
|
||||
//
|
||||
// enum
|
||||
//
|
||||
m_w.Write(@"
|
||||
public static void GenSerialize(this JsonFormatter 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 JsonFormatter 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<>))
|
||||
{
|
||||
//
|
||||
// array
|
||||
//
|
||||
var et = t.GetGenericArguments()[0];
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter 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))
|
||||
{
|
||||
//
|
||||
// object
|
||||
//
|
||||
var et = t.GetGenericArguments()[1];
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, $0> 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 if (t == typeof(glTFExtension))
|
||||
{
|
||||
// skip
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// reflection
|
||||
//
|
||||
Debug.LogFormat("{0}({1})", path, t.Name);
|
||||
|
||||
m_w.Write(@"
|
||||
/// $1
|
||||
public static void GenSerialize(this JsonFormatter 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 == typeof(glTF_KHR_materials_unlit))
|
||||
{
|
||||
|
||||
}
|
||||
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_snippets.TryGetValue(path + "/" + fi.Name, out value))
|
||||
{
|
||||
snipet = value;
|
||||
}
|
||||
|
||||
if (value == "")
|
||||
{
|
||||
// found, but empty
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug.LogFormat("write: {0}", OutPath);
|
||||
UnityPath.FromFullpath(OutPath).ImportAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ namespace VRM
|
|||
|
||||
// Serialize VRM
|
||||
var f = new JsonFormatter();
|
||||
f.GenSerialize(VRM);
|
||||
VRMSerializer.Serialize(f, VRM);
|
||||
var bytes = f.GetStoreBytes();
|
||||
glTFExtensionExport.GetOrCreate(ref glTF.extensions).Add("VRM", bytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
using UniGLTF;
|
||||
|
||||
|
||||
namespace VRM
|
||||
|
|
|
|||
|
|
@ -1,797 +0,0 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
using UnityEngine;
|
||||
using VRM;
|
||||
|
||||
namespace VRM {
|
||||
|
||||
static public class IFormatterExtensionsGltf
|
||||
{
|
||||
|
||||
|
||||
/// vrm
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
public static void GenSerialize(this JsonFormatter f, String value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
|
||||
/// vrm/meta
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
public static void GenSerialize(this JsonFormatter f, Int32 value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
|
||||
/// vrm/humanoid
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/humanoid/humanBones
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_HumanoidBone> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/humanoid/humanBones[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
public static void GenSerialize(this JsonFormatter f, Boolean value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
|
||||
/// vrm/humanoid/humanBones[]/min
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
public static void GenSerialize(this JsonFormatter f, Single value)
|
||||
{
|
||||
f.Value(value);
|
||||
}
|
||||
|
||||
/// vrm/firstPerson
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/firstPerson/meshAnnotations
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_MeshAnnotation> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/firstPerson/meshAnnotations[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/firstPerson/lookAtHorizontalInner
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/firstPerson/lookAtHorizontalInner/curve
|
||||
public static void GenSerialize(this JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList(value.Length);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster
|
||||
public static void GenSerialize(this JsonFormatter f, glTF_VRM_BlendShapeMaster value)
|
||||
{
|
||||
f.BeginMap(0); // dummy
|
||||
|
||||
if(value.blendShapeGroups!=null)
|
||||
{
|
||||
f.Key("blendShapeGroups"); f.GenSerialize(value.blendShapeGroups);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_BlendShapeGroup> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups[]/binds
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_BlendShapeBind> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups[]/binds[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups[]/materialValues
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_MaterialValueBind> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/blendShapeMaster/blendShapeGroups[]/materialValues[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/boneGroups
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_SecondaryAnimationGroup> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/boneGroups[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/boneGroups[]/bones
|
||||
public static void GenSerialize(this JsonFormatter f, Int32[] value)
|
||||
{
|
||||
f.BeginList(value.Length);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/colliderGroups
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_SecondaryAnimationColliderGroup> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/colliderGroups[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/colliderGroups[]/colliders
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_SecondaryAnimationCollider> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/secondaryAnimation/colliderGroups[]/colliders[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/materialProperties
|
||||
public static void GenSerialize(this JsonFormatter f, List<glTF_VRM_Material> value)
|
||||
{
|
||||
f.BeginList(value.Count);
|
||||
foreach (var x in value)
|
||||
{
|
||||
f.GenSerialize(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
/// vrm/materialProperties[]
|
||||
public static void GenSerialize(this JsonFormatter 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();
|
||||
}
|
||||
|
||||
/// vrm/materialProperties[]/floatProperties
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, Single> value)
|
||||
{
|
||||
f.BeginMap(value.Count);
|
||||
foreach (var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.GenSerialize(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
|
||||
/// vrm/materialProperties[]/vectorProperties
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, Single[]> value)
|
||||
{
|
||||
f.BeginMap(value.Count);
|
||||
foreach (var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.GenSerialize(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
|
||||
/// vrm/materialProperties[]/textureProperties
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, Int32> value)
|
||||
{
|
||||
f.BeginMap(value.Count);
|
||||
foreach (var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.GenSerialize(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
|
||||
/// vrm/materialProperties[]/keywordMap
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, Boolean> value)
|
||||
{
|
||||
f.BeginMap(value.Count);
|
||||
foreach (var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.GenSerialize(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
|
||||
/// vrm/materialProperties[]/tagMap
|
||||
public static void GenSerialize(this JsonFormatter f, Dictionary<string, String> value)
|
||||
{
|
||||
f.BeginMap(value.Count);
|
||||
foreach (var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.GenSerialize(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
810
Assets/VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs
Normal file
810
Assets/VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs
Normal file
|
|
@ -0,0 +1,810 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
using UnityEngine;
|
||||
using VRM;
|
||||
|
||||
namespace VRM {
|
||||
|
||||
static public class VRMSerializer
|
||||
{
|
||||
|
||||
|
||||
public static void Serialize(JsonFormatter f, glTF_VRM_extensions value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("exporterVersion");
|
||||
f.Value(value.exporterVersion);
|
||||
|
||||
f.Key("specVersion");
|
||||
f.Value(value.specVersion);
|
||||
|
||||
f.Key("meta");
|
||||
Serialize_vrm_meta(f, value.meta);
|
||||
|
||||
f.Key("humanoid");
|
||||
Serialize_vrm_humanoid(f, value.humanoid);
|
||||
|
||||
f.Key("firstPerson");
|
||||
Serialize_vrm_firstPerson(f, value.firstPerson);
|
||||
|
||||
f.Key("blendShapeMaster");
|
||||
Serialize_vrm_blendShapeMaster(f, value.blendShapeMaster);
|
||||
|
||||
f.Key("secondaryAnimation");
|
||||
Serialize_vrm_secondaryAnimation(f, value.secondaryAnimation);
|
||||
|
||||
f.Key("materialProperties");
|
||||
Serialize_vrm_materialProperties(f, value.materialProperties);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_meta(JsonFormatter f, glTF_VRM_Meta value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("title");
|
||||
f.Value(value.title);
|
||||
|
||||
f.Key("version");
|
||||
f.Value(value.version);
|
||||
|
||||
f.Key("author");
|
||||
f.Value(value.author);
|
||||
|
||||
f.Key("contactInformation");
|
||||
f.Value(value.contactInformation);
|
||||
|
||||
f.Key("reference");
|
||||
f.Value(value.reference);
|
||||
|
||||
f.Key("texture");
|
||||
f.Value(value.texture);
|
||||
|
||||
f.Key("allowedUserName");
|
||||
f.Value(value.allowedUserName);
|
||||
|
||||
f.Key("violentUssageName");
|
||||
f.Value(value.violentUssageName);
|
||||
|
||||
f.Key("sexualUssageName");
|
||||
f.Value(value.sexualUssageName);
|
||||
|
||||
f.Key("commercialUssageName");
|
||||
f.Value(value.commercialUssageName);
|
||||
|
||||
f.Key("otherPermissionUrl");
|
||||
f.Value(value.otherPermissionUrl);
|
||||
|
||||
f.Key("licenseName");
|
||||
f.Value(value.licenseName);
|
||||
|
||||
f.Key("otherLicenseUrl");
|
||||
f.Value(value.otherLicenseUrl);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid(JsonFormatter f, glTF_VRM_Humanoid value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("humanBones");
|
||||
Serialize_vrm_humanoid_humanBones(f, value.humanBones);
|
||||
|
||||
f.Key("armStretch");
|
||||
f.Value(value.armStretch);
|
||||
|
||||
f.Key("legStretch");
|
||||
f.Value(value.legStretch);
|
||||
|
||||
f.Key("upperArmTwist");
|
||||
f.Value(value.upperArmTwist);
|
||||
|
||||
f.Key("lowerArmTwist");
|
||||
f.Value(value.lowerArmTwist);
|
||||
|
||||
f.Key("upperLegTwist");
|
||||
f.Value(value.upperLegTwist);
|
||||
|
||||
f.Key("lowerLegTwist");
|
||||
f.Value(value.lowerLegTwist);
|
||||
|
||||
f.Key("feetSpacing");
|
||||
f.Value(value.feetSpacing);
|
||||
|
||||
f.Key("hasTranslationDoF");
|
||||
f.Value(value.hasTranslationDoF);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid_humanBones(JsonFormatter f, List<glTF_VRM_HumanoidBone> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_humanoid_humanBones_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid_humanBones_ITEM(JsonFormatter f, glTF_VRM_HumanoidBone value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("bone");
|
||||
f.Value(value.bone);
|
||||
|
||||
f.Key("node");
|
||||
f.Value(value.node);
|
||||
|
||||
f.Key("useDefaultValues");
|
||||
f.Value(value.useDefaultValues);
|
||||
|
||||
f.Key("min");
|
||||
Serialize_vrm_humanoid_humanBones__min(f, value.min);
|
||||
|
||||
f.Key("max");
|
||||
Serialize_vrm_humanoid_humanBones__max(f, value.max);
|
||||
|
||||
f.Key("center");
|
||||
Serialize_vrm_humanoid_humanBones__center(f, value.center);
|
||||
|
||||
f.Key("axisLength");
|
||||
f.Value(value.axisLength);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid_humanBones__min(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid_humanBones__max(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_humanoid_humanBones__center(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson(JsonFormatter f, glTF_VRM_Firstperson value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("firstPersonBone");
|
||||
f.Value(value.firstPersonBone);
|
||||
|
||||
f.Key("firstPersonBoneOffset");
|
||||
Serialize_vrm_firstPerson_firstPersonBoneOffset(f, value.firstPersonBoneOffset);
|
||||
|
||||
f.Key("meshAnnotations");
|
||||
Serialize_vrm_firstPerson_meshAnnotations(f, value.meshAnnotations);
|
||||
|
||||
f.Key("lookAtTypeName");
|
||||
f.Value(value.lookAtTypeName);
|
||||
|
||||
f.Key("lookAtHorizontalInner");
|
||||
Serialize_vrm_firstPerson_lookAtHorizontalInner(f, value.lookAtHorizontalInner);
|
||||
|
||||
f.Key("lookAtHorizontalOuter");
|
||||
Serialize_vrm_firstPerson_lookAtHorizontalOuter(f, value.lookAtHorizontalOuter);
|
||||
|
||||
f.Key("lookAtVerticalDown");
|
||||
Serialize_vrm_firstPerson_lookAtVerticalDown(f, value.lookAtVerticalDown);
|
||||
|
||||
f.Key("lookAtVerticalUp");
|
||||
Serialize_vrm_firstPerson_lookAtVerticalUp(f, value.lookAtVerticalUp);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_firstPersonBoneOffset(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_meshAnnotations(JsonFormatter f, List<glTF_VRM_MeshAnnotation> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_firstPerson_meshAnnotations_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_meshAnnotations_ITEM(JsonFormatter f, glTF_VRM_MeshAnnotation value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("mesh");
|
||||
f.Value(value.mesh);
|
||||
|
||||
f.Key("firstPersonFlag");
|
||||
f.Value(value.firstPersonFlag);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtHorizontalInner(JsonFormatter f, glTF_VRM_DegreeMap value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("curve");
|
||||
Serialize_vrm_firstPerson_lookAtHorizontalInner_curve(f, value.curve);
|
||||
|
||||
f.Key("xRange");
|
||||
f.Value(value.xRange);
|
||||
|
||||
f.Key("yRange");
|
||||
f.Value(value.yRange);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtHorizontalInner_curve(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtHorizontalOuter(JsonFormatter f, glTF_VRM_DegreeMap value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("curve");
|
||||
Serialize_vrm_firstPerson_lookAtHorizontalOuter_curve(f, value.curve);
|
||||
|
||||
f.Key("xRange");
|
||||
f.Value(value.xRange);
|
||||
|
||||
f.Key("yRange");
|
||||
f.Value(value.yRange);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtHorizontalOuter_curve(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtVerticalDown(JsonFormatter f, glTF_VRM_DegreeMap value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("curve");
|
||||
Serialize_vrm_firstPerson_lookAtVerticalDown_curve(f, value.curve);
|
||||
|
||||
f.Key("xRange");
|
||||
f.Value(value.xRange);
|
||||
|
||||
f.Key("yRange");
|
||||
f.Value(value.yRange);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtVerticalDown_curve(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtVerticalUp(JsonFormatter f, glTF_VRM_DegreeMap value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("curve");
|
||||
Serialize_vrm_firstPerson_lookAtVerticalUp_curve(f, value.curve);
|
||||
|
||||
f.Key("xRange");
|
||||
f.Value(value.xRange);
|
||||
|
||||
f.Key("yRange");
|
||||
f.Value(value.yRange);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_firstPerson_lookAtVerticalUp_curve(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster(JsonFormatter f, glTF_VRM_BlendShapeMaster value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("blendShapeGroups");
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups(f, value.blendShapeGroups);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups(JsonFormatter f, List<glTF_VRM_BlendShapeGroup> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(JsonFormatter f, glTF_VRM_BlendShapeGroup value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("name");
|
||||
f.Value(value.name);
|
||||
|
||||
f.Key("presetName");
|
||||
f.Value(value.presetName);
|
||||
|
||||
f.Key("binds");
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups__binds(f, value.binds);
|
||||
|
||||
f.Key("materialValues");
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(f, value.materialValues);
|
||||
|
||||
f.Key("isBinary");
|
||||
f.Value(value.isBinary);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__binds(JsonFormatter f, List<glTF_VRM_BlendShapeBind> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(JsonFormatter f, glTF_VRM_BlendShapeBind value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("mesh");
|
||||
f.Value(value.mesh);
|
||||
|
||||
f.Key("index");
|
||||
f.Value(value.index);
|
||||
|
||||
f.Key("weight");
|
||||
f.Value(value.weight);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(JsonFormatter f, List<glTF_VRM_MaterialValueBind> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(JsonFormatter f, glTF_VRM_MaterialValueBind value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("materialName");
|
||||
f.Value(value.materialName);
|
||||
|
||||
f.Key("propertyName");
|
||||
f.Value(value.propertyName);
|
||||
|
||||
f.Key("targetValue");
|
||||
Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(f, value.targetValue);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation(JsonFormatter f, glTF_VRM_SecondaryAnimation value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("boneGroups");
|
||||
Serialize_vrm_secondaryAnimation_boneGroups(f, value.boneGroups);
|
||||
|
||||
f.Key("colliderGroups");
|
||||
Serialize_vrm_secondaryAnimation_colliderGroups(f, value.colliderGroups);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_boneGroups(JsonFormatter f, List<glTF_VRM_SecondaryAnimationGroup> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_secondaryAnimation_boneGroups_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_boneGroups_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationGroup value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("comment");
|
||||
f.Value(value.comment);
|
||||
|
||||
f.Key("stiffiness");
|
||||
f.Value(value.stiffiness);
|
||||
|
||||
f.Key("gravityPower");
|
||||
f.Value(value.gravityPower);
|
||||
|
||||
f.Key("gravityDir");
|
||||
Serialize_vrm_secondaryAnimation_boneGroups__gravityDir(f, value.gravityDir);
|
||||
|
||||
f.Key("dragForce");
|
||||
f.Value(value.dragForce);
|
||||
|
||||
f.Key("center");
|
||||
f.Value(value.center);
|
||||
|
||||
f.Key("hitRadius");
|
||||
f.Value(value.hitRadius);
|
||||
|
||||
f.Key("bones");
|
||||
Serialize_vrm_secondaryAnimation_boneGroups__bones(f, value.bones);
|
||||
|
||||
f.Key("colliderGroups");
|
||||
Serialize_vrm_secondaryAnimation_boneGroups__colliderGroups(f, value.colliderGroups);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_boneGroups__gravityDir(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_boneGroups__bones(JsonFormatter f, Int32[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_boneGroups__colliderGroups(JsonFormatter f, Int32[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_colliderGroups(JsonFormatter f, List<glTF_VRM_SecondaryAnimationColliderGroup> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationColliderGroup value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("node");
|
||||
f.Value(value.node);
|
||||
|
||||
f.Key("colliders");
|
||||
Serialize_vrm_secondaryAnimation_colliderGroups__colliders(f, value.colliders);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders(JsonFormatter f, List<glTF_VRM_SecondaryAnimationCollider> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationCollider value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("offset");
|
||||
Serialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(f, value.offset);
|
||||
|
||||
f.Key("radius");
|
||||
f.Value(value.radius);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(JsonFormatter f, Vector3 value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("x");
|
||||
f.Value(value.x);
|
||||
|
||||
f.Key("y");
|
||||
f.Value(value.y);
|
||||
|
||||
f.Key("z");
|
||||
f.Value(value.z);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties(JsonFormatter f, List<glTF_VRM_Material> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_vrm_materialProperties_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties_ITEM(JsonFormatter f, glTF_VRM_Material value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
f.Key("name");
|
||||
f.Value(value.name);
|
||||
|
||||
f.Key("shader");
|
||||
f.Value(value.shader);
|
||||
|
||||
f.Key("renderQueue");
|
||||
f.Value(value.renderQueue);
|
||||
|
||||
f.Key("floatProperties");
|
||||
Serialize_vrm_materialProperties__floatProperties(f, value.floatProperties);
|
||||
|
||||
f.Key("vectorProperties");
|
||||
Serialize_vrm_materialProperties__vectorProperties(f, value.vectorProperties);
|
||||
|
||||
f.Key("textureProperties");
|
||||
Serialize_vrm_materialProperties__textureProperties(f, value.textureProperties);
|
||||
|
||||
f.Key("keywordMap");
|
||||
Serialize_vrm_materialProperties__keywordMap(f, value.keywordMap);
|
||||
|
||||
f.Key("tagMap");
|
||||
Serialize_vrm_materialProperties__tagMap(f, value.tagMap);
|
||||
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__floatProperties(JsonFormatter f, Dictionary<string, Single> value)
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.Value(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__vectorProperties(JsonFormatter f, Dictionary<string, Single[]> value)
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
Serialize_vrm_materialProperties__vectorProperties_DICT(f, kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__vectorProperties_DICT(JsonFormatter f, Single[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__textureProperties(JsonFormatter f, Dictionary<string, Int32> value)
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.Value(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__keywordMap(JsonFormatter f, Dictionary<string, Boolean> value)
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.Value(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_vrm_materialProperties__tagMap(JsonFormatter f, Dictionary<string, String> value)
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach(var kv in value)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.Value(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
11
Assets/VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs.meta
Normal file
11
Assets/VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6690cb3c5aaeaa4f862b396991bf4a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user