From 1e84c70bc2d0e50d5d46409cd4ee188463b5a608 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 5 Feb 2026 15:10:43 +0900 Subject: [PATCH] generate Format/ExpressionsNodeTransform --- .../VRM10/Editor/Vrm10SerializerGenerator.cs | 11 +- .../Format/ExpressionsNodeTransform.meta | 8 + .../Deserializer.g.cs | 145 ++++++++++++++++++ .../Deserializer.g.cs.meta | 11 ++ .../ExpressionsNodeTransform/Format.g.cs | 43 ++++++ .../ExpressionsNodeTransform/Format.g.cs.meta | 11 ++ .../ExpressionsNodeTransform/Serializer.g.cs | 141 +++++++++++++++++ .../Serializer.g.cs.meta | 11 ++ .../Format/SpringBoneLimit/Format.g.cs | 4 +- 9 files changed, 382 insertions(+), 3 deletions(-) create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform.meta create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs.meta create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs.meta create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs create mode 100644 Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs.meta diff --git a/Packages/VRM10/Editor/Vrm10SerializerGenerator.cs b/Packages/VRM10/Editor/Vrm10SerializerGenerator.cs index ec5b753d9..cd3b24015 100644 --- a/Packages/VRM10/Editor/Vrm10SerializerGenerator.cs +++ b/Packages/VRM10/Editor/Vrm10SerializerGenerator.cs @@ -36,6 +36,7 @@ namespace UniVRM10 private const string Vrm10SpecDir = "vrm-specification/specification"; private const string Vrm10FormatGeneratedDir = "Packages/VRM10/Runtime/Format"; + private const string UniGltfFormatGeneratedDir = "Packages/UniGLTF/Runtime/UniGLTF/Format"; public static void Run(bool debug) { @@ -48,7 +49,7 @@ namespace UniVRM10 // VRMC_hdr_emissiveMultiplier new GenerateInfo( $"{Vrm10SpecDir}/VRMC_materials_hdr_emissiveMultiplier-1.0/schema/VRMC_materials_hdr_emissiveMultiplier.json", - "Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/EmissiveMultiplier" + $"{UniGltfFormatGeneratedDir}/ExtensionsAndExtras/EmissiveMultiplier" ), // VRMC_vrm @@ -94,6 +95,14 @@ namespace UniVRM10 $"{Vrm10SpecDir}/VRMC_springBone_limit-1.0/schema/VRMC_springBone_limit.schema.json", $"{Vrm10FormatGeneratedDir}/SpringBoneLimit" ), + + // VRMC_vrm_expressions_node_transform-1.0 + // (experimental) + // https://github.com/ousttrue/vrm-specification/tree/VRMC_vrm_expression_joint + new GenerateInfo( + $"{Vrm10SpecDir}/VRMC_vrm_expressions_node_transform-1.0/schema/VRMC_vrm_expressions_node_transform.schema.json", + $"{Vrm10FormatGeneratedDir}/ExpressionsNodeTransform" + ), }; foreach (var arg in args) diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform.meta b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform.meta new file mode 100644 index 000000000..e63834052 --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d80842db26fe76645bf195c10b9c6bf7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs new file mode 100644 index 000000000..dfa8a3469 --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs @@ -0,0 +1,145 @@ +// This file is generated from JsonSchema. Don't modify this source code. +using UniJSON; +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace UniGLTF.Extensions.VRMC_vrm_expressions_node_transform { + +public static class GltfDeserializer +{ + public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(VRMC_vrm_expressions_node_transform.ExtensionName); + +public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_vrm_expressions_node_transform extension) +{ + if(src is UniGLTF.glTFExtensionImport extensions) + { + foreach(var kv in extensions.ObjectItems()) + { + if(kv.Key.GetUtf8String() == ExtensionNameUtf8) + { + extension = Deserialize(kv.Value); + return true; + } + } + } + + extension = default; + return false; +} + + +public static VRMC_vrm_expressions_node_transform Deserialize(JsonNode parsed) +{ + var value = new VRMC_vrm_expressions_node_transform(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="nodeTransformBinds"){ + value.NodeTransformBinds = Deserialize_NodeTransformBinds(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_NodeTransformBinds(JsonNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_NodeTransformBinds_ITEM(x)); + } + return value; +} + +public static NodeTransformBind Deserialize_NodeTransformBinds_ITEM(JsonNode parsed) +{ + var value = new NodeTransformBind(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="node"){ + value.Node = kv.Value.GetInt32(); + continue; + } + + if(key=="rotation"){ + value.Rotation = __nodeTransformBinds_ITEM_Deserialize_Rotation(kv.Value); + continue; + } + + if(key=="scale"){ + value.Scale = __nodeTransformBinds_ITEM_Deserialize_Scale(kv.Value); + continue; + } + + if(key=="translation"){ + value.Translation = __nodeTransformBinds_ITEM_Deserialize_Translation(kv.Value); + continue; + } + + } + return value; +} + +public static float[] __nodeTransformBinds_ITEM_Deserialize_Rotation(JsonNode parsed) +{ + var value = new float[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static float[] __nodeTransformBinds_ITEM_Deserialize_Scale(JsonNode parsed) +{ + var value = new float[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static float[] __nodeTransformBinds_ITEM_Deserialize_Translation(JsonNode parsed) +{ + var value = new float[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +} // GltfDeserializer +} // UniGLTF diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs.meta b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs.meta new file mode 100644 index 000000000..4d946ab7e --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Deserializer.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a0544899292fe54e961d98e2f7d755c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs new file mode 100644 index 000000000..48421d4b1 --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs @@ -0,0 +1,43 @@ +// This file is generated from JsonSchema. Don't modify this source code. +using System; +using System.Collections.Generic; + + +namespace UniGLTF.Extensions.VRMC_vrm_expressions_node_transform +{ + + public class NodeTransformBind + { + // Dictionary object with extension-specific objects. + public object Extensions; + + // Application-specific data. + public object Extras; + + // The node index. + public int? Node; + + // The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar. + public float[] Rotation; + + // The node's non-uniform scale, given as the scaling factors along the x, y, and z axes. + public float[] Scale; + + // The node's translation along the x, y, and z axes. + public float[] Translation; + } + + public class VRMC_vrm_expressions_node_transform + { + public const string ExtensionName = "VRMC_vrm_expressions_node_transform"; + + // Dictionary object with extension-specific objects. + public object Extensions; + + // Application-specific data. + public object Extras; + + // Specify a node transform + public List NodeTransformBinds; + } +} diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs.meta b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs.meta new file mode 100644 index 000000000..311817f13 --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Format.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3f6d0369358084249b383bea969b16a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs new file mode 100644 index 000000000..a3f38a515 --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs @@ -0,0 +1,141 @@ +// This file is generated from JsonSchema. Don't modify this source code. +using System; +using System.Collections.Generic; +using System.Linq; +using UniJSON; + +namespace UniGLTF.Extensions.VRMC_vrm_expressions_node_transform { + + static public class GltfSerializer + { + + public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_vrm_expressions_node_transform extension) + { + if (dst is glTFExtensionImport) + { + throw new NotImplementedException(); + } + + if (!(dst is glTFExtensionExport extensions)) + { + extensions = new glTFExtensionExport(); + dst = extensions; + } + + var f = new JsonFormatter(); + Serialize(f, extension); + extensions.Add(VRMC_vrm_expressions_node_transform.ExtensionName, f.GetStoreBytes()); + } + + +public static void Serialize(JsonFormatter f, VRMC_vrm_expressions_node_transform value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + (value.Extensions as glTFExtension).Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + (value.Extras as glTFExtension).Serialize(f); + } + + if(value.NodeTransformBinds!=null&&value.NodeTransformBinds.Count()>=1){ + f.Key("nodeTransformBinds"); + Serialize_NodeTransformBinds(f, value.NodeTransformBinds); + } + + f.EndMap(); +} + +public static void Serialize_NodeTransformBinds(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_NodeTransformBinds_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_NodeTransformBinds_ITEM(JsonFormatter f, NodeTransformBind value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + (value.Extensions as glTFExtension).Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + (value.Extras as glTFExtension).Serialize(f); + } + + if(value.Node.HasValue){ + f.Key("node"); + f.Value(value.Node.GetValueOrDefault()); + } + + if(value.Rotation!=null&&value.Rotation.Count()>=4){ + f.Key("rotation"); + __nodeTransformBinds_ITEM_Serialize_Rotation(f, value.Rotation); + } + + if(value.Scale!=null&&value.Scale.Count()>=3){ + f.Key("scale"); + __nodeTransformBinds_ITEM_Serialize_Scale(f, value.Scale); + } + + if(value.Translation!=null&&value.Translation.Count()>=3){ + f.Key("translation"); + __nodeTransformBinds_ITEM_Serialize_Translation(f, value.Translation); + } + + f.EndMap(); +} + +public static void __nodeTransformBinds_ITEM_Serialize_Rotation(JsonFormatter f, float[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void __nodeTransformBinds_ITEM_Serialize_Scale(JsonFormatter f, float[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void __nodeTransformBinds_ITEM_Serialize_Translation(JsonFormatter f, float[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + + } // class +} // namespace diff --git a/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs.meta b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs.meta new file mode 100644 index 000000000..773237b4d --- /dev/null +++ b/Packages/VRM10/Runtime/Format/ExpressionsNodeTransform/Serializer.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 16a49328d069d9f47840c104597af4a4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/VRM10/Runtime/Format/SpringBoneLimit/Format.g.cs b/Packages/VRM10/Runtime/Format/SpringBoneLimit/Format.g.cs index f820abb77..655df84f1 100644 --- a/Packages/VRM10/Runtime/Format/SpringBoneLimit/Format.g.cs +++ b/Packages/VRM10/Runtime/Format/SpringBoneLimit/Format.g.cs @@ -44,10 +44,10 @@ namespace UniGLTF.Extensions.VRMC_springBone_limit // Application-specific data. public object Extras; - // The phi angle of the spherical limit in radians. If the phi angle is set to π or greater, the angle will be interpreted as π by the implementation. + // The pitch angle of the spherical limit in radians. If the pitch angle is set to π or greater, the angle will be interpreted as π by the implementation. public float? Pitch; - // The theta angle of the spherical limit in radians. If the theta angle is set to π/2 or greater, the angle will be interpreted as π/2 by the implementation. + // The yaw angle of the spherical limit in radians. If the yaw angle is set to π/2 or greater, the angle will be interpreted as π/2 by the implementation. public float? Yaw; // The rotation from the default orientation of the spherical limit. The rotation is represented as a quaternion (x, y, z, w), where w is the scalar.