Exemple #1
0
        public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_constraints extension)
        {
            if (src is UniGLTF.glTFExtensionImport extensions)
            {
                foreach (var kv in extensions.ObjectItems())
                {
                    if (kv.Key.GetUtf8String() == VRMC_constraints.ExtensionNameUtf8)
                    {
                        extension = Deserialize(kv.Value);
                        return(true);
                    }
                }
            }

            extension = default;
            return(false);
        }
Exemple #2
0
        public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_constraints 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_constraints.ExtensionName, f.GetStoreBytes());
        }
Exemple #3
0
        public static VRMC_constraints Deserialize(ListTreeNode <JsonValue> parsed)
        {
            var value = new VRMC_constraints();

            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 == "position")
                {
                    value.Position = Deserialize_Position(kv.Value);
                    continue;
                }

                if (key == "rotation")
                {
                    value.Rotation = Deserialize_Rotation(kv.Value);
                    continue;
                }

                if (key == "aim")
                {
                    value.Aim = Deserialize_Aim(kv.Value);
                    continue;
                }
            }
            return(value);
        }
Exemple #4
0
        public static void Serialize(JsonFormatter f, VRMC_constraints 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.Position != null)
            {
                f.Key("position");
                Serialize_Position(f, value.Position);
            }

            if (value.Rotation != null)
            {
                f.Key("rotation");
                Serialize_Rotation(f, value.Rotation);
            }

            if (value.Aim != null)
            {
                f.Key("aim");
                Serialize_Aim(f, value.Aim);
            }

            f.EndMap();
        }