JsonSchema を更新

This commit is contained in:
ousttrue
2021-06-11 16:38:22 +09:00
parent be9220cb6c
commit c523b1c7ea
12 changed files with 1817 additions and 392 deletions

View File

@@ -47,6 +47,11 @@ public static VRMC_springBone Deserialize(JsonNode parsed)
continue;
}
if(key=="colliders"){
value.Colliders = Deserialize_Colliders(kv.Value);
continue;
}
if(key=="colliderGroups"){
value.ColliderGroups = Deserialize_ColliderGroups(kv.Value);
continue;
@@ -61,6 +66,162 @@ public static VRMC_springBone Deserialize(JsonNode parsed)
return value;
}
public static List<Collider> Deserialize_Colliders(JsonNode parsed)
{
var value = new List<Collider>();
foreach(var x in parsed.ArrayItems())
{
value.Add(Deserialize_Colliders_ITEM(x));
}
return value;
}
public static Collider 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 = __colliders_ITEM_Deserialize_Shape(kv.Value);
continue;
}
}
return value;
}
public static ColliderShape __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 = __colliders_ITEM__shape_Deserialize_Sphere(kv.Value);
continue;
}
if(key=="capsule"){
value.Capsule = __colliders_ITEM__shape_Deserialize_Capsule(kv.Value);
continue;
}
}
return value;
}
public static ColliderShapeSphere __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 = __colliders_ITEM__shape__sphere_Deserialize_Offset(kv.Value);
continue;
}
if(key=="radius"){
value.Radius = kv.Value.GetSingle();
continue;
}
}
return value;
}
public static float[] __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 __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 = __colliders_ITEM__shape__capsule_Deserialize_Offset(kv.Value);
continue;
}
if(key=="radius"){
value.Radius = kv.Value.GetSingle();
continue;
}
if(key=="tail"){
value.Tail = __colliders_ITEM__shape__capsule_Deserialize_Tail(kv.Value);
continue;
}
}
return value;
}
public static float[] __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[] __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<ColliderGroup> Deserialize_ColliderGroups(JsonNode parsed)
{
var value = new List<ColliderGroup>();
@@ -89,6 +250,11 @@ public static ColliderGroup Deserialize_ColliderGroups_ITEM(JsonNode parsed)
continue;
}
if(key=="name"){
value.Name = kv.Value.GetString();
continue;
}
if(key=="colliders"){
value.Colliders = __colliderGroups_ITEM_Deserialize_Colliders(kv.Value);
continue;
@@ -98,158 +264,13 @@ public static ColliderGroup Deserialize_ColliderGroups_ITEM(JsonNode parsed)
return value;
}
public static List<Collider> __colliderGroups_ITEM_Deserialize_Colliders(JsonNode parsed)
public static int[] __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()];
var value = new int[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();
value[i++] = x.GetInt32();
}
return value;
}

View File

@@ -62,7 +62,11 @@ namespace UniGLTF.Extensions.VRMC_springBone
// Application-specific data.
public object Extras;
public List<Collider> Colliders;
// Name of the ColliderGroup
public string Name;
// An array of colliders.
public int[] Colliders;
}
public class SpringBoneJoint
@@ -120,6 +124,9 @@ namespace UniGLTF.Extensions.VRMC_springBone
// Application-specific data.
public object Extras;
// An array of colliders.
public List<Collider> Colliders;
// An array of colliderGroups.
public List<ColliderGroup> ColliderGroups;

View File

