public void Apply(UniHumanoid.AvatarDescription desc, List <Transform> nodes)
        {
            armStretch        = desc.armStretch;
            legStretch        = desc.legStretch;
            upperArmTwist     = desc.upperArmTwist;
            lowerArmTwist     = desc.lowerArmTwist;
            upperLegTwist     = desc.upperLegTwist;
            lowerLegTwist     = desc.lowerArmTwist;
            feetSpacing       = desc.feetSpacing;
            hasTranslationDoF = desc.hasTranslationDoF;

            foreach (var x in desc.human)
            {
                var key   = x.humanBone.FromHumanBodyBone();
                var found = humanBones.FirstOrDefault(y => y.vrmBone == key);
                if (found == null)
                {
                    found = new glTF_VRM_HumanoidBone
                    {
                        vrmBone = key
                    };
                    humanBones.Add(found);
                }
                found.node = nodes.FindIndex(y => y.name == x.boneName);

                found.useDefaultValues = x.useDefaultValues;
                found.axisLength       = x.axisLength;
                found.center           = x.center;
                found.max = x.max;
                found.min = x.min;
            }
        }
 public void HumanoidBoneTestError()
 {
     var model = new glTF_VRM_HumanoidBone()
     {
         bone = "hips", // NOTE: This field must not be null?
     };
 }
        public static string ToJson(this glTF_VRM_HumanoidBone self)
        {
            var f = new JsonFormatter();

            VRMSerializer.Serialize_vrm_humanoid_humanBones_ITEM(f, self);
            return(f.ToString());
        }
Beispiel #4
0
        public static glTF_VRM_HumanoidBone Deserialize_vrm_humanoid_humanBones_LIST(ListTreeNode <JsonValue> parsed)
        {
            var value = new glTF_VRM_HumanoidBone();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "bone")
                {
                    value.bone = kv.Value.GetString();
                    continue;
                }

                if (key == "node")
                {
                    value.node = kv.Value.GetInt32();
                    continue;
                }

                if (key == "useDefaultValues")
                {
                    value.useDefaultValues = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "min")
                {
                    value.min = Deserialize_vrm_humanoid_humanBones__min(kv.Value);
                    continue;
                }

                if (key == "max")
                {
                    value.max = Deserialize_vrm_humanoid_humanBones__max(kv.Value);
                    continue;
                }

                if (key == "center")
                {
                    value.center = Deserialize_vrm_humanoid_humanBones__center(kv.Value);
                    continue;
                }

                if (key == "axisLength")
                {
                    value.axisLength = kv.Value.GetSingle();
                    continue;
                }
            }
            return(value);
        }
        public void HumanoidBoneTest()
        {
            var model = new glTF_VRM_HumanoidBone()
            {
                bone = "hips", // NOTE: This field must not be null?
                node = 0,
            };

            var json = model.ToJson();

            Assert.AreEqual(@"{""bone"":""hips"",""node"":0,""useDefaultValues"":true}", json);
            Debug.Log(json);
        }
Beispiel #6
0
        public static void Serialize_vrm_humanoid_humanBones_ITEM(JsonFormatter f, glTF_VRM_HumanoidBone value)
        {
            f.BeginMap();


            if (!string.IsNullOrEmpty(value.bone))
            {
                f.Key("bone");
                f.Value(value.bone);
            }

            if (value.node >= 0)
            {
                f.Key("node");
                f.Value(value.node);
            }

            if (true)
            {
                f.Key("useDefaultValues");
                f.Value(value.useDefaultValues);
            }

            if (value.min != null && value.min != Vector3.zero)
            {
                f.Key("min");
                Serialize_vrm_humanoid_humanBones__min(f, value.min);
            }

            if (value.max != null && value.min != Vector3.zero)
            {
                f.Key("max");
                Serialize_vrm_humanoid_humanBones__max(f, value.max);
            }

            if (value.center != null && value.min != Vector3.zero)
            {
                f.Key("center");
                Serialize_vrm_humanoid_humanBones__center(f, value.center);
            }

            if (value.axisLength > 0)
            {
                f.Key("axisLength");
                f.Value(value.axisLength);
            }

            f.EndMap();
        }
        public void HumanoidBoneTestError()
        {
            var model = new glTF_VRM_HumanoidBone()
            {
                bone = "hips", // NOTE: This field must not be null?
            };

            var c = new JsonSchemaValidationContext("")
            {
                EnableDiagnosisForNotRequiredFields = true,
            };
            var ex = Assert.Throws <JsonSchemaValidationException>(
                () => JsonSchema.FromType <glTF_VRM_HumanoidBone>().Serialize(model, c)
                );

            Assert.AreEqual("[node.String] minimum: ! -1>=0", ex.Message);
        }
Beispiel #8
0
        public void HumanoidBoneTest()
        {
            var model = new glTF_VRM_HumanoidBone()
            {
                bone = "hips", // NOTE: This field must not be null?
            };

            var json = model.ToJson();

            Assert.AreEqual(@"{""bone"":""hips"",""node"":-1,""useDefaultValues"":true}", json);
            Debug.Log(json);

            var c = new JsonSchemaValidationContext("")
            {
                EnableDiagnosisForNotRequiredFields = true,
            };
            var json2 = JsonSchema.FromType <glTF_VRM_HumanoidBone>().Serialize(model, c);

            // NOTE: New serializer outputs values which will not be used...
            Assert.AreEqual(
                @"{""bone"":""hips"",""node"":-1,""useDefaultValues"":true,""min"":{""x"":0,""y"":0,""z"":0},""max"":{""x"":0,""y"":0,""z"":0},""center"":{""x"":0,""y"":0,""z"":0},""axisLength"":0}",
                json2);
        }