mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-01 15:22:53 -05:00
Merge pull request #924 from ousttrue/feature10/update_jsonschema_20210430
Feature10/update jsonschema 20210430
This commit is contained in:
@@ -265,7 +265,7 @@ namespace UniGLTF.JsonSchema
|
||||
|
||||
public void Dump(StringBuilder sb, string indent = "")
|
||||
{
|
||||
sb.AppendLine($"{indent}{JsonPath}: {type}");
|
||||
sb.AppendLine($"{JsonPath}: {type}");
|
||||
|
||||
foreach (var x in Children())
|
||||
{
|
||||
|
||||
@@ -71,6 +71,8 @@ public static $0 $2(JsonNode parsed)
|
||||
.Replace("$2", callName)
|
||||
);
|
||||
|
||||
var prefix = string.IsNullOrEmpty(ClassName) ? "Deserialize_" : $"{ClassName}_Deserialize_";
|
||||
|
||||
foreach (var kv in Properties)
|
||||
{
|
||||
writer.Write(@"
|
||||
@@ -80,7 +82,7 @@ public static $0 $2(JsonNode parsed)
|
||||
}
|
||||
"
|
||||
.Replace("$0", kv.Key)
|
||||
.Replace("$1", kv.Value.GenerateDeserializerCall($"Deserialize_{kv.Key.ToUpperCamel()}", "kv.Value"))
|
||||
.Replace("$1", kv.Value.GenerateDeserializerCall($"{prefix}{kv.Key.ToUpperCamel()}", "kv.Value"))
|
||||
.Replace("$2", kv.Key.ToUpperCamel())
|
||||
);
|
||||
}
|
||||
@@ -95,7 +97,7 @@ public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
if (!kv.Value.IsInline)
|
||||
{
|
||||
kv.Value.GenerateDeserializer(writer, $"Deserialize_{kv.Key.ToUpperCamel()}");
|
||||
kv.Value.GenerateDeserializer(writer, $"{prefix}{kv.Key.ToUpperCamel()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,6 +133,9 @@ public static void {callName}(JsonFormatter f, {ValueType} value)
|
||||
"
|
||||
);
|
||||
|
||||
|
||||
var prefix = string.IsNullOrEmpty(ClassName) ? "Serialize_" : $"{ClassName}_Serialize_";
|
||||
|
||||
foreach (var kv in Properties)
|
||||
{
|
||||
var valueName = $"value.{kv.Key.ToUpperCamel()}";
|
||||
@@ -138,7 +143,7 @@ public static void {callName}(JsonFormatter f, {ValueType} value)
|
||||
writer.Write($@"
|
||||
if({kv.Value.CreateSerializationCondition(valueName)}{condition}){{
|
||||
f.Key(""{kv.Key}"");
|
||||
{kv.Value.GenerateSerializerCall($"Serialize_{kv.Key.ToUpperCamel()}", valueName)};
|
||||
{kv.Value.GenerateSerializerCall($"{prefix}{kv.Key.ToUpperCamel()}", valueName)};
|
||||
}}
|
||||
");
|
||||
}
|
||||
@@ -152,7 +157,7 @@ public static void {callName}(JsonFormatter f, {ValueType} value)
|
||||
{
|
||||
if (!kv.Value.IsInline)
|
||||
{
|
||||
kv.Value.GenerateSerializer(writer, $"Serialize_{kv.Key.ToUpperCamel()}");
|
||||
kv.Value.GenerateSerializer(writer, $"{prefix}{kv.Key.ToUpperCamel()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ namespace UniVRM10
|
||||
// VRMC_materials_mtoon
|
||||
"vrm-specification/specification/VRMC_materials_mtoon-1.0_draft/schema/VRMC_materials_mtoon.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/MaterialsMToon", // dst
|
||||
// VRMC_node_collider
|
||||
"vrm-specification/specification/VRMC_node_collider_1.0_draft/schema/VRMC_node_collider.json",
|
||||
"Assets/VRM10/Runtime/Format/NodeCollider", // dst
|
||||
// VRMC_springBone
|
||||
"vrm-specification/specification/VRMC_springBone-1.0_draft/schema/VRMC_springBone.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/SpringBone", // dst
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace UniVRM10
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class VRM10SpringBoneCollider
|
||||
public class VRM10SpringBoneCollider : MonoBehaviour
|
||||
{
|
||||
public VRM10SpringBoneColliderTypes ColliderType;
|
||||
|
||||
@@ -22,5 +22,74 @@ namespace UniVRM10
|
||||
|
||||
/// <summary>bone local position</summary>
|
||||
public Vector3 Tail;
|
||||
|
||||
public static void DrawWireCapsule(Vector3 headPos, Vector3 tailPos, float radius)
|
||||
{
|
||||
var headToTail = tailPos - headPos;
|
||||
if (headToTail.sqrMagnitude <= float.Epsilon)
|
||||
{
|
||||
Gizmos.DrawWireSphere(headPos, radius);
|
||||
return;
|
||||
}
|
||||
|
||||
var forward = headToTail.normalized * radius;
|
||||
|
||||
var xLen = Mathf.Abs(forward.x);
|
||||
var yLen = Mathf.Abs(forward.y);
|
||||
var zLen = Mathf.Abs(forward.z);
|
||||
var rightWorldAxis = (yLen > xLen && yLen > zLen) ? Vector3.right : Vector3.up;
|
||||
|
||||
var up = Vector3.Cross(forward, rightWorldAxis).normalized * radius;
|
||||
var right = Vector3.Cross(up, forward).normalized * radius;
|
||||
|
||||
const int division = 24;
|
||||
DrawWireCircle(headPos, up, right, division, division);
|
||||
DrawWireCircle(headPos, up, -forward, division, division / 2);
|
||||
DrawWireCircle(headPos, right, -forward, division, division / 2);
|
||||
|
||||
DrawWireCircle(tailPos, up, right, division, division);
|
||||
DrawWireCircle(tailPos, up, forward, division, division / 2);
|
||||
DrawWireCircle(tailPos, right, forward, division, division / 2);
|
||||
|
||||
Gizmos.DrawLine(headPos + right, tailPos + right);
|
||||
Gizmos.DrawLine(headPos - right, tailPos - right);
|
||||
Gizmos.DrawLine(headPos + up, tailPos + up);
|
||||
Gizmos.DrawLine(headPos - up, tailPos - up);
|
||||
}
|
||||
|
||||
private static void DrawWireCircle(Vector3 centerPos, Vector3 xAxis, Vector3 yAxis, int division, int count)
|
||||
{
|
||||
for (var idx = 0; idx < division && idx < count; ++idx)
|
||||
{
|
||||
var s = ((idx + 0) % division) / (float)division * Mathf.PI * 2f;
|
||||
var t = ((idx + 1) % division) / (float)division * Mathf.PI * 2f;
|
||||
|
||||
Gizmos.DrawLine(
|
||||
centerPos + xAxis * Mathf.Cos(s) + yAxis * Mathf.Sin(s),
|
||||
centerPos + xAxis * Mathf.Cos(t) + yAxis * Mathf.Sin(t)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 mat = transform.localToWorldMatrix;
|
||||
Gizmos.matrix = mat * Matrix4x4.Scale(new Vector3(
|
||||
1.0f / transform.lossyScale.x,
|
||||
1.0f / transform.lossyScale.y,
|
||||
1.0f / transform.lossyScale.z
|
||||
));
|
||||
switch (ColliderType)
|
||||
{
|
||||
case VRM10SpringBoneColliderTypes.Sphere:
|
||||
Gizmos.DrawWireSphere(Offset, Radius);
|
||||
break;
|
||||
|
||||
case VRM10SpringBoneColliderTypes.Capsule:
|
||||
DrawWireCapsule(Offset, Tail, Radius);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,82 +10,7 @@ namespace UniVRM10
|
||||
[AddComponentMenu("VRM10/VRM10SpringBoneColliderGroup")]
|
||||
public class VRM10SpringBoneColliderGroup : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
Color m_gizmoColor = Color.cyan;
|
||||
|
||||
[SerializeField]
|
||||
public List<VRM10SpringBoneCollider> Colliders = new List<VRM10SpringBoneCollider>();
|
||||
|
||||
public static void DrawWireCapsule(Vector3 headPos, Vector3 tailPos, float radius)
|
||||
{
|
||||
var headToTail = tailPos - headPos;
|
||||
if (headToTail.sqrMagnitude <= float.Epsilon)
|
||||
{
|
||||
Gizmos.DrawWireSphere(headPos, radius);
|
||||
return;
|
||||
}
|
||||
|
||||
var forward = headToTail.normalized * radius;
|
||||
|
||||
var xLen = Mathf.Abs(forward.x);
|
||||
var yLen = Mathf.Abs(forward.y);
|
||||
var zLen = Mathf.Abs(forward.z);
|
||||
var rightWorldAxis = (yLen > xLen && yLen > zLen) ? Vector3.right : Vector3.up;
|
||||
|
||||
var up = Vector3.Cross(forward, rightWorldAxis).normalized * radius;
|
||||
var right = Vector3.Cross(up, forward).normalized * radius;
|
||||
|
||||
const int division = 24;
|
||||
DrawWireCircle(headPos, up, right, division, division);
|
||||
DrawWireCircle(headPos, up, -forward, division, division / 2);
|
||||
DrawWireCircle(headPos, right, -forward, division, division / 2);
|
||||
|
||||
DrawWireCircle(tailPos, up, right, division, division);
|
||||
DrawWireCircle(tailPos, up, forward, division, division / 2);
|
||||
DrawWireCircle(tailPos, right, forward, division, division / 2);
|
||||
|
||||
Gizmos.DrawLine(headPos + right, tailPos + right);
|
||||
Gizmos.DrawLine(headPos - right, tailPos - right);
|
||||
Gizmos.DrawLine(headPos + up, tailPos + up);
|
||||
Gizmos.DrawLine(headPos - up, tailPos - up);
|
||||
}
|
||||
|
||||
private static void DrawWireCircle(Vector3 centerPos, Vector3 xAxis, Vector3 yAxis, int division, int count)
|
||||
{
|
||||
for (var idx = 0; idx < division && idx < count; ++idx)
|
||||
{
|
||||
var s = ((idx + 0) % division) / (float)division * Mathf.PI * 2f;
|
||||
var t = ((idx + 1) % division) / (float)division * Mathf.PI * 2f;
|
||||
|
||||
Gizmos.DrawLine(
|
||||
centerPos + xAxis * Mathf.Cos(s) + yAxis * Mathf.Sin(s),
|
||||
centerPos + xAxis * Mathf.Cos(t) + yAxis * Mathf.Sin(t)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = m_gizmoColor;
|
||||
Matrix4x4 mat = transform.localToWorldMatrix;
|
||||
Gizmos.matrix = mat * Matrix4x4.Scale(new Vector3(
|
||||
1.0f / transform.lossyScale.x,
|
||||
1.0f / transform.lossyScale.y,
|
||||
1.0f / transform.lossyScale.z
|
||||
));
|
||||
foreach (var y in Colliders)
|
||||
{
|
||||
switch (y.ColliderType)
|
||||
{
|
||||
case VRM10SpringBoneColliderTypes.Sphere:
|
||||
Gizmos.DrawWireSphere(y.Offset, y.Radius);
|
||||
break;
|
||||
|
||||
case VRM10SpringBoneColliderTypes.Capsule:
|
||||
DrawWireCapsule(y.Offset, y.Tail, y.Radius);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,17 +74,17 @@ public static Constraint Deserialize_Constraint(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="position"){
|
||||
value.Position = Deserialize_Position(kv.Value);
|
||||
value.Position = __constraint_Deserialize_Position(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="rotation"){
|
||||
value.Rotation = Deserialize_Rotation(kv.Value);
|
||||
value.Rotation = __constraint_Deserialize_Rotation(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="aim"){
|
||||
value.Aim = Deserialize_Aim(kv.Value);
|
||||
value.Aim = __constraint_Deserialize_Aim(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public static Constraint Deserialize_Constraint(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static PositionConstraint Deserialize_Position(JsonNode parsed)
|
||||
public static PositionConstraint __constraint_Deserialize_Position(JsonNode parsed)
|
||||
{
|
||||
var value = new PositionConstraint();
|
||||
|
||||
@@ -131,7 +131,7 @@ public static PositionConstraint Deserialize_Position(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="freezeAxes"){
|
||||
value.FreezeAxes = Deserialize_FreezeAxes(kv.Value);
|
||||
value.FreezeAxes = __constraint__position_Deserialize_FreezeAxes(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public static PositionConstraint Deserialize_Position(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static bool[] Deserialize_FreezeAxes(JsonNode parsed)
|
||||
public static bool[] __constraint__position_Deserialize_FreezeAxes(JsonNode parsed)
|
||||
{
|
||||
var value = new bool[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
@@ -155,7 +155,7 @@ public static bool[] Deserialize_FreezeAxes(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static RotationConstraint Deserialize_Rotation(JsonNode parsed)
|
||||
public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode parsed)
|
||||
{
|
||||
var value = new RotationConstraint();
|
||||
|
||||
@@ -194,7 +194,7 @@ public static RotationConstraint Deserialize_Rotation(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="freezeAxes"){
|
||||
value.FreezeAxes = Deserialize_FreezeAxes(kv.Value);
|
||||
value.FreezeAxes = __constraint__rotation_Deserialize_FreezeAxes(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,18 @@ public static RotationConstraint Deserialize_Rotation(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static AimConstraint Deserialize_Aim(JsonNode parsed)
|
||||
public static bool[] __constraint__rotation_Deserialize_FreezeAxes(JsonNode parsed)
|
||||
{
|
||||
var value = new bool[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value[i++] = x.GetBoolean();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static AimConstraint __constraint_Deserialize_Aim(JsonNode parsed)
|
||||
{
|
||||
var value = new AimConstraint();
|
||||
|
||||
@@ -246,17 +257,17 @@ public static AimConstraint Deserialize_Aim(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="aimVector"){
|
||||
value.AimVector = Deserialize_AimVector(kv.Value);
|
||||
value.AimVector = __constraint__aim_Deserialize_AimVector(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="upVector"){
|
||||
value.UpVector = Deserialize_UpVector(kv.Value);
|
||||
value.UpVector = __constraint__aim_Deserialize_UpVector(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="freezeAxes"){
|
||||
value.FreezeAxes = Deserialize_FreezeAxes(kv.Value);
|
||||
value.FreezeAxes = __constraint__aim_Deserialize_FreezeAxes(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -269,7 +280,7 @@ public static AimConstraint Deserialize_Aim(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_AimVector(JsonNode parsed)
|
||||
public static float[] __constraint__aim_Deserialize_AimVector(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
@@ -280,7 +291,7 @@ public static float[] Deserialize_AimVector(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_UpVector(JsonNode parsed)
|
||||
public static float[] __constraint__aim_Deserialize_UpVector(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
@@ -291,5 +302,16 @@ public static float[] Deserialize_UpVector(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static bool[] __constraint__aim_Deserialize_FreezeAxes(JsonNode parsed)
|
||||
{
|
||||
var value = new bool[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value[i++] = x.GetBoolean();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
} // GltfDeserializer
|
||||
} // UniGLTF
|
||||
|
||||
@@ -68,23 +68,23 @@ public static void Serialize_Constraint(JsonFormatter f, Constraint value)
|
||||
|
||||
if(value.Position!=null){
|
||||
f.Key("position");
|
||||
Serialize_Position(f, value.Position);
|
||||
__constraint_Serialize_Position(f, value.Position);
|
||||
}
|
||||
|
||||
if(value.Rotation!=null){
|
||||
f.Key("rotation");
|
||||
Serialize_Rotation(f, value.Rotation);
|
||||
__constraint_Serialize_Rotation(f, value.Rotation);
|
||||
}
|
||||
|
||||
if(value.Aim!=null){
|
||||
f.Key("aim");
|
||||
Serialize_Aim(f, value.Aim);
|
||||
__constraint_Serialize_Aim(f, value.Aim);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Position(JsonFormatter f, PositionConstraint value)
|
||||
public static void __constraint_Serialize_Position(JsonFormatter f, PositionConstraint value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
@@ -121,7 +121,7 @@ public static void Serialize_Position(JsonFormatter f, PositionConstraint value)
|
||||
|
||||
if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=3){
|
||||
f.Key("freezeAxes");
|
||||
Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
__constraint__position_Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
@@ -132,7 +132,7 @@ public static void Serialize_Position(JsonFormatter f, PositionConstraint value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_FreezeAxes(JsonFormatter f, bool[] value)
|
||||
public static void __constraint__position_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
@@ -144,7 +144,7 @@ public static void Serialize_FreezeAxes(JsonFormatter f, bool[] value)
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Rotation(JsonFormatter f, RotationConstraint value)
|
||||
public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationConstraint value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
@@ -181,7 +181,7 @@ public static void Serialize_Rotation(JsonFormatter f, RotationConstraint value)
|
||||
|
||||
if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=3){
|
||||
f.Key("freezeAxes");
|
||||
Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
__constraint__rotation_Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
@@ -192,7 +192,19 @@ public static void Serialize_Rotation(JsonFormatter f, RotationConstraint value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Aim(JsonFormatter f, AimConstraint value)
|
||||
public static void __constraint__rotation_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void __constraint_Serialize_Aim(JsonFormatter f, AimConstraint value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
@@ -229,17 +241,17 @@ public static void Serialize_Aim(JsonFormatter f, AimConstraint value)
|
||||
|
||||
if(value.AimVector!=null&&value.AimVector.Count()>=3){
|
||||
f.Key("aimVector");
|
||||
Serialize_AimVector(f, value.AimVector);
|
||||
__constraint__aim_Serialize_AimVector(f, value.AimVector);
|
||||
}
|
||||
|
||||
if(value.UpVector!=null&&value.UpVector.Count()>=3){
|
||||
f.Key("upVector");
|
||||
Serialize_UpVector(f, value.UpVector);
|
||||
__constraint__aim_Serialize_UpVector(f, value.UpVector);
|
||||
}
|
||||
|
||||
if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=2){
|
||||
f.Key("freezeAxes");
|
||||
Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
__constraint__aim_Serialize_FreezeAxes(f, value.FreezeAxes);
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
@@ -250,7 +262,7 @@ public static void Serialize_Aim(JsonFormatter f, AimConstraint value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_AimVector(JsonFormatter f, float[] value)
|
||||
public static void __constraint__aim_Serialize_AimVector(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
@@ -262,7 +274,19 @@ public static void Serialize_AimVector(JsonFormatter f, float[] value)
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_UpVector(JsonFormatter f, float[] value)
|
||||
public static void __constraint__aim_Serialize_UpVector(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void __constraint__aim_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57de298702679f949a2f2658ad186d4a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,172 +0,0 @@
|
||||
// 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_node_collider {
|
||||
|
||||
public static class GltfDeserializer
|
||||
{
|
||||
|
||||
public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_node_collider extension)
|
||||
{
|
||||
if(src is UniGLTF.glTFExtensionImport extensions)
|
||||
{
|
||||
foreach(var kv in extensions.ObjectItems())
|
||||
{
|
||||
if(kv.Key.GetUtf8String() == VRMC_node_collider.ExtensionNameUtf8)
|
||||
{
|
||||
extension = Deserialize(kv.Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static VRMC_node_collider Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_node_collider();
|
||||
|
||||
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=="shapes"){
|
||||
value.Shapes = Deserialize_Shapes(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static List<ColliderShape> Deserialize_Shapes(JsonNode parsed)
|
||||
{
|
||||
var value = new List<ColliderShape>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value.Add(Deserialize_Shapes_ITEM(x));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShape Deserialize_Shapes_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShape();
|
||||
|
||||
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=="sphere"){
|
||||
value.Sphere = Deserialize_Sphere(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="capsule"){
|
||||
value.Capsule = Deserialize_Capsule(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShapeSphere Deserialize_Sphere(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeSphere();
|
||||
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
|
||||
if(key=="offset"){
|
||||
value.Offset = Deserialize_Offset(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="radius"){
|
||||
value.Radius = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Offset(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 ColliderShapeCapsule Deserialize_Capsule(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeCapsule();
|
||||
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
|
||||
if(key=="offset"){
|
||||
value.Offset = Deserialize_Offset(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="radius"){
|
||||
value.Radius = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="tail"){
|
||||
value.Tail = Deserialize_Tail(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Tail(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
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 162032f06e7a71549bb767d4aad3d221
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
// This file is generated from JsonSchema. Don't modify this source code.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF.Extensions.VRMC_node_collider
|
||||
{
|
||||
|
||||
public class ColliderShapeSphere
|
||||
{
|
||||
// The sphere center. vector3
|
||||
public float[] Offset;
|
||||
|
||||
// The sphere radius
|
||||
public float? Radius;
|
||||
}
|
||||
|
||||
public class ColliderShapeCapsule
|
||||
{
|
||||
// The capsule head. vector3
|
||||
public float[] Offset;
|
||||
|
||||
// The capsule radius
|
||||
public float? Radius;
|
||||
|
||||
// The capsule tail. vector3
|
||||
public float[] Tail;
|
||||
}
|
||||
|
||||
public class ColliderShape
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public glTFExtension Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
public ColliderShapeSphere Sphere;
|
||||
|
||||
public ColliderShapeCapsule Capsule;
|
||||
}
|
||||
|
||||
public class VRMC_node_collider
|
||||
{
|
||||
public const string ExtensionName = "VRMC_node_collider";
|
||||
public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName);
|
||||
|
||||
// Dictionary object with extension-specific objects.
|
||||
public glTFExtension Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
public List<ColliderShape> Shapes;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f73d7cedc49cb4d9513f7a0a9ae9b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,160 +0,0 @@
|
||||
// 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_node_collider {
|
||||
|
||||
static public class GltfSerializer
|
||||
{
|
||||
|
||||
public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_node_collider 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_node_collider.ExtensionName, f.GetStoreBytes());
|
||||
}
|
||||
|
||||
|
||||
public static void Serialize(JsonFormatter f, VRMC_node_collider value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
value.Extensions.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Shapes!=null&&value.Shapes.Count()>=0){
|
||||
f.Key("shapes");
|
||||
Serialize_Shapes(f, value.Shapes);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Shapes(JsonFormatter f, List<ColliderShape> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_Shapes_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Shapes_ITEM(JsonFormatter f, ColliderShape value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
value.Extensions.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Sphere!=null){
|
||||
f.Key("sphere");
|
||||
Serialize_Sphere(f, value.Sphere);
|
||||
}
|
||||
|
||||
if(value.Capsule!=null){
|
||||
f.Key("capsule");
|
||||
Serialize_Capsule(f, value.Capsule);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Sphere(JsonFormatter f, ColliderShapeSphere value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Offset!=null&&value.Offset.Count()>=3){
|
||||
f.Key("offset");
|
||||
Serialize_Offset(f, value.Offset);
|
||||
}
|
||||
|
||||
if(value.Radius.HasValue){
|
||||
f.Key("radius");
|
||||
f.Value(value.Radius.GetValueOrDefault());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Offset(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Capsule(JsonFormatter f, ColliderShapeCapsule value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Offset!=null&&value.Offset.Count()>=3){
|
||||
f.Key("offset");
|
||||
Serialize_Offset(f, value.Offset);
|
||||
}
|
||||
|
||||
if(value.Radius.HasValue){
|
||||
f.Key("radius");
|
||||
f.Value(value.Radius.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.Tail!=null&&value.Tail.Count()>=3){
|
||||
f.Key("tail");
|
||||
Serialize_Tail(f, value.Tail);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Tail(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8eb6c9672b71ea147867c73cb8d58a35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -46,6 +46,11 @@ public static VRMC_springBone Deserialize(JsonNode parsed)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="colliderGroups"){
|
||||
value.ColliderGroups = Deserialize_ColliderGroups(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="springs"){
|
||||
value.Springs = Deserialize_Springs(kv.Value);
|
||||
continue;
|
||||
@@ -55,6 +60,199 @@ public static VRMC_springBone Deserialize(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static List<ColliderGroup> Deserialize_ColliderGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new List<ColliderGroup>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value.Add(Deserialize_ColliderGroups_ITEM(x));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ColliderGroup Deserialize_ColliderGroups_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderGroup();
|
||||
|
||||
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=="colliders"){
|
||||
value.Colliders = __colliderGroups_ITEM_Deserialize_Colliders(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static List<Collider> __colliderGroups_ITEM_Deserialize_Colliders(JsonNode parsed)
|
||||
{
|
||||
var value = new List<Collider>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value.Add(__colliderGroups_ITEM_Deserialize_Colliders_ITEM(x));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Collider __colliderGroups_ITEM_Deserialize_Colliders_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new Collider();
|
||||
|
||||
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=="shape"){
|
||||
value.Shape = __colliderGroups_ITEM__colliders_ITEM_Deserialize_Shape(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShape __colliderGroups_ITEM__colliders_ITEM_Deserialize_Shape(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShape();
|
||||
|
||||
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=="sphere"){
|
||||
value.Sphere = __colliderGroups_ITEM__colliders_ITEM__shape_Deserialize_Sphere(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="capsule"){
|
||||
value.Capsule = __colliderGroups_ITEM__colliders_ITEM__shape_Deserialize_Capsule(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShapeSphere __colliderGroups_ITEM__colliders_ITEM__shape_Deserialize_Sphere(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeSphere();
|
||||
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
|
||||
if(key=="offset"){
|
||||
value.Offset = __colliderGroups_ITEM__colliders_ITEM__shape__sphere_Deserialize_Offset(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="radius"){
|
||||
value.Radius = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] __colliderGroups_ITEM__colliders_ITEM__shape__sphere_Deserialize_Offset(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 ColliderShapeCapsule __colliderGroups_ITEM__colliders_ITEM__shape_Deserialize_Capsule(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeCapsule();
|
||||
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
|
||||
if(key=="offset"){
|
||||
value.Offset = __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Deserialize_Offset(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="radius"){
|
||||
value.Radius = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="tail"){
|
||||
value.Tail = __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Deserialize_Tail(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Deserialize_Offset(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[] __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Deserialize_Tail(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 List<Spring> Deserialize_Springs(JsonNode parsed)
|
||||
{
|
||||
var value = new List<Spring>();
|
||||
@@ -89,12 +287,12 @@ public static Spring Deserialize_Springs_ITEM(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="joints"){
|
||||
value.Joints = Deserialize_Joints(kv.Value);
|
||||
value.Joints = __springs_ITEM_Deserialize_Joints(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="colliders"){
|
||||
value.Colliders = Deserialize_Colliders(kv.Value);
|
||||
if(key=="colliderGroups"){
|
||||
value.ColliderGroups = __springs_ITEM_Deserialize_ColliderGroups(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -102,17 +300,17 @@ public static Spring Deserialize_Springs_ITEM(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static List<SpringBoneJoint> Deserialize_Joints(JsonNode parsed)
|
||||
public static List<SpringBoneJoint> __springs_ITEM_Deserialize_Joints(JsonNode parsed)
|
||||
{
|
||||
var value = new List<SpringBoneJoint>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
{
|
||||
value.Add(Deserialize_Joints_ITEM(x));
|
||||
value.Add(__springs_ITEM_Deserialize_Joints_ITEM(x));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static SpringBoneJoint Deserialize_Joints_ITEM(JsonNode parsed)
|
||||
public static SpringBoneJoint __springs_ITEM_Deserialize_Joints_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new SpringBoneJoint();
|
||||
|
||||
@@ -151,7 +349,7 @@ public static SpringBoneJoint Deserialize_Joints_ITEM(JsonNode parsed)
|
||||
}
|
||||
|
||||
if(key=="gravityDir"){
|
||||
value.GravityDir = Deserialize_GravityDir(kv.Value);
|
||||
value.GravityDir = __springs_ITEM__joints_ITEM_Deserialize_GravityDir(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -164,7 +362,7 @@ public static SpringBoneJoint Deserialize_Joints_ITEM(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_GravityDir(JsonNode parsed)
|
||||
public static float[] __springs_ITEM__joints_ITEM_Deserialize_GravityDir(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
@@ -175,7 +373,7 @@ public static float[] Deserialize_GravityDir(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int[] Deserialize_Colliders(JsonNode parsed)
|
||||
public static int[] __springs_ITEM_Deserialize_ColliderGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new int[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
||||
@@ -7,6 +7,65 @@ using UniJSON;
|
||||
namespace UniGLTF.Extensions.VRMC_springBone
|
||||
{
|
||||
|
||||
public class ColliderShapeSphere
|
||||
{
|
||||
// The sphere center. vector3
|
||||
public float[] Offset;
|
||||
|
||||
// The sphere radius
|
||||
public float? Radius;
|
||||
}
|
||||
|
||||
public class ColliderShapeCapsule
|
||||
{
|
||||
// The capsule head. vector3
|
||||
public float[] Offset;
|
||||
|
||||
// The capsule radius
|
||||
public float? Radius;
|
||||
|
||||
// The capsule tail. vector3
|
||||
public float[] Tail;
|
||||
}
|
||||
|
||||
public class ColliderShape
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public glTFExtension Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
public ColliderShapeSphere Sphere;
|
||||
|
||||
public ColliderShapeCapsule Capsule;
|
||||
}
|
||||
|
||||
public class Collider
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public glTFExtension Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
// The node index.
|
||||
public int? Node;
|
||||
|
||||
public ColliderShape Shape;
|
||||
}
|
||||
|
||||
public class ColliderGroup
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public glTFExtension Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
public List<Collider> Colliders;
|
||||
}
|
||||
|
||||
public class SpringBoneJoint
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
@@ -48,8 +107,8 @@ namespace UniGLTF.Extensions.VRMC_springBone
|
||||
// Joints of the spring. Except for the first element, a previous joint of the array must be an ancestor of the joint.
|
||||
public List<SpringBoneJoint> Joints;
|
||||
|
||||
// Colliders that detect collision with this spring.
|
||||
public int[] Colliders;
|
||||
// Indices of ColliderGroups that detect collision with this spring.
|
||||
public int[] ColliderGroups;
|
||||
}
|
||||
|
||||
public class VRMC_springBone
|
||||
@@ -63,6 +122,9 @@ namespace UniGLTF.Extensions.VRMC_springBone
|
||||
// Application-specific data.
|
||||
public glTFExtension Extras;
|
||||
|
||||
// An array of colliderGroups.
|
||||
public List<ColliderGroup> ColliderGroups;
|
||||
|
||||
// An array of springs.
|
||||
public List<Spring> Springs;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ public static void Serialize(JsonFormatter f, VRMC_springBone value)
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.ColliderGroups!=null&&value.ColliderGroups.Count()>=0){
|
||||
f.Key("colliderGroups");
|
||||
Serialize_ColliderGroups(f, value.ColliderGroups);
|
||||
}
|
||||
|
||||
if(value.Springs!=null&&value.Springs.Count()>=0){
|
||||
f.Key("springs");
|
||||
Serialize_Springs(f, value.Springs);
|
||||
@@ -51,6 +56,186 @@ public static void Serialize(JsonFormatter f, VRMC_springBone value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_ColliderGroups(JsonFormatter f, List<ColliderGroup> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_ColliderGroups_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_ColliderGroups_ITEM(JsonFormatter f, ColliderGroup value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
value.Extensions.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Colliders!=null&&value.Colliders.Count()>=0){
|
||||
f.Key("colliders");
|
||||
__colliderGroups_ITEM_Serialize_Colliders(f, value.Colliders);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM_Serialize_Colliders(JsonFormatter f, List<Collider> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
__colliderGroups_ITEM_Serialize_Colliders_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM_Serialize_Colliders_ITEM(JsonFormatter f, Collider value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
value.Extensions.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Node.HasValue){
|
||||
f.Key("node");
|
||||
f.Value(value.Node.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.Shape!=null){
|
||||
f.Key("shape");
|
||||
__colliderGroups_ITEM__colliders_ITEM_Serialize_Shape(f, value.Shape);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM_Serialize_Shape(JsonFormatter f, ColliderShape value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
value.Extensions.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
value.Extras.Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Sphere!=null){
|
||||
f.Key("sphere");
|
||||
__colliderGroups_ITEM__colliders_ITEM__shape_Serialize_Sphere(f, value.Sphere);
|
||||
}
|
||||
|
||||
if(value.Capsule!=null){
|
||||
f.Key("capsule");
|
||||
__colliderGroups_ITEM__colliders_ITEM__shape_Serialize_Capsule(f, value.Capsule);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM__shape_Serialize_Sphere(JsonFormatter f, ColliderShapeSphere value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Offset!=null&&value.Offset.Count()>=3){
|
||||
f.Key("offset");
|
||||
__colliderGroups_ITEM__colliders_ITEM__shape__sphere_Serialize_Offset(f, value.Offset);
|
||||
}
|
||||
|
||||
if(value.Radius.HasValue){
|
||||
f.Key("radius");
|
||||
f.Value(value.Radius.GetValueOrDefault());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM__shape__sphere_Serialize_Offset(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM__shape_Serialize_Capsule(JsonFormatter f, ColliderShapeCapsule value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Offset!=null&&value.Offset.Count()>=3){
|
||||
f.Key("offset");
|
||||
__colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Offset(f, value.Offset);
|
||||
}
|
||||
|
||||
if(value.Radius.HasValue){
|
||||
f.Key("radius");
|
||||
f.Value(value.Radius.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.Tail!=null&&value.Tail.Count()>=3){
|
||||
f.Key("tail");
|
||||
__colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Tail(f, value.Tail);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Offset(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Serialize_Tail(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Springs(JsonFormatter f, List<Spring> value)
|
||||
{
|
||||
f.BeginList();
|
||||
@@ -85,30 +270,30 @@ public static void Serialize_Springs_ITEM(JsonFormatter f, Spring value)
|
||||
|
||||
if(value.Joints!=null&&value.Joints.Count()>=0){
|
||||
f.Key("joints");
|
||||
Serialize_Joints(f, value.Joints);
|
||||
__springs_ITEM_Serialize_Joints(f, value.Joints);
|
||||
}
|
||||
|
||||
if(value.Colliders!=null&&value.Colliders.Count()>=0){
|
||||
f.Key("colliders");
|
||||
Serialize_Colliders(f, value.Colliders);
|
||||
if(value.ColliderGroups!=null&&value.ColliderGroups.Count()>=0){
|
||||
f.Key("colliderGroups");
|
||||
__springs_ITEM_Serialize_ColliderGroups(f, value.ColliderGroups);
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_Joints(JsonFormatter f, List<SpringBoneJoint> value)
|
||||
public static void __springs_ITEM_Serialize_Joints(JsonFormatter f, List<SpringBoneJoint> value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
Serialize_Joints_ITEM(f, item);
|
||||
__springs_ITEM_Serialize_Joints_ITEM(f, item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Joints_ITEM(JsonFormatter f, SpringBoneJoint value)
|
||||
public static void __springs_ITEM_Serialize_Joints_ITEM(JsonFormatter f, SpringBoneJoint value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
@@ -145,7 +330,7 @@ public static void Serialize_Joints_ITEM(JsonFormatter f, SpringBoneJoint value)
|
||||
|
||||
if(value.GravityDir!=null&&value.GravityDir.Count()>=3){
|
||||
f.Key("gravityDir");
|
||||
Serialize_GravityDir(f, value.GravityDir);
|
||||
__springs_ITEM__joints_ITEM_Serialize_GravityDir(f, value.GravityDir);
|
||||
}
|
||||
|
||||
if(value.DragForce.HasValue){
|
||||
@@ -156,7 +341,7 @@ public static void Serialize_Joints_ITEM(JsonFormatter f, SpringBoneJoint value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void Serialize_GravityDir(JsonFormatter f, float[] value)
|
||||
public static void __springs_ITEM__joints_ITEM_Serialize_GravityDir(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
@@ -168,7 +353,7 @@ public static void Serialize_GravityDir(JsonFormatter f, float[] value)
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void Serialize_Colliders(JsonFormatter f, int[] value)
|
||||
public static void __springs_ITEM_Serialize_ColliderGroups(JsonFormatter f, int[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -293,12 +293,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
|
||||
|
||||
// How the camera interprets the mesh.
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
public FirstPersonType FirstPersonType;
|
||||
public FirstPersonType Type;
|
||||
}
|
||||
|
||||
public class FirstPerson
|
||||
{
|
||||
// Mesh rendering annotation for cameras. 'required' : [ 'mesh' , 'firstPersonType' ]
|
||||
// Mesh rendering annotation for cameras.
|
||||
public List<MeshAnnotation> MeshAnnotations;
|
||||
}
|
||||
|
||||
@@ -324,19 +324,19 @@ namespace UniGLTF.Extensions.VRMC_vrm
|
||||
public float[] OffsetFromHeadBone;
|
||||
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
public LookAtType LookAtType;
|
||||
public LookAtType Type;
|
||||
|
||||
// Horizontal inward movement. The left eye moves right. The right eye moves left.
|
||||
public LookAtRangeMap LookAtHorizontalInner;
|
||||
public LookAtRangeMap RangeMapHorizontalInner;
|
||||
|
||||
// Horizontal outward movement. The left eye moves left. The right eye moves right.
|
||||
public LookAtRangeMap LookAtHorizontalOuter;
|
||||
public LookAtRangeMap RangeMapHorizontalOuter;
|
||||
|
||||
// Vertical downward movement. Both eyes move upwards
|
||||
public LookAtRangeMap LookAtVerticalDown;
|
||||
public LookAtRangeMap RangeMapVerticalDown;
|
||||
|
||||
// Vertical upward movement. Both eyes move downwards
|
||||
public LookAtRangeMap LookAtVerticalUp;
|
||||
public LookAtRangeMap RangeMapVerticalUp;
|
||||
}
|
||||
|
||||
public enum ExpressionPreset
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,6 @@ namespace UniVRM10
|
||||
Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_vrm.VRMC_vrm.ExtensionName);
|
||||
Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_materials_mtoon.VRMC_materials_mtoon.ExtensionName);
|
||||
Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_springBone.VRMC_springBone.ExtensionName);
|
||||
Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider.ExtensionName);
|
||||
Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint.ExtensionName);
|
||||
Storage.Gltf.buffers.Add(new glTFBuffer
|
||||
{
|
||||
@@ -264,14 +263,14 @@ namespace UniVRM10
|
||||
return (vrm, vrmSpringBone, thumbnailTextureIndex);
|
||||
}
|
||||
|
||||
UniGLTF.Extensions.VRMC_node_collider.ColliderShape ExportShape(VRM10SpringBoneCollider z)
|
||||
UniGLTF.Extensions.VRMC_springBone.ColliderShape ExportShape(VRM10SpringBoneCollider z)
|
||||
{
|
||||
var shape = new UniGLTF.Extensions.VRMC_node_collider.ColliderShape();
|
||||
var shape = new UniGLTF.Extensions.VRMC_springBone.ColliderShape();
|
||||
switch (z.ColliderType)
|
||||
{
|
||||
case VRM10SpringBoneColliderTypes.Sphere:
|
||||
{
|
||||
shape.Sphere = new UniGLTF.Extensions.VRMC_node_collider.ColliderShapeSphere
|
||||
shape.Sphere = new UniGLTF.Extensions.VRMC_springBone.ColliderShapeSphere
|
||||
{
|
||||
Radius = z.Radius,
|
||||
Offset = ReverseX(z.Offset),
|
||||
@@ -281,7 +280,7 @@ namespace UniVRM10
|
||||
|
||||
case VRM10SpringBoneColliderTypes.Capsule:
|
||||
{
|
||||
shape.Capsule = new UniGLTF.Extensions.VRMC_node_collider.ColliderShapeCapsule
|
||||
shape.Capsule = new UniGLTF.Extensions.VRMC_springBone.ColliderShapeCapsule
|
||||
{
|
||||
Radius = z.Radius,
|
||||
Offset = new float[] { z.Offset.x, z.Offset.y, z.Offset.z },
|
||||
@@ -311,43 +310,48 @@ namespace UniVRM10
|
||||
{
|
||||
var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
|
||||
{
|
||||
ColliderGroups = new List<UniGLTF.Extensions.VRMC_springBone.ColliderGroup>(),
|
||||
Springs = new List<UniGLTF.Extensions.VRMC_springBone.Spring>(),
|
||||
};
|
||||
|
||||
Func<Transform, int> getIndexFromTransform = t =>
|
||||
Func<Transform, int> getNodeIndexFromTransform = t =>
|
||||
{
|
||||
var node = converter.Nodes[t.gameObject];
|
||||
return model.Nodes.IndexOf(node);
|
||||
};
|
||||
|
||||
var colliderGroups = vrmController.GetComponentsInChildren<VRM10SpringBoneColliderGroup>();
|
||||
foreach (var x in colliderGroups)
|
||||
{
|
||||
var colliderGroup = new UniGLTF.Extensions.VRMC_springBone.ColliderGroup
|
||||
{
|
||||
Colliders = new List<UniGLTF.Extensions.VRMC_springBone.Collider>(),
|
||||
};
|
||||
springBone.ColliderGroups.Add(colliderGroup);
|
||||
|
||||
foreach (var y in x.Colliders)
|
||||
{
|
||||
if (y == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
colliderGroup.Colliders.Add(new UniGLTF.Extensions.VRMC_springBone.Collider
|
||||
{
|
||||
Node = getNodeIndexFromTransform(y.transform),
|
||||
Shape = ExportShape(y),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var x in vrmController.GetComponentsInChildren<VRM10SpringBone>())
|
||||
{
|
||||
var spring = new UniGLTF.Extensions.VRMC_springBone.Spring
|
||||
{
|
||||
Name = x.Comment,
|
||||
Joints = x.Joints.Select(y => ExportJoint(y, getIndexFromTransform)).ToList(),
|
||||
Joints = x.Joints.Select(y => ExportJoint(y, getNodeIndexFromTransform)).ToList(),
|
||||
ColliderGroups = x.ColliderGroups.Select(y => Array.IndexOf(colliderGroups, y)).ToArray(),
|
||||
};
|
||||
springBone.Springs.Add(spring);
|
||||
|
||||
List<int> colliders = new List<int>();
|
||||
foreach (var y in x.ColliderGroups)
|
||||
{
|
||||
// node
|
||||
var node = converter.Nodes[y.gameObject];
|
||||
var nodeIndex = model.Nodes.IndexOf(node);
|
||||
colliders.Add(nodeIndex);
|
||||
var gltfNode = Storage.Gltf.nodes[nodeIndex];
|
||||
|
||||
// VRMC_node_collider
|
||||
var collider = new UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider
|
||||
{
|
||||
Shapes = y.Colliders.Select(ExportShape).ToList(),
|
||||
};
|
||||
|
||||
// serialize
|
||||
UniGLTF.Extensions.VRMC_node_collider.GltfSerializer.SerializeTo(ref gltfNode.extensions, collider);
|
||||
}
|
||||
spring.Colliders = colliders.ToArray();
|
||||
}
|
||||
|
||||
return springBone;
|
||||
@@ -453,7 +457,7 @@ namespace UniVRM10
|
||||
return new UniGLTF.Extensions.VRMC_vrm.MeshAnnotation
|
||||
{
|
||||
Node = getIndex(flags.Renderer),
|
||||
FirstPersonType = flags.FirstPersonFlag,
|
||||
Type = flags.FirstPersonFlag,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -497,16 +501,16 @@ namespace UniVRM10
|
||||
|
||||
vrm.LookAt = new UniGLTF.Extensions.VRMC_vrm.LookAt
|
||||
{
|
||||
LookAtType = vrmController.LookAt.LookAtType,
|
||||
Type = vrmController.LookAt.LookAtType,
|
||||
OffsetFromHeadBone = new float[]{
|
||||
vrmController.LookAt.OffsetFromHead.x ,
|
||||
vrmController.LookAt.OffsetFromHead.y ,
|
||||
vrmController.LookAt.OffsetFromHead.z ,
|
||||
},
|
||||
LookAtHorizontalInner = ExportLookAtRangeMap(vrmController.LookAt.HorizontalInner),
|
||||
LookAtHorizontalOuter = ExportLookAtRangeMap(vrmController.LookAt.HorizontalOuter),
|
||||
LookAtVerticalDown = ExportLookAtRangeMap(vrmController.LookAt.VerticalDown),
|
||||
LookAtVerticalUp = ExportLookAtRangeMap(vrmController.LookAt.VerticalUp),
|
||||
RangeMapHorizontalInner = ExportLookAtRangeMap(vrmController.LookAt.HorizontalInner),
|
||||
RangeMapHorizontalOuter = ExportLookAtRangeMap(vrmController.LookAt.HorizontalOuter),
|
||||
RangeMapVerticalDown = ExportLookAtRangeMap(vrmController.LookAt.VerticalDown),
|
||||
RangeMapVerticalUp = ExportLookAtRangeMap(vrmController.LookAt.VerticalUp),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -334,12 +334,12 @@ namespace UniVRM10
|
||||
if (vrm.LookAt != null)
|
||||
{
|
||||
var src = vrm.LookAt;
|
||||
controller.LookAt.LookAtType = src.LookAtType;
|
||||
controller.LookAt.LookAtType = src.Type;
|
||||
controller.LookAt.OffsetFromHead = new Vector3(src.OffsetFromHeadBone[0], src.OffsetFromHeadBone[1], src.OffsetFromHeadBone[2]);
|
||||
controller.LookAt.HorizontalInner = new CurveMapper(src.LookAtHorizontalInner.InputMaxValue.Value, src.LookAtHorizontalInner.OutputScale.Value);
|
||||
controller.LookAt.HorizontalOuter = new CurveMapper(src.LookAtHorizontalOuter.InputMaxValue.Value, src.LookAtHorizontalOuter.OutputScale.Value);
|
||||
controller.LookAt.VerticalUp = new CurveMapper(src.LookAtVerticalUp.InputMaxValue.Value, src.LookAtHorizontalOuter.OutputScale.Value);
|
||||
controller.LookAt.VerticalDown = new CurveMapper(src.LookAtVerticalDown.InputMaxValue.Value, src.LookAtHorizontalOuter.OutputScale.Value);
|
||||
controller.LookAt.HorizontalInner = new CurveMapper(src.RangeMapHorizontalInner.InputMaxValue.Value, src.RangeMapHorizontalInner.OutputScale.Value);
|
||||
controller.LookAt.HorizontalOuter = new CurveMapper(src.RangeMapHorizontalOuter.InputMaxValue.Value, src.RangeMapHorizontalOuter.OutputScale.Value);
|
||||
controller.LookAt.VerticalUp = new CurveMapper(src.RangeMapVerticalUp.InputMaxValue.Value, src.RangeMapVerticalUp.OutputScale.Value);
|
||||
controller.LookAt.VerticalDown = new CurveMapper(src.RangeMapVerticalDown.InputMaxValue.Value, src.RangeMapVerticalDown.OutputScale.Value);
|
||||
}
|
||||
|
||||
// firstPerson
|
||||
@@ -351,7 +351,7 @@ namespace UniVRM10
|
||||
var node = Nodes[x.Node.Value];
|
||||
controller.FirstPerson.Renderers.Add(new RendererFirstPersonFlags
|
||||
{
|
||||
FirstPersonFlag = x.FirstPersonType,
|
||||
FirstPersonFlag = x.Type,
|
||||
Renderer = node.GetComponent<Renderer>()
|
||||
});
|
||||
}
|
||||
@@ -365,6 +365,47 @@ namespace UniVRM10
|
||||
// springs
|
||||
if (gltfVrmSpringBone.Springs != null)
|
||||
{
|
||||
var secondary = Root.transform.Find("secondary");
|
||||
if (secondary == null)
|
||||
{
|
||||
secondary = new GameObject("secondary").transform;
|
||||
secondary.SetParent(Root.transform, false);
|
||||
}
|
||||
|
||||
// colliderGroup
|
||||
var list = new List<VRM10SpringBoneColliderGroup>();
|
||||
foreach (var g in gltfVrmSpringBone.ColliderGroups)
|
||||
{
|
||||
var colliderGroup = secondary.gameObject.AddComponent<VRM10SpringBoneColliderGroup>();
|
||||
list.Add(colliderGroup);
|
||||
|
||||
foreach (var c in g.Colliders)
|
||||
{
|
||||
var node = Nodes[c.Node.Value];
|
||||
|
||||
var collider = node.gameObject.AddComponent<VRM10SpringBoneCollider>();
|
||||
colliderGroup.Colliders.Add(collider);
|
||||
|
||||
if (c.Shape.Sphere is UniGLTF.Extensions.VRMC_springBone.ColliderShapeSphere sphere)
|
||||
{
|
||||
collider.ColliderType = VRM10SpringBoneColliderTypes.Sphere;
|
||||
collider.Radius = sphere.Radius.Value;
|
||||
collider.Offset = Vector3InvertX(sphere.Offset);
|
||||
}
|
||||
else if (c.Shape.Capsule is UniGLTF.Extensions.VRMC_springBone.ColliderShapeCapsule capsule)
|
||||
{
|
||||
collider.ColliderType = VRM10SpringBoneColliderTypes.Capsule;
|
||||
collider.Radius = capsule.Radius.Value;
|
||||
collider.Offset = Vector3InvertX(capsule.Offset);
|
||||
collider.Tail = Vector3InvertX(capsule.Tail);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var gltfSpring in gltfVrmSpringBone.Springs)
|
||||
{
|
||||
if (gltfSpring.Joints == null || gltfSpring.Joints.Count == 0)
|
||||
@@ -374,6 +415,7 @@ namespace UniVRM10
|
||||
var firstJointNode = Nodes[gltfSpring.Joints.First().Node.Value];
|
||||
var springBone = firstJointNode.gameObject.AddComponent<VRM10SpringBone>();
|
||||
springBone.Comment = gltfSpring.Name;
|
||||
springBone.ColliderGroups = gltfSpring.ColliderGroups.Select(x => list[x]).ToList();
|
||||
|
||||
// joint
|
||||
foreach (var gltfJoint in gltfSpring.Joints)
|
||||
@@ -395,52 +437,6 @@ namespace UniVRM10
|
||||
springBone.Joints.Add(joint);
|
||||
}
|
||||
}
|
||||
|
||||
// collider
|
||||
springBone.ColliderGroups.AddRange(gltfSpring.Colliders.Select(colliderNode =>
|
||||
{
|
||||
if (UniGLTF.Extensions.VRMC_node_collider.GltfDeserializer.TryGet(Parser.GLTF.nodes[colliderNode].extensions,
|
||||
out UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider extension))
|
||||
{
|
||||
var node = Nodes[colliderNode];
|
||||
var colliderGroup = node.gameObject.GetComponent<VRM10SpringBoneColliderGroup>();
|
||||
if (colliderGroup == null)
|
||||
{
|
||||
colliderGroup = node.gameObject.AddComponent<VRM10SpringBoneColliderGroup>();
|
||||
colliderGroup.Colliders.AddRange(extension.Shapes.Select(x =>
|
||||
{
|
||||
if (x.Sphere != null)
|
||||
{
|
||||
return new VRM10SpringBoneCollider
|
||||
{
|
||||
ColliderType = VRM10SpringBoneColliderTypes.Sphere,
|
||||
Offset = Vector3InvertX(x.Sphere.Offset),
|
||||
Radius = x.Sphere.Radius.Value,
|
||||
};
|
||||
}
|
||||
else if (x.Capsule != null)
|
||||
{
|
||||
return new VRM10SpringBoneCollider
|
||||
{
|
||||
ColliderType = VRM10SpringBoneColliderTypes.Capsule,
|
||||
Offset = Vector3InvertX(x.Capsule.Offset),
|
||||
Radius = x.Capsule.Radius.Value,
|
||||
Tail = Vector3InvertX(x.Capsule.Tail),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}));
|
||||
}
|
||||
return colliderGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(x => x != null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace UniVRM10
|
||||
// firstPerson に同居していた LookAt は独立します
|
||||
var lookAt = new LookAt
|
||||
{
|
||||
LookAtHorizontalInner = MigrateLookAtRangeMap(vrm0["lookAtHorizontalInner"]),
|
||||
LookAtHorizontalOuter = MigrateLookAtRangeMap(vrm0["lookAtHorizontalOuter"]),
|
||||
LookAtVerticalDown = MigrateLookAtRangeMap(vrm0["lookAtVerticalDown"]),
|
||||
LookAtVerticalUp = MigrateLookAtRangeMap(vrm0["lookAtVerticalUp"]),
|
||||
LookAtType = MigrateLookAtType(vrm0["lookAtTypeName"]),
|
||||
RangeMapHorizontalInner = MigrateLookAtRangeMap(vrm0["lookAtHorizontalInner"]),
|
||||
RangeMapHorizontalOuter = MigrateLookAtRangeMap(vrm0["lookAtHorizontalOuter"]),
|
||||
RangeMapVerticalDown = MigrateLookAtRangeMap(vrm0["lookAtVerticalDown"]),
|
||||
RangeMapVerticalUp = MigrateLookAtRangeMap(vrm0["lookAtVerticalUp"]),
|
||||
Type = MigrateLookAtType(vrm0["lookAtTypeName"]),
|
||||
OffsetFromHeadBone = MigrateVector3.Migrate(vrm0["firstPersonBoneOffset"]),
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace UniVRM10
|
||||
var a = new MeshAnnotation
|
||||
{
|
||||
Node = meshIndexToRenderNodeIndex(x["mesh"].GetInt32()),
|
||||
FirstPersonType = MigrateFirstPersonType(x["firstPersonFlag"]),
|
||||
Type = MigrateFirstPersonType(x["firstPersonFlag"]),
|
||||
};
|
||||
firstPerson.MeshAnnotations.Add(a);
|
||||
}
|
||||
|
||||
@@ -23,16 +23,22 @@ namespace UniVRM10
|
||||
{
|
||||
var colliderNodes = new List<int>();
|
||||
|
||||
var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
|
||||
{
|
||||
ColliderGroups = new List<UniGLTF.Extensions.VRMC_springBone.ColliderGroup>(),
|
||||
Springs = new List<UniGLTF.Extensions.VRMC_springBone.Spring>(),
|
||||
};
|
||||
|
||||
foreach (var x in sa["colliderGroups"].ArrayItems())
|
||||
{
|
||||
var node = x["node"].GetInt32();
|
||||
colliderNodes.Add(node);
|
||||
var gltfNode = gltf.nodes[node];
|
||||
|
||||
var collider = new UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider()
|
||||
var colliderGroup = new UniGLTF.Extensions.VRMC_springBone.ColliderGroup()
|
||||
{
|
||||
Shapes = new List<UniGLTF.Extensions.VRMC_node_collider.ColliderShape>(),
|
||||
Colliders = new List<UniGLTF.Extensions.VRMC_springBone.Collider>(),
|
||||
};
|
||||
springBone.ColliderGroups.Add(colliderGroup);
|
||||
|
||||
// {
|
||||
// "node": 14,
|
||||
@@ -65,31 +71,21 @@ namespace UniVRM10
|
||||
// },
|
||||
foreach (var y in x["colliders"].ArrayItems())
|
||||
{
|
||||
collider.Shapes.Add(new UniGLTF.Extensions.VRMC_node_collider.ColliderShape
|
||||
colliderGroup.Colliders.Add(new UniGLTF.Extensions.VRMC_springBone.Collider
|
||||
{
|
||||
Sphere = new UniGLTF.Extensions.VRMC_node_collider.ColliderShapeSphere
|
||||
Node = x["node"].GetInt32(),
|
||||
Shape = new UniGLTF.Extensions.VRMC_springBone.ColliderShape
|
||||
{
|
||||
Offset = MigrateVector3.Migrate(y["offset"]),
|
||||
Radius = y["radius"].GetSingle()
|
||||
Sphere = new UniGLTF.Extensions.VRMC_springBone.ColliderShapeSphere
|
||||
{
|
||||
Offset = MigrateVector3.Migrate(y["offset"]),
|
||||
Radius = y["radius"].GetSingle()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!(gltfNode.extensions is UniGLTF.glTFExtensionExport extensions))
|
||||
{
|
||||
extensions = new UniGLTF.glTFExtensionExport();
|
||||
gltfNode.extensions = extensions;
|
||||
}
|
||||
|
||||
var f = new JsonFormatter();
|
||||
UniGLTF.Extensions.VRMC_node_collider.GltfSerializer.Serialize(f, collider);
|
||||
extensions.Add(UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider.ExtensionName, f.GetStoreBytes());
|
||||
}
|
||||
|
||||
var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
|
||||
{
|
||||
Springs = new List<UniGLTF.Extensions.VRMC_springBone.Spring>(),
|
||||
};
|
||||
foreach (var x in sa["boneGroups"].ArrayItems())
|
||||
{
|
||||
// {
|
||||
@@ -123,7 +119,7 @@ namespace UniVRM10
|
||||
var spring = new UniGLTF.Extensions.VRMC_springBone.Spring
|
||||
{
|
||||
Name = comment,
|
||||
Colliders = x["colliderGroups"].ArrayItems().Select(z => colliderNodes[z.GetInt32()]).ToArray(),
|
||||
ColliderGroups = x["colliderGroups"].ArrayItems().Select(z => z.GetInt32()).ToArray(),
|
||||
Joints = new List<UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint>(),
|
||||
};
|
||||
|
||||
|
||||
@@ -244,12 +244,11 @@ namespace UniVRM10
|
||||
parser1.Parse(AliciaPath, bytes1);
|
||||
Assert.True(UniGLTF.Extensions.VRMC_springBone.GltfDeserializer.TryGet(parser1.GLTF.extensions, out UniGLTF.Extensions.VRMC_springBone.VRMC_springBone springBone));
|
||||
var spring = springBone.Springs[0];
|
||||
var colliderNodeIndex = spring.Colliders[0];
|
||||
Assert.True(UniGLTF.Extensions.VRMC_node_collider.GltfDeserializer.TryGet(parser1.GLTF.nodes[colliderNodeIndex].extensions, out UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider colliderGroup));
|
||||
var colliderNodeIndex = spring.ColliderGroups[0];
|
||||
// x軸だけが反転する
|
||||
Assert.AreEqual(-VALUE.x, colliderGroup.Shapes[0].Sphere.Offset[0]);
|
||||
Assert.AreEqual(VALUE.y, colliderGroup.Shapes[0].Sphere.Offset[1]);
|
||||
Assert.AreEqual(VALUE.z, colliderGroup.Shapes[0].Sphere.Offset[2]);
|
||||
Assert.AreEqual(-VALUE.x, springBone.ColliderGroups[colliderIndex].Colliders[0].Shape.Sphere.Offset[0]);
|
||||
Assert.AreEqual(VALUE.y, springBone.ColliderGroups[colliderIndex].Colliders[0].Shape.Sphere.Offset[1]);
|
||||
Assert.AreEqual(VALUE.z, springBone.ColliderGroups[colliderIndex].Colliders[0].Shape.Sphere.Offset[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Submodule vrm-specification updated: a690675180...9a02cc2302
Reference in New Issue
Block a user