@@ -43,6 +43,11 @@ public static void Serialize(JsonFormatter f, VRMC_springBone value)
(value.Extras as glTFExtension).Serialize(f);
}
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");
Serialize_ColliderGroups(f, value.ColliderGroups);
@@ -56,6 +61,151 @@ public static void Serialize(JsonFormatter f, VRMC_springBone value)
f.EndMap();
}
public static void Serialize_Colliders(JsonFormatter f, List<Collider> value)
{
f.BeginList();
foreach(var item in value)
{
Serialize_Colliders_ITEM(f, item);
}
f.EndList();
}
public static void Serialize_Colliders_ITEM(JsonFormatter f, Collider value)
{
f.BeginMap();
if(value.Extensions!=null){
f.Key("extensions");
(value.Extensions as glTFExtension).Serialize(f);
}
if(value.Extras!=null){
f.Key("extras");
(value.Extras as glTFExtension).Serialize(f);
}
if(value.Node.HasValue){
f.Key("node");
f.Value(value.Node.GetValueOrDefault());
}
if(value.Shape!=null){
f.Key("shape");
__colliders_ITEM_Serialize_Shape(f, value.Shape);
}
f.EndMap();
}
public static void __colliders_ITEM_Serialize_Shape(JsonFormatter f, ColliderShape value)
{
f.BeginMap();
if(value.Extensions!=null){
f.Key("extensions");
(value.Extensions as glTFExtension).Serialize(f);
}
if(value.Extras!=null){
f.Key("extras");
(value.Extras as glTFExtension).Serialize(f);
}
if(value.Sphere!=null){
f.Key("sphere");
__colliders_ITEM__shape_Serialize_Sphere(f, value.Sphere);
}
if(value.Capsule!=null){
f.Key("capsule");
__colliders_ITEM__shape_Serialize_Capsule(f, value.Capsule);
}
f.EndMap();
}
public static void __colliders_ITEM__shape_Serialize_Sphere(JsonFormatter f, ColliderShapeSphere value)
{
f.BeginMap();
if(value.Offset!=null&&value.Offset.Count()>=3){
f.Key("offset");
__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 __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 __colliders_ITEM__shape_Serialize_Capsule(JsonFormatter f, ColliderShapeCapsule value)
{
f.BeginMap();
if(value.Offset!=null&&value.Offset.Count()>=3){
f.Key("offset");
__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");
__colliders_ITEM__shape__capsule_Serialize_Tail(f, value.Tail);
}
f.EndMap();
}
public static void __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 __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_ColliderGroups(JsonFormatter f, List<ColliderGroup> value)
{
f.BeginList();
@@ -83,7 +233,12 @@ public static void Serialize_ColliderGroups_ITEM(JsonFormatter f, ColliderGroup
(value.Extras as glTFExtension).Serialize(f);
}
if(value.Colliders!=null&&value.Colliders.Count()>=0){
if(!string.IsNullOrEmpty(value.Name)){
f.Key("name");
f.Value(value.Name);
}
if(value.Colliders!=null&&value.Colliders.Count()>=1){
f.Key("colliders");
__colliderGroups_ITEM_Serialize_Colliders(f, value.Colliders);
}
@@ -91,140 +246,7 @@ public static void Serialize_ColliderGroups_ITEM(JsonFormatter f, ColliderGroup
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 as glTFExtension).Serialize(f);
}
if(value.Extras!=null){
f.Key("extras");
(value.Extras as glTFExtension).Serialize(f);
}
if(value.Node.HasValue){
f.Key("node");
f.Value(value.Node.GetValueOrDefault());
}
if(value.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 as glTFExtension).Serialize(f);
}
if(value.Extras!=null){
f.Key("extras");
(value.Extras as glTFExtension).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)
public static void __colliderGroups_ITEM_Serialize_Colliders(JsonFormatter f, int[] value)
{
f.BeginList();

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@ namespace UniGLTF.Extensions.VRMC_vrm
public enum AvatarPermissionType
{
onlyAuthor,
explicitlyLicensedPerson,
onlySeparatelyLicensedPerson,
everyone,
}
@@ -26,20 +26,25 @@ namespace UniGLTF.Extensions.VRMC_vrm
{
required,
unnecessary,
abandoned,
}
public enum ModificationType
{
prohibited,
inherited,
notInherited,
allowModification,
allowModificationRedistribution,
}
public class Meta
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// The name of the model
public string Name;
@@ -61,31 +66,34 @@ namespace UniGLTF.Extensions.VRMC_vrm
// Third party licenses of the model, if required. You can use line breaks
public string ThirdPartyLicenses;
// The index to access the thumbnail image of the avatar model in gltf.images. The texture resolution of 1024x1024 is recommended. It must be square. Preferable resolution is 1024 x 1024. This is for the application to use as an icon.
// The index to the thumbnail image of the model in gltf.images
public int? ThumbnailImage;
// A person who can perform with this avatars
// A person who can perform as an avatar with this model
public AvatarPermissionType AvatarPermission;
// A flag that permits to use this avatar in excessively violent contents
// A flag that permits to use this model in excessively violent contents
public bool? AllowExcessivelyViolentUsage;
// A flag that permits to use this avatar in excessively sexual contents
// A flag that permits to use this model in excessively sexual contents
public bool? AllowExcessivelySexualUsage;
// An option that permits to use this avatar in commercial products
// An option that permits to use this model in commercial products
public CommercialUsageType CommercialUsage;
// A flag that permits to use this avatar in political or religious contents
// A flag that permits to use this model in political or religious contents
public bool? AllowPoliticalOrReligiousUsage;
// An option that forces or abandons to display the credit of this avatar
// A flag that permits to use this model in contents contain anti-social activities or hate speeches
public bool? AllowAntisocialOrHateUsage;
// An option that forces or abandons to display the credit of this model
public CreditNotationType CreditNotation;
// A flag that permits to redistribute this avatar
// A flag that permits to redistribute this model
public bool? AllowRedistribution;
// An option that controls the condition to modify this avatar
// An option that controls the condition to modify this model
public ModificationType Modification;
// Describe the URL links of other license
@@ -94,6 +102,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class HumanBone
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// Represents a single glTF node tied to this humanBone.
public int? Node;
}
@@ -268,6 +282,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class Humanoid
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// Represents a set of humanBones of a humanoid.
public HumanBones HumanBones;
}
@@ -283,6 +303,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class MeshAnnotation
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// The index of the node that attached to target mesh.
public int? Node;
@@ -292,6 +318,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class FirstPerson
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// Mesh rendering annotation for cameras.
public List<MeshAnnotation> MeshAnnotations;
}
@@ -305,6 +337,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class LookAtRangeMap
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// Yaw and pitch angles ( degrees ) between the head bone forward vector and the eye gaze LookAt vector
public float? InputMaxValue;
@@ -314,6 +352,12 @@ namespace UniGLTF.Extensions.VRMC_vrm
public class LookAt
{
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// The origin of LookAt. Position offset from the head bone
public float[] OffsetFromHeadBone;
@@ -467,9 +511,16 @@ namespace UniGLTF.Extensions.VRMC_vrm
{
public const string ExtensionName = "VRMC_vrm";
// Dictionary object with extension-specific objects.
public object Extensions;
// Application-specific data.
public object Extras;
// Specification version of the VRM
public string SpecVersion;
// Meta informations of the VRM model
public Meta Meta;
// Correspondence between nodes and human bones

File diff suppressed because it is too large Load Diff

View File

@@ -263,7 +263,7 @@ namespace UniVRM10
ExportLookAt(vrm, vrmController);
ExportFirstPerson(vrm, vrmController, model, converter);
vrmSpringBone = ExportSpringBone(vrmController.SpringBone, model, converter);
vrmSpringBone = ExportSpringBone(vrmController, model, converter);
ExportConstraints(vrmController, model, converter);
}
@@ -313,49 +313,49 @@ namespace UniVRM10
return joint;
}
UniGLTF.Extensions.VRMC_springBone.VRMC_springBone ExportSpringBone(VRM10ControllerSpringBone src, Model model, ModelExporter converter)
UniGLTF.Extensions.VRMC_springBone.VRMC_springBone ExportSpringBone(VRM10Controller controller, Model model, ModelExporter converter)
{
var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
{
Colliders = new List<UniGLTF.Extensions.VRMC_springBone.Collider>(),
ColliderGroups = new List<UniGLTF.Extensions.VRMC_springBone.ColliderGroup>(),
Springs = new List<UniGLTF.Extensions.VRMC_springBone.Spring>(),
};
// colliders
Func<Transform, int> getNodeIndexFromTransform = t =>
{
var node = converter.Nodes[t.gameObject];
return model.Nodes.IndexOf(node);
};
foreach (var x in src.ColliderGroups)
var colliders = controller.GetComponentsInChildren<VRM10SpringBoneCollider>();
foreach (var c in colliders)
{
var colliderGroup = new UniGLTF.Extensions.VRMC_springBone.ColliderGroup
springBone.Colliders.Add(new UniGLTF.Extensions.VRMC_springBone.Collider
{
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),
});
}
Node = getNodeIndexFromTransform(c.transform),
Shape = ExportShape(c),
});
}
foreach (var x in src.Springs)
// colliderGroups
foreach (var x in controller.SpringBone.ColliderGroups)
{
springBone.ColliderGroups.Add(new UniGLTF.Extensions.VRMC_springBone.ColliderGroup
{
Colliders = x.Colliders.Select(y => Array.IndexOf(colliders, y)).ToArray(),
});
}
// springs
foreach (var x in controller.SpringBone.Springs)
{
var spring = new UniGLTF.Extensions.VRMC_springBone.Spring
{
Name = x.Name,
Joints = x.Joints.Select(y => ExportJoint(y, getNodeIndexFromTransform)).ToList(),
ColliderGroups = x.ColliderGroups.Select(y => src.ColliderGroups.IndexOf(y)).ToArray(),
ColliderGroups = x.ColliderGroups.Select(y => controller.SpringBone.ColliderGroups.IndexOf(y)).ToArray(),
};
springBone.Springs.Add(spring);
}

