mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 06:20:01 -05:00
仕様を更新、コードを再生成
This commit is contained in:
@@ -79,6 +79,16 @@ public static Constraint Deserialize_Constraint(JsonNode parsed)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="roll"){
|
||||
value.Roll = __constraint_Deserialize_Roll(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="aim"){
|
||||
value.Aim = __constraint_Deserialize_Aim(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="rotation"){
|
||||
value.Rotation = __constraint_Deserialize_Rotation(kv.Value);
|
||||
continue;
|
||||
@@ -88,6 +98,90 @@ public static Constraint Deserialize_Constraint(JsonNode parsed)
|
||||
return value;
|
||||
}
|
||||
|
||||
public static RollConstraint __constraint_Deserialize_Roll(JsonNode parsed)
|
||||
{
|
||||
var value = new RollConstraint();
|
||||
|
||||
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=="name"){
|
||||
value.Name = kv.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="source"){
|
||||
value.Source = kv.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="rollAxis"){
|
||||
value.RollAxis = (RollAxis)Enum.Parse(typeof(RollAxis), kv.Value.GetString(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="weight"){
|
||||
value.Weight = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static AimConstraint __constraint_Deserialize_Aim(JsonNode parsed)
|
||||
{
|
||||
var value = new AimConstraint();
|
||||
|
||||
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=="name"){
|
||||
value.Name = kv.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="source"){
|
||||
value.Source = kv.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="aimAxis"){
|
||||
value.AimAxis = (AimAxis)Enum.Parse(typeof(AimAxis), kv.Value.GetString(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="weight"){
|
||||
value.Weight = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode parsed)
|
||||
{
|
||||
var value = new RotationConstraint();
|
||||
@@ -116,11 +210,6 @@ public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode pars
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="axes"){
|
||||
value.Axes = __constraint__rotation_Deserialize_Axes(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="weight"){
|
||||
value.Weight = kv.Value.GetSingle();
|
||||
continue;
|
||||
@@ -130,16 +219,5 @@ public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode pars
|
||||
return value;
|
||||
}
|
||||
|
||||
public static bool[] __constraint__rotation_Deserialize_Axes(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
|
||||
|
||||
@@ -6,6 +6,67 @@ using System.Collections.Generic;
|
||||
namespace UniGLTF.Extensions.VRMC_node_constraint
|
||||
{
|
||||
|
||||
public enum RollAxis
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
|
||||
}
|
||||
|
||||
public class RollConstraint
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public object Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public object Extras;
|
||||
|
||||
// The user-defined name of this object.
|
||||
public string Name;
|
||||
|
||||
// The index of the node constrains the node.
|
||||
public int? Source;
|
||||
|
||||
// The roll axis of the constraint.
|
||||
public RollAxis RollAxis;
|
||||
|
||||
// The weight of the constraint.
|
||||
public float? Weight;
|
||||
}
|
||||
|
||||
public enum AimAxis
|
||||
{
|
||||
PositiveX,
|
||||
NegativeX,
|
||||
PositiveY,
|
||||
NegativeY,
|
||||
PositiveZ,
|
||||
NegativeZ,
|
||||
|
||||
}
|
||||
|
||||
public class AimConstraint
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
public object Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public object Extras;
|
||||
|
||||
// The user-defined name of this object.
|
||||
public string Name;
|
||||
|
||||
// The index of the node constrains the node.
|
||||
public int? Source;
|
||||
|
||||
// The aim axis of the constraint.
|
||||
public AimAxis AimAxis;
|
||||
|
||||
// The weight of the constraint.
|
||||
public float? Weight;
|
||||
}
|
||||
|
||||
public class RotationConstraint
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
@@ -20,9 +81,6 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
|
||||
// The index of the node constrains the node.
|
||||
public int? Source;
|
||||
|
||||
// Axes be constrained by this constraint, in X-Y-Z order.
|
||||
public bool[] Axes;
|
||||
|
||||
// The weight of the constraint.
|
||||
public float? Weight;
|
||||
}
|
||||
@@ -35,6 +93,12 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
|
||||
// Application-specific data.
|
||||
public object Extras;
|
||||
|
||||
// A constraint that transfers a rotation around one axis of a source.
|
||||
public RollConstraint Roll;
|
||||
|
||||
// A constraint that makes it look at a source object.
|
||||
public AimConstraint Aim;
|
||||
|
||||
// A constraint that links the rotation with a source.
|
||||
public RotationConstraint Rotation;
|
||||
}
|
||||
@@ -52,7 +116,7 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
|
||||
// Specification version of VRMC_node_constraint
|
||||
public string SpecVersion;
|
||||
|
||||
// Contains position, rotation, or aim
|
||||
// Contains roll, aim, or rotation
|
||||
public Constraint Constraint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,16 @@ public static void Serialize_Constraint(JsonFormatter f, Constraint value)
|
||||
(value.Extras as glTFExtension).Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Roll!=null){
|
||||
f.Key("roll");
|
||||
__constraint_Serialize_Roll(f, value.Roll);
|
||||
}
|
||||
|
||||
if(value.Aim!=null){
|
||||
f.Key("aim");
|
||||
__constraint_Serialize_Aim(f, value.Aim);
|
||||
}
|
||||
|
||||
if(value.Rotation!=null){
|
||||
f.Key("rotation");
|
||||
__constraint_Serialize_Rotation(f, value.Rotation);
|
||||
@@ -79,6 +89,82 @@ public static void Serialize_Constraint(JsonFormatter f, Constraint value)
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __constraint_Serialize_Roll(JsonFormatter f, RollConstraint 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(!string.IsNullOrEmpty(value.Name)){
|
||||
f.Key("name");
|
||||
f.Value(value.Name);
|
||||
}
|
||||
|
||||
if(value.Source.HasValue){
|
||||
f.Key("source");
|
||||
f.Value(value.Source.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(true){
|
||||
f.Key("rollAxis");
|
||||
f.Value(value.RollAxis.ToString());
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
f.Key("weight");
|
||||
f.Value(value.Weight.GetValueOrDefault());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __constraint_Serialize_Aim(JsonFormatter f, AimConstraint 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(!string.IsNullOrEmpty(value.Name)){
|
||||
f.Key("name");
|
||||
f.Value(value.Name);
|
||||
}
|
||||
|
||||
if(value.Source.HasValue){
|
||||
f.Key("source");
|
||||
f.Value(value.Source.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(true){
|
||||
f.Key("aimAxis");
|
||||
f.Value(value.AimAxis.ToString());
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
f.Key("weight");
|
||||
f.Value(value.Weight.GetValueOrDefault());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationConstraint value)
|
||||
{
|
||||
f.BeginMap();
|
||||
@@ -104,11 +190,6 @@ public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationCons
|
||||
f.Value(value.Source.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.Axes!=null&&value.Axes.Count()>=3){
|
||||
f.Key("axes");
|
||||
__constraint__rotation_Serialize_Axes(f, value.Axes);
|
||||
}
|
||||
|
||||
if(value.Weight.HasValue){
|
||||
f.Key("weight");
|
||||
f.Value(value.Weight.GetValueOrDefault());
|
||||
@@ -117,17 +198,5 @@ public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationCons
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __constraint__rotation_Serialize_Axes(JsonFormatter f, bool[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
foreach(var item in value)
|
||||
{
|
||||
f.Value(item);
|
||||
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace UniVRM10
|
||||
Rotation = new UniGLTF.Extensions.VRMC_node_constraint.RotationConstraint
|
||||
{
|
||||
Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]),
|
||||
Axes = ToArray(c.Axes),
|
||||
// Axes = ToArray(c.Axes),
|
||||
Weight = c.Weight,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -666,7 +666,7 @@ namespace UniVRM10
|
||||
var r = constraint.Rotation;
|
||||
var rotationConstraint = node.gameObject.AddComponent<VRM10RotationConstraint>();
|
||||
rotationConstraint.Source = Nodes[r.Source.Value];
|
||||
rotationConstraint.Axes = ConstraintAxes(r.Axes);
|
||||
// rotationConstraint.Axes = ConstraintAxes(r.Axes);
|
||||
rotationConstraint.Weight = r.Weight.Value;
|
||||
rotationConstraint.ModelRoot = Root.transform;
|
||||
}
|
||||
|
||||
Submodule vrm-specification updated: 084c4fd3a1...e93a3a0776
Reference in New Issue
Block a user