mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 23:18:04 -05:00
generate cs from JsonSchema
This commit is contained in:
parent
502628b768
commit
693eb982fa
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -347,7 +347,7 @@ namespace UniVRM10
|
|||
// serialize
|
||||
UniGLTF.Extensions.VRMC_node_collider.GltfSerializer.SerializeTo(ref gltfNode.extensions, collider);
|
||||
}
|
||||
spring.Colliders = colliders.ToArray();
|
||||
spring.ColliderGroups = colliders.ToArray();
|
||||
}
|
||||
|
||||
return springBone;
|
||||
|
|
@ -453,7 +453,7 @@ namespace UniVRM10
|
|||
return new UniGLTF.Extensions.VRMC_vrm.MeshAnnotation
|
||||
{
|
||||
Node = getIndex(flags.Renderer),
|
||||
FirstPersonType = flags.FirstPersonFlag,
|
||||
Type = flags.FirstPersonFlag,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -497,16 +497,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>()
|
||||
});
|
||||
}
|
||||
|
|
@ -397,7 +397,7 @@ namespace UniVRM10
|
|||
}
|
||||
|
||||
// collider
|
||||
springBone.ColliderGroups.AddRange(gltfSpring.Colliders.Select(colliderNode =>
|
||||
springBone.ColliderGroups.AddRange(gltfSpring.ColliderGroups.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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,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 => colliderNodes[z.GetInt32()]).ToArray(),
|
||||
Joints = new List<UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint>(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ 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];
|
||||
var colliderNodeIndex = spring.ColliderGroups[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));
|
||||
// x軸だけが反転する
|
||||
Assert.AreEqual(-VALUE.x, colliderGroup.Shapes[0].Sphere.Offset[0]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user