View File

@@ -387,9 +387,33 @@ namespace UniVRM10
{
await awaitCaller.NextFrame();
// springs
if (gltfVrmSpringBone.Springs != null)
// colliders
var colliders = new List<VRM10SpringBoneCollider>();
if (gltfVrmSpringBone.Colliders != null)
{
foreach (var c in gltfVrmSpringBone.Colliders)
{
var collider = Nodes[c.Node.Value].gameObject.AddComponent<VRM10SpringBoneCollider>();
colliders.Add(collider);
if (c.Shape.Capsule is UniGLTF.Extensions.VRMC_springBone.ColliderShapeCapsule capsule)
{
collider.ColliderType = VRM10SpringBoneColliderTypes.Capsule;
collider.Offset = Vector3InvertX(capsule.Offset);
collider.Tail = Vector3InvertX(capsule.Tail);
collider.Radius = capsule.Radius.Value;
}
else if (c.Shape.Sphere is UniGLTF.Extensions.VRMC_springBone.ColliderShapeSphere sphere)
{
collider.ColliderType = VRM10SpringBoneColliderTypes.Sphere;
collider.Offset = Vector3InvertX(sphere.Offset);
collider.Radius = sphere.Radius.Value;
}
else
{
throw new Vrm10Exception();
}
}
var secondary = Root.transform.Find("secondary");
if (secondary == null)
{
@@ -407,66 +431,48 @@ namespace UniVRM10
foreach (var c in g.Colliders)
{
var node = Nodes[c.Node.Value];
var collider = node.gameObject.AddComponent<VRM10SpringBoneCollider>();
var collider = colliders[c];
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();
}
}
}
}
}
if (gltfVrmSpringBone.Springs != null)
// springs
if (gltfVrmSpringBone.Springs != null)
{
// spring
foreach (var gltfSpring in gltfVrmSpringBone.Springs)
{
foreach (var gltfSpring in gltfVrmSpringBone.Springs)
if (gltfSpring.Joints == null || gltfSpring.Joints.Count == 0)
{
if (gltfSpring.Joints == null || gltfSpring.Joints.Count == 0)
{
continue;
}
var spring = new VRM10ControllerSpringBone.Spring(gltfSpring.Name);
controller.SpringBone.Springs.Add(spring);
continue;
}
var spring = new VRM10ControllerSpringBone.Spring(gltfSpring.Name);
controller.SpringBone.Springs.Add(spring);
if (gltfSpring.ColliderGroups != null)
if (gltfSpring.ColliderGroups != null)
{
spring.ColliderGroups = gltfSpring.ColliderGroups.Select(x => controller.SpringBone.ColliderGroups[x]).ToList();
}
// joint
foreach (var gltfJoint in gltfSpring.Joints)
{
if (gltfJoint.Node.HasValue)
{
spring.ColliderGroups = gltfSpring.ColliderGroups.Select(x => controller.SpringBone.ColliderGroups[x]).ToList();
}
// joint
foreach (var gltfJoint in gltfSpring.Joints)
{
if (gltfJoint.Node.HasValue)
var index = gltfJoint.Node.Value;
if (index < 0 || index >= Nodes.Count)
{
var index = gltfJoint.Node.Value;
if (index < 0 || index >= Nodes.Count)
{
throw new IndexOutOfRangeException($"{index} > {Nodes.Count}");
}
var joint = Nodes[gltfJoint.Node.Value].gameObject.AddComponent<VRM10SpringBoneJoint>();
joint.m_jointRadius = gltfJoint.HitRadius.Value;
joint.m_dragForce = gltfJoint.DragForce.Value;
joint.m_gravityDir = Vector3InvertX(gltfJoint.GravityDir);
joint.m_gravityPower = gltfJoint.GravityPower.Value;
joint.m_stiffnessForce = gltfJoint.Stiffness.Value;
// joint.m_exclude = gltfJoint.Exclude.GetValueOrDefault();
spring.Joints.Add(joint);
throw new IndexOutOfRangeException($"{index} > {Nodes.Count}");
}
var joint = Nodes[gltfJoint.Node.Value].gameObject.AddComponent<VRM10SpringBoneJoint>();
joint.m_jointRadius = gltfJoint.HitRadius.Value;
joint.m_dragForce = gltfJoint.DragForce.Value;
joint.m_gravityDir = Vector3InvertX(gltfJoint.GravityDir);
joint.m_gravityPower = gltfJoint.GravityPower.Value;
joint.m_stiffnessForce = gltfJoint.Stiffness.Value;
// joint.m_exclude = gltfJoint.Exclude.GetValueOrDefault();
spring.Joints.Add(joint);
}
}
}

View File

@@ -65,7 +65,7 @@ namespace UniVRM10
meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor;
break;
case "ExplicitlyLicensedPerson":
meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.explicitlyLicensedPerson;
meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlySeparatelyLicensedPerson;
break;
case "Everyone":
meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone;

View File

@@ -49,27 +49,28 @@ namespace UniVRM10
last.children = new[] { tail_index };
}
/// <summary>
/// {
/// "colliderGroups": [
/// ],
/// "boneGroups": [
/// ],
/// }
/// </summary>
/// <param name="gltf"></param>
/// <param name="sa"></param>
/// <returns></returns>
public static UniGLTF.Extensions.VRMC_springBone.VRMC_springBone Migrate(UniGLTF.glTF gltf, JsonNode sa)
{
var colliderNodes = new List<int>();
var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
{
Colliders = new List<UniGLTF.Extensions.VRMC_springBone.Collider>(),
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 colliderGroup = new UniGLTF.Extensions.VRMC_springBone.ColliderGroup()
{
Colliders = new List<UniGLTF.Extensions.VRMC_springBone.Collider>(),
};
springBone.ColliderGroups.Add(colliderGroup);
// {
// "node": 14,
// "colliders": [
@@ -99,9 +100,11 @@ namespace UniVRM10
// }
// ]
// },
var colliders = new List<int>();
foreach (var y in x["colliders"].ArrayItems())
{
colliderGroup.Colliders.Add(new UniGLTF.Extensions.VRMC_springBone.Collider
colliders.Add(springBone.Colliders.Count);
springBone.Colliders.Add(new UniGLTF.Extensions.VRMC_springBone.Collider
{
Node = x["node"].GetInt32(),
Shape = new UniGLTF.Extensions.VRMC_springBone.ColliderShape
@@ -114,6 +117,11 @@ namespace UniVRM10
}
});
}
var colliderGroup = new UniGLTF.Extensions.VRMC_springBone.ColliderGroup()
{
Colliders = colliders.ToArray(),
};
springBone.ColliderGroups.Add(colliderGroup);
}
// https://github.com/vrm-c/vrm-specification/pull/255

View File

@@ -228,10 +228,10 @@ namespace UniVRM10
var bytes0 = File.ReadAllBytes(AliciaPath);
parser0.Parse(AliciaPath, bytes0);
var json0 = parser0.Json.ParseAsJson();
var colliderIndex = json0["extensions"]["VRM"]["secondaryAnimation"]["boneGroups"][0]["colliderGroups"][0].GetInt32();
var x = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][colliderIndex]["colliders"][0]["offset"]["x"].GetSingle();
var y = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][colliderIndex]["colliders"][0]["offset"]["y"].GetSingle();
var z = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][colliderIndex]["colliders"][0]["offset"]["z"].GetSingle();
var groupIndex = json0["extensions"]["VRM"]["secondaryAnimation"]["boneGroups"][0]["colliderGroups"][0].GetInt32();
var x = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][groupIndex]["colliders"][0]["offset"]["x"].GetSingle();
var y = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][groupIndex]["colliders"][0]["offset"]["y"].GetSingle();
var z = json0["extensions"]["VRM"]["secondaryAnimation"]["colliderGroups"][groupIndex]["colliders"][0]["offset"]["z"].GetSingle();
Assert.AreEqual(VALUE.x, x);
Assert.AreEqual(VALUE.y, y);
Assert.AreEqual(VALUE.z, z);
@@ -244,11 +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.ColliderGroups[0];
// var colliderNodeIndex = spring.ColliderGroups[0];
// x軸だけが反転する
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]);
Assert.AreEqual(-VALUE.x, springBone.Colliders[groupIndex].Shape.Sphere.Offset[0]);
Assert.AreEqual(VALUE.y, springBone.Colliders[groupIndex].Shape.Sphere.Offset[1]);
Assert.AreEqual(VALUE.z, springBone.Colliders[groupIndex].Shape.Sphere.Offset[2]);
}
}
}