Exemplo n.º 1
3
        public object FromJson(JsonNode node)
        {
            if (node.Type == JsonType.Number)
            {
                return Enum.ToObject(type, (int)node);
            }

            return Enum.Parse(type, node, ignoreCase: true);
        }
Exemplo n.º 2
3
		private void CreateBlocks(JsonNode root)
		{
			width = root.Get<int>("width");
			height = root.Get<int>("height");
			Blocks = new BlockType[width,height];
			var blocksData = root["layers"][0]["data"].GetIntArray();
			for (int y = 0; y < height; y++)
				for (int x = 0; x < width; x++)
					Blocks[x, y] = (BlockType)blocksData[x + y * width];
		}
Exemplo n.º 3
2
 private static void FormatNode(IFormatterOutput output, JsonNode node, int level)
 {
     switch (node.NodeType)
     {
         case NodeType.String:
             OutputString(output, node.AsString());
             break;
         case NodeType.Integer:
             output.Write(Convert.ToString(node.AsLongInteger()));
             break;
         case NodeType.Float:
             output.Write(Convert.ToString(node.AsFloat()));
             break;
         case NodeType.Boolean:
             output.Write(Convert.ToString(node.AsBoolean()));
             break;
         case NodeType.List:
             output.Write('[');
             for (int i = 0; i < node.Count; i++)
             {
                 if (i != 0)
                     output.Write(',');
                 output.WriteNewline();
                 output.WriteIndentation(level + 1);
                 FormatNode(output, node[i], level + 1);
             }
             if (node.Count > 0)
             {
                 output.WriteNewline();
                 output.WriteIndentation(level);
             }
             output.Write(']');
             break;
         case NodeType.Dictionary:
             output.Write('{');
             bool first = true;
             foreach (string key in node.Keys)
             {
                 if (!first)
                     output.Write(',');
                 output.WriteNewline();
                 output.WriteIndentation(level + 1);
                 OutputString(output, key);
                 output.Write(':');
                 FormatNode(output, node[key], level + 1);
                 first = false;
             }
             if (node.Keys.Count > 0)
             {
                 output.WriteNewline();
                 output.WriteIndentation(level);
             }
             output.Write('}');
             break;
     }
 }
Exemplo n.º 4
1
		public Map(JsonNode root)
		{
			CreateBlocks(root);
			CreateActors(root);
			CreateBackgroundGraphics();
			scoreText = new FontText(ContentLoader.Load<Font>("Verdana12"), "Score: 0", ScoreDrawArea);
		}
Exemplo n.º 5
1
		public void ParseBooleansStringsAndNumbers()
		{
			var json = new JsonNode("{ \"Flag\": true, \"SomeNumber\": 1.23, \"Text\": \"blub\" }");
			Assert.AreEqual(3, json.NumberOfNodes);
			Assert.IsTrue(json.Get<bool>("Flag"));
			Assert.AreEqual(1.23f, json.Get<float>("SomeNumber"));
			Assert.AreEqual("blub", json.GetOrDefault("Text", ""));
		}
Exemplo n.º 6
1
		protected override void LoadData(Stream fileData)
		{
			using (var stream = new StreamReader(fileData))
			{
				var text = stream.ReadToEnd();
				Data = new JsonNode(text);
			}
		}
Exemplo n.º 7
0
		public void ExtractSomeDataValue()
		{
			var json = new JsonNode("{ \"SomeData\":6 }");
			Assert.AreEqual(1, json.NumberOfNodes);
			Assert.AreEqual(6, json.Get<int>("SomeData"));
			Assert.Throws<JsonNode.NodeNotFound>(() => json.Get<int>("blah"));
		}
Exemplo n.º 8
0
		public void ReadJsonWithChildrenNodes()
		{
			var json = new JsonNode("{ \"Child1\": { \"Number\":1 }, \"Child2\": { \"Number\":2 } }");
			Assert.AreEqual(2, json.NumberOfNodes);
			Assert.AreEqual(1, json["Child1"].Get<int>("Number"));
			Assert.AreEqual(2, json["Child2"].Get<int>("Number"));
		}
Exemplo n.º 9
0
 public Schema(byte[] data, SchemaManager schemaManager)
 {
     m_schemaManager = schemaManager;
       m_jsonNode = (JsonNode)JsonObject.Load(data);
       m_root = new SchemaObject(m_jsonNode, this);
       m_name = m_root.Id;
 }
Exemplo n.º 10
0
 public TemplateCommand(JsonNode jsonNode, Template template)
 {
     m_jsonNode = jsonNode;
       m_template = template;
       m_type = jsonNode.GetObjectOrDefault("type", TemplateCommandType.Undefined);
       m_pathSeperator = jsonNode.GetObjectOrDefault<char?>("pathSeparator", null);
 }
Exemplo n.º 11
0
		public void ReadJsonArray()
		{
			var json = new JsonNode("{ \"layers\":[ { \"sky\":[1, 1] }, { \"ground\":[0, 0] } ] }");
			Assert.AreEqual(1, json.NumberOfNodes);
			var layers = json["layers"];
			Assert.AreEqual(2, layers.NumberOfNodes);
			Assert.AreEqual(new[] { 1, 1 }, layers[0]["sky"].GetIntArray());
			Assert.AreEqual(new[] { 0, 0 }, layers[1]["ground"].GetIntArray());
		}
Exemplo n.º 12
0
		private void CreateActor(JsonNode entityData)
		{
			JsonNode properties = entityData["properties"];
			var position = new Vector2D(entityData.Get<int>("x"), entityData.Get<int>("y"));
			var type = entityData.Get<string>("type");
			actorList.Add(new Actor(this, position, type)
			{
				MaxVelocityX = Meter * properties.GetOrDefault("maxdx", DefaultMaxVelocityX),
				WantsToGoLeft = properties.GetOrDefault("left", false),
				WantsToGoRight = properties.GetOrDefault("right", false)
			});
		}
Exemplo n.º 13
0
        public void WriteNode(JsonNode node)
        {
            switch (node.Type)
            {
                case JsonType.Array    : WriteArray((IEnumerable<JsonNode>)node); break;
                case JsonType.Object   : WriteObject((JsonObject)node); break;

                // Primitives
                case JsonType.Binary   : WriteBinary((XBinary)node);    break;
                case JsonType.Boolean  : WriteBoolean((bool)node);      break;
                case JsonType.Date     : WriteDate((XDate)node);        break;
                case JsonType.Null     : WriteNull();                   break;
                case JsonType.Number   : WriteNumber((JsonNumber)node); break;
                case JsonType.String   : WriteString(node);             break;
            }
        }
Exemplo n.º 14
0
 public TemplateParameter(JsonNode jsonNode, Template template)
 {
     m_name = jsonNode.GetObjectOrDefault("name", "unknown");
       m_type = jsonNode.GetObjectOrDefault("type", TemplateParameterType.Undefined);
       m_value = jsonNode.GetObjectOrDefault("default", "");
       template.AddParameters(ref m_value, null, null);
       m_isEditable = !jsonNode.GetObjectOrDefault("isreadonly", false);
       m_description = jsonNode.GetObjectOrDefault<string>("description", null);
       m_key = jsonNode.GetObjectOrDefault<string>("key", null);
       string pathSeparator = jsonNode.GetObjectOrDefault("pathseparator", "\\");
       m_pathSeparator = pathSeparator.Length > 0 ? pathSeparator[0] : '\\';
       if (m_type == TemplateParameterType.File)
       {
     if (string.IsNullOrEmpty(m_value))
       m_value = template.TargetPath;
     m_value = m_value.Replace('\\', m_pathSeparator);
       }
 }
Exemplo n.º 15
0
 public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm1)
 {
     Migration.CheckMeta(vrm0["meta"], vrm1.Meta);
     Migration.CheckHumanoid(vrm0["humanoid"], vrm1.Humanoid);
 }
Exemplo n.º 16
0
        public static void CheckHumanoid(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.Humanoid vrm1)
        {
            foreach (var humanoidBone in vrm0["humanBones"].ArrayItems())
            {
                var boneType = humanoidBone["bone"].GetString();
                switch (boneType)
                {
                case "hips": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Hips); break;

                case "leftUpperLeg": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftUpperLeg); break;

                case "rightUpperLeg": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightUpperLeg); break;

                case "leftLowerLeg": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftLowerLeg); break;

                case "rightLowerLeg": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightLowerLeg); break;

                case "leftFoot": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftFoot); break;

                case "rightFoot": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightFoot); break;

                case "spine": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Spine); break;

                case "chest": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Chest); break;

                case "neck": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Neck); break;

                case "head": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Head); break;

                case "leftShoulder": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftShoulder); break;

                case "rightShoulder": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightShoulder); break;

                case "leftUpperArm": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftUpperArm); break;

                case "rightUpperArm": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightUpperArm); break;

                case "leftLowerArm": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftLowerArm); break;

                case "rightLowerArm": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightLowerArm); break;

                case "leftHand": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftHand); break;

                case "rightHand": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightHand); break;

                case "leftToes": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftToes); break;

                case "rightToes": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightToes); break;

                case "leftEye": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftEye); break;

                case "rightEye": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightEye); break;

                case "jaw": CheckBone(boneType, humanoidBone, vrm1.HumanBones.Jaw); break;

                case "leftThumbProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftThumbProximal); break;

                case "leftThumbIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftThumbIntermediate); break;

                case "leftThumbDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftThumbDistal); break;

                case "leftIndexProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftIndexProximal); break;

                case "leftIndexIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftIndexIntermediate); break;

                case "leftIndexDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftIndexDistal); break;

                case "leftMiddleProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftMiddleProximal); break;

                case "leftMiddleIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftMiddleIntermediate); break;

                case "leftMiddleDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftMiddleDistal); break;

                case "leftRingProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftRingProximal); break;

                case "leftRingIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftRingIntermediate); break;

                case "leftRingDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftRingDistal); break;

                case "leftLittleProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftLittleProximal); break;

                case "leftLittleIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftLittleIntermediate); break;

                case "leftLittleDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.LeftLittleDistal); break;

                case "rightThumbProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightThumbProximal); break;

                case "rightThumbIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightThumbIntermediate); break;

                case "rightThumbDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightThumbDistal); break;

                case "rightIndexProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightIndexProximal); break;

                case "rightIndexIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightIndexIntermediate); break;

                case "rightIndexDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightIndexDistal); break;

                case "rightMiddleProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightMiddleProximal); break;

                case "rightMiddleIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightMiddleIntermediate); break;

                case "rightMiddleDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightMiddleDistal); break;

                case "rightRingProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightRingProximal); break;

                case "rightRingIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightRingIntermediate); break;

                case "rightRingDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightRingDistal); break;

                case "rightLittleProximal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightLittleProximal); break;

                case "rightLittleIntermediate": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightLittleIntermediate); break;

                case "rightLittleDistal": CheckBone(boneType, humanoidBone, vrm1.HumanBones.RightLittleDistal); break;

                case "upperChest": CheckBone(boneType, humanoidBone, vrm1.HumanBones.UpperChest); break;

                default: throw new MigrationException("humanonoid.humanBones[*].bone", boneType);
                }
            }
        }
Exemplo n.º 17
0
        public static void CheckMeta(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.Meta vrm1)
        {
            if (vrm0["title"].GetString() != vrm1.Name)
            {
                throw new MigrationException("meta.title", vrm1.Name);
            }
            if (vrm0["version"].GetString() != vrm1.Version)
            {
                throw new MigrationException("meta.version", vrm1.Version);
            }
            if (!IsSingleList("meta.author", vrm0["author"].GetString(), vrm1.Authors))
            {
                throw new MigrationException("meta.author", $"{vrm1.Authors}");
            }
            if (vrm0["contactInformation"].GetString() != vrm1.ContactInformation)
            {
                throw new MigrationException("meta.contactInformation", vrm1.ContactInformation);
            }
            if (!IsSingleList("meta.reference", vrm0["reference"].GetString(), vrm1.References))
            {
                throw new MigrationException("meta.reference", $"{vrm1.References}");
            }
            if (vrm0["texture"].GetInt32() != vrm1.ThumbnailImage)
            {
                throw new MigrationException("meta.texture", $"{vrm1.ThumbnailImage}");
            }

            if (vrm0["allowedUserName"].GetString() != AvatarPermission("meta.allowedUserName", vrm1.AvatarPermission))
            {
                throw new MigrationException("meta.allowedUserName", $"{vrm1.AvatarPermission}");
            }
            if (vrm0["violentUssageName"].GetString() == "Allow" != vrm1.AllowExcessivelyViolentUsage)
            {
                throw new MigrationException("meta.violentUssageName", $"{vrm1.AllowExcessivelyViolentUsage}");
            }
            if (vrm0["sexualUssageName"].GetString() == "Allow" != vrm1.AllowExcessivelySexualUsage)
            {
                throw new MigrationException("meta.sexualUssageName", $"{vrm1.AllowExcessivelyViolentUsage}");
            }

            if (vrm0["commercialUssageName"].GetString() == "Allow")
            {
                if (vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit)
                {
                    throw new MigrationException("meta.commercialUssageName", $"{vrm1.CommercialUsage}");
                }
            }
            else
            {
                if (vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.corporation ||
                    vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit)
                {
                    throw new MigrationException("meta.commercialUssageName", $"{vrm1.CommercialUsage}");
                }
            }

            if (GetLicenseUrl(vrm0) != vrm1.OtherLicenseUrl)
            {
                throw new MigrationException("meta.otherLicenseUrl", vrm1.OtherLicenseUrl);
            }

            switch (vrm0["licenseName"].GetString())
            {
            case "Other":
            {
                if (vrm1.Modification != UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited)
                {
                    throw new MigrationException("meta.licenceName", $"{vrm1.Modification}");
                }
                if (vrm1.AllowRedistribution.Value)
                {
                    throw new MigrationException("meta.liceneName", $"{vrm1.Modification}");
                }
                break;
            }

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 18
0
 internal override float FromJson(JsonNode node) => (float)node;
Exemplo n.º 19
0
        static byte[] MigrateVrm(glTF gltf, ArraySegment <byte> bin, JsonNode vrm0)
        {
            var meshToNode = CreateMeshToNode(gltf);

            {
                // vrm
                var vrm1 = new UniGLTF.Extensions.VRMC_vrm.VRMC_vrm();

                // meta (required)
                vrm1.Meta = MigrationVrmMeta.Migrate(gltf, vrm0["meta"]);
                // humanoid (required)
                vrm1.Humanoid = MigrationVrmHumanoid.Migrate(vrm0["humanoid"]);

                // blendshape (optional)
                if (vrm0.TryGet("blendShapeMaster", out JsonNode vrm0BlendShape))
                {
                    vrm1.Expressions = new UniGLTF.Extensions.VRMC_vrm.Expressions
                    {
                        Preset = new UniGLTF.Extensions.VRMC_vrm.Preset(),
                        Custom = new Dictionary <string, UniGLTF.Extensions.VRMC_vrm.Expression>(),
                    };
                    foreach (var(preset, customName, expression) in MigrationVrmExpression.Migrate(gltf, vrm0BlendShape, meshToNode))
                    {
                        switch (preset)
                        {
                        case ExpressionPreset.happy: SetIfNull(ref vrm1.Expressions.Preset.Happy, expression); break;

                        case ExpressionPreset.angry: SetIfNull(ref vrm1.Expressions.Preset.Angry, expression); break;

                        case ExpressionPreset.sad: SetIfNull(ref vrm1.Expressions.Preset.Sad, expression); break;

                        case ExpressionPreset.relaxed: SetIfNull(ref vrm1.Expressions.Preset.Relaxed, expression); break;

                        case ExpressionPreset.surprised: SetIfNull(ref vrm1.Expressions.Preset.Surprised, expression); break;

                        case ExpressionPreset.aa: SetIfNull(ref vrm1.Expressions.Preset.Aa, expression); break;

                        case ExpressionPreset.ih: SetIfNull(ref vrm1.Expressions.Preset.Ih, expression); break;

                        case ExpressionPreset.ou: SetIfNull(ref vrm1.Expressions.Preset.Ou, expression); break;

                        case ExpressionPreset.ee: SetIfNull(ref vrm1.Expressions.Preset.Ee, expression); break;

                        case ExpressionPreset.oh: SetIfNull(ref vrm1.Expressions.Preset.Oh, expression); break;

                        case ExpressionPreset.blink: SetIfNull(ref vrm1.Expressions.Preset.Blink, expression); break;

                        case ExpressionPreset.blinkLeft: SetIfNull(ref vrm1.Expressions.Preset.BlinkLeft, expression); break;

                        case ExpressionPreset.blinkRight: SetIfNull(ref vrm1.Expressions.Preset.BlinkRight, expression); break;

                        case ExpressionPreset.lookUp: SetIfNull(ref vrm1.Expressions.Preset.LookUp, expression); break;

                        case ExpressionPreset.lookDown: SetIfNull(ref vrm1.Expressions.Preset.LookDown, expression); break;

                        case ExpressionPreset.lookLeft: SetIfNull(ref vrm1.Expressions.Preset.LookLeft, expression); break;

                        case ExpressionPreset.lookRight: SetIfNull(ref vrm1.Expressions.Preset.LookRight, expression); break;

                        case ExpressionPreset.neutral: SetIfNull(ref vrm1.Expressions.Preset.Neutral, expression); break;

                        case ExpressionPreset.custom:
                            if (vrm1.Expressions.Custom.ContainsKey(customName))
                            {
                                // 同名が既存。先着を有効とする
                            }
                            else
                            {
                                vrm1.Expressions.Custom[customName] = expression;
                            }
                            break;

                        default: throw new NotImplementedException();
                        }
                    }
                }

                // lookat & firstperson (optional)
                if (vrm0.TryGet("firstPerson", out JsonNode vrm0FirstPerson))
                {
                    (vrm1.LookAt, vrm1.FirstPerson) = MigrationVrmLookAtAndFirstPerson.Migrate(gltf, vrm0FirstPerson);
                }

                UniGLTF.Extensions.VRMC_vrm.GltfSerializer.SerializeTo(ref gltf.extensions, vrm1);
            }

            // springBone & collider (optional)
            if (vrm0.TryGet("secondaryAnimation", out JsonNode vrm0SpringBone))
            {
                var springBone = MigrationVrmSpringBone.Migrate(gltf, vrm0SpringBone);
                UniGLTF.Extensions.VRMC_springBone.GltfSerializer.SerializeTo(ref gltf.extensions, springBone);
            }

            // Material
            {
                MigrationMaterials.Migrate(gltf, vrm0);
            }

            // Serialize whole glTF
            ArraySegment <byte> vrm1Json = default;

            {
                var f = new JsonFormatter();
                GltfSerializer.Serialize(f, gltf);
                vrm1Json = f.GetStoreBytes();
            }

            return(Glb.Create(vrm1Json, bin).ToBytes());
        }
Exemplo n.º 20
0
 internal override bool FromJson(JsonNode node) => (bool)node;
Exemplo n.º 21
0
 internal override double FromJson(JsonNode node) => (double)node;
Exemplo n.º 22
0
 public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_springBone.VRMC_springBone vrm1, List <UniGLTF.glTFNode> nodes)
 {
     // Migration.CheckSpringBone(vrm0["secondaryAnimation"], vrm1.sp)
 }
Exemplo n.º 23
0
        ///
        /// 互換性の無いところ
        ///
        /// * きつくなる方向は許す
        /// * 緩くなる方向は不許可(throw)
        ///
        // "meta": {
        //   "title": "Alicia Solid",
        //   "version": "1.10",
        //   "author": "© DWANGO Co., Ltd.",
        //   "contactInformation": "https://3d.nicovideo.jp/alicia/",
        //   "reference": "",
        //   "texture": 7,
        //   "allowedUserName": "******",
        //   "violentUssageName": "Disallow",
        //   "sexualUssageName": "Disallow",
        //   "commercialUssageName": "Allow",
        //   "otherPermissionUrl": "https://3d.nicovideo.jp/alicia/rule.html",
        //   "licenseName": "Other",
        //   "otherLicenseUrl": "https://3d.nicovideo.jp/alicia/rule.html"
        // },
        static UniGLTF.Extensions.VRMC_vrm.Meta MigrateMeta(JsonNode vrm0)
        {
            var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
            {
                AllowPoliticalOrReligiousUsage = false,
                AllowExcessivelySexualUsage    = false,
                AllowExcessivelyViolentUsage   = false,
                AllowRedistribution            = false,
                AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor,
                CommercialUsage  = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit,
                CreditNotation   = UniGLTF.Extensions.VRMC_vrm.CreditNotationType.required,
                Modification     = UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited,
            };

            foreach (var kv in vrm0.ObjectItems())
            {
                var key = kv.Key.GetString();
                switch (key)
                {
                case "title": meta.Name = kv.Value.GetString(); break;

                case "version": meta.Version = kv.Value.GetString(); break;

                case "author": meta.Authors = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "contactInformation": meta.ContactInformation = kv.Value.GetString(); break;

                case "reference": meta.References = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "texture": meta.ThumbnailImage = kv.Value.GetInt32(); break;

                case "allowedUserName":
                {
                    var allowedUserName = kv.Value.GetString();
                    switch (allowedUserName)
                    {
                    case "OnlyAuthor":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor;
                        break;

                    case "ExplicitlyLicensedPerson":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.explicitlyLicensedPerson;
                        break;

                    case "Everyone":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {allowedUserName}");
                    }
                }
                break;

                case "violentUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var violentUsageName = kv.Value.GetString();
                    switch (violentUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelyViolentUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelyViolentUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {violentUsageName}");
                    }
                }
                break;

                case "sexualUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var sexualUsageName = kv.Value.GetString();
                    switch (sexualUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelySexualUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelySexualUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {sexualUsageName}");
                    }
                }
                break;

                case "commercialUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var commercialUsageName = kv.Value.GetString();
                    switch (commercialUsageName)
                    {
                    case "Allow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit;
                        break;

                    case "Disallow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {commercialUsageName}");
                    }
                }
                break;

                case "otherPermissionUrl":
                {
                    // TODO
                    // var url = kv.Value.GetString();
                    // if (!String.IsNullOrWhiteSpace(url))
                    // {
                    //     throw new NotImplementedException("otherPermissionUrl not allowd");
                    // }
                }
                break;

                case "otherLicenseUrl": meta.OtherLicenseUrl = kv.Value.GetString(); break;

                case "licenseName":
                {
                    // TODO
                    // CreditNotation = CreditNotationType.required,
                }
                break;

                default:
                    throw new NotImplementedException(key);
                }
            }

            return(meta);
        }
Exemplo n.º 24
0
 static float[] ToFloat4(JsonNode node)
 {
     return(node.ArrayItems().Select(x => x.GetSingle()).ToArray());
 }
Exemplo n.º 25
0
            public static MToonValue Create(JsonNode vrmMaterial)
            {
                var definition = new MToon.MToonDefinition
                {
                    Color    = new MToon.ColorDefinition {
                    },
                    Lighting = new MToon.LightingDefinition
                    {
                        LightingInfluence = new MToon.LightingInfluenceDefinition {
                        },
                        LitAndShadeMixing = new MToon.LitAndShadeMixingDefinition {
                        },
                        Normal            = new MToon.NormalDefinition {
                        }
                    },
                    Emission      = new MToon.EmissionDefinition {
                    },
                    MatCap        = new MToon.MatCapDefinition {
                    },
                    Meta          = new MToon.MetaDefinition {
                    },
                    Outline       = new MToon.OutlineDefinition {
                    },
                    Rendering     = new MToon.RenderingDefinition {
                    },
                    Rim           = new MToon.RimDefinition {
                    },
                    TextureOption = new MToon.TextureUvCoordsDefinition {
                    }
                };

                var offsetScale = new Dictionary <string, float[]>();

                foreach (var kv in vrmMaterial["vectorProperties"].ObjectItems())
                {
                    var key = kv.Key.GetString();
                    switch (key)
                    {
                    case "_Color":
                        definition.Color.LitColor = ToColor(kv.Value);
                        break;

                    case "_ShadeColor":
                        definition.Color.ShadeColor = ToColor(kv.Value);
                        break;

                    case "_EmissionColor":
                        definition.Emission.EmissionColor = ToColor(kv.Value);
                        break;

                    case "_OutlineColor":
                        definition.Outline.OutlineColor = ToColor(kv.Value);
                        break;

                    case "_RimColor":
                        definition.Rim.RimColor = ToColor(kv.Value);
                        break;

                    case "_MainTex":
                    case "_ShadeTexture":
                    case "_BumpMap":
                    case "_EmissionMap":
                    case "_OutlineWidthTexture":
                    case "_ReceiveShadowTexture":
                    case "_RimTexture":
                    case "_ShadingGradeTexture":
                    case "_SphereAdd":
                    case "_UvAnimMaskTexture":
                        // scale, offset
                        offsetScale.Add(key, ToFloat4(kv.Value));
                        break;

                    default:
#if VRM_DEVELOP
                        Debug.LogWarning($"vectorProperties: {kv.Key}: {kv.Value}");
#endif
                        break;
                    }
                }

                foreach (var kv in vrmMaterial["floatProperties"].ObjectItems())
                {
                    var value = kv.Value.GetSingle();
                    switch (kv.Key.GetString())
                    {
                    case "_BlendMode":
                        definition.Rendering.RenderMode = (MToon.RenderMode)(int) value;
                        break;

                    case "_CullMode":
                        definition.Rendering.CullMode = (MToon.CullMode)(int) value;
                        break;

                    case "_Cutoff":
                        definition.Color.CutoutThresholdValue = value;
                        break;

                    case "_BumpScale":
                        definition.Lighting.Normal.NormalScaleValue = value;
                        break;

                    case "_LightColorAttenuation":
                        definition.Lighting.LightingInfluence.LightColorAttenuationValue = value;
                        break;

                    case "_RimFresnelPower":
                        definition.Rim.RimFresnelPowerValue = value;
                        break;

                    case "_RimLift":
                        definition.Rim.RimLiftValue = value;
                        break;

                    case "_RimLightingMix":
                        definition.Rim.RimLightingMixValue = value;
                        break;

                    case "_ShadeShift":
                        definition.Lighting.LitAndShadeMixing.ShadingShiftValue = value;
                        break;

                    case "_ShadeToony":
                        definition.Lighting.LitAndShadeMixing.ShadingToonyValue = value;
                        break;

                    case "_ShadingGradeRate":
                        // definition.Lighting.LightingInfluence.gr
                        break;

                    case "_OutlineColorMode":
                        definition.Outline.OutlineColorMode = (MToon.OutlineColorMode)value;
                        break;

                    case "_OutlineLightingMix":
                        definition.Outline.OutlineLightingMixValue = value;
                        break;

                    case "_OutlineScaledMaxDistance":
                        definition.Outline.OutlineScaledMaxDistanceValue = value;
                        break;

                    case "_OutlineWidth":
                        definition.Outline.OutlineWidthValue = value;
                        break;

                    case "_OutlineWidthMode":
                        definition.Outline.OutlineWidthMode = (MToon.OutlineWidthMode)value;
                        break;

                    case "_OutlineCullMode":
                        // definition.Outline.
                        break;

                    case "_UvAnimRotation":
                        definition.TextureOption.UvAnimationRotationSpeedValue = value;
                        break;

                    case "_UvAnimScrollX":
                        definition.TextureOption.UvAnimationScrollXSpeedValue = value;
                        break;

                    case "_UvAnimScrollY":
                        definition.TextureOption.UvAnimationScrollYSpeedValue = value;
                        break;

                    case "_ZWrite":
                        break;

                    case "_ReceiveShadowRate":
                    case "_DstBlend":
                    case "_SrcBlend":
                    case "_IndirectLightIntensity":
                    case "_MToonVersion":
                    case "_DebugMode":
                        break;

                    default:
#if VRM_DEVELOP
                        Debug.LogWarning($"floatProperties: {kv.Key} is unknown");
#endif
                        break;
                    }
                }

                var map = new TextureIndexMap();

                foreach (var kv in vrmMaterial["textureProperties"].ObjectItems())
                {
                    var index = kv.Value.GetInt32();
                    switch (kv.Key.GetString())
                    {
                    case "_MainTex": map.MainTex = index; break;

                    case "_ShadeTexture": map.ShadeTexture = index; break;

                    case "_BumpMap": map.BumpMap = index; break;

                    case "_ReceiveShadowTexture": map.ReceiveShadowTexture = index; break;

                    case "_ShadingGradeTexture": map.ShadingGradeTexture = index; break;

                    case "_RimTexture": map.RimTexture = index; break;

                    case "_SphereAdd": map.SphereAdd = index; break;

                    case "_EmissionMap": map.EmissionMap = index; break;

                    case "_OutlineWidthTexture": map.OutlineWidthTexture = index; break;

                    case "_UvAnimMaskTexture": map.UvAnimMaskTexture = index; break;

                    default:
#if VRM_DEVELOP
                        Debug.LogWarning($"textureProperties: {kv.Key} is unknown");
#endif
                        break;
                    }
                }

                return(new MToonValue
                {
                    Definition = definition,
                    OffsetScale = offsetScale,
                    TextureIndexMap = map,
                });
            }
Exemplo n.º 26
0
 static Color ToColor(JsonNode node)
 {
     return(node.ArrayItems().Select(x => x.GetSingle()).ToArray().ToColor4());
 }
Exemplo n.º 27
0
 internal override string FromJson(JsonNode node) => node.ToString();
Exemplo n.º 28
0
 internal override ulong FromJson(JsonNode node) => (ulong)node;
Exemplo n.º 29
0
 internal override short FromJson(JsonNode node) => (short)node;
Exemplo n.º 30
0
        static UniGLTF.Extensions.VRMC_springBone.VRMC_springBone MigrateSpringBone(UniGLTF.glTF gltf, JsonNode sa)
        {
            var colliderNodes = new List <int>();

            foreach (var x in sa["colliderGroups"].ArrayItems())
            {
                var node = x["node"].GetInt32();
                colliderNodes.Add(node);
                var gltfNode = gltf.nodes[node];

                var collider = new UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider()
                {
                    Shapes = new List <UniGLTF.Extensions.VRMC_node_collider.ColliderShape>(),
                };

                // {
                //   "node": 14,
                //   "colliders": [
                //     {
                //       "offset": {
                //         "x": 0.025884293,
                //         "y": -0.120000005,
                //         "z": 0
                //       },
                //       "radius": 0.05
                //     },
                //     {
                //       "offset": {
                //         "x": -0.02588429,
                //         "y": -0.120000005,
                //         "z": 0
                //       },
                //       "radius": 0.05
                //     },
                //     {
                //       "offset": {
                //         "x": 0,
                //         "y": -0.0220816135,
                //         "z": 0
                //       },
                //       "radius": 0.08
                //     }
                //   ]
                // },
                foreach (var y in x["colliders"].ArrayItems())
                {
                    collider.Shapes.Add(new UniGLTF.Extensions.VRMC_node_collider.ColliderShape
                    {
                        Sphere = new UniGLTF.Extensions.VRMC_node_collider.ColliderShapeSphere
                        {
                            Offset = ReverseZ(y["offset"]),
                            Radius = y["radius"].GetSingle()
                        }
                    });
                }

                if (!(gltfNode.extensions is UniGLTF.glTFExtensionExport extensions))
                {
                    extensions          = new UniGLTF.glTFExtensionExport();
                    gltfNode.extensions = extensions;
                }

                var f = new JsonFormatter();
                UniGLTF.Extensions.VRMC_node_collider.GltfSerializer.Serialize(f, collider);
                extensions.Add(UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider.ExtensionName, f.GetStoreBytes());
            }

            var springBone = new UniGLTF.Extensions.VRMC_springBone.VRMC_springBone
            {
                Springs = new List <UniGLTF.Extensions.VRMC_springBone.Spring>(),
            };

            foreach (var x in sa["boneGroups"].ArrayItems())
            {
                // {
                //   "comment": "",
                //   "stiffiness": 2,
                //   "gravityPower": 0,
                //   "gravityDir": {
                //     "x": 0,
                //     "y": -1,
                //     "z": 0
                //   },
                //   "dragForce": 0.7,
                //   "center": -1,
                //   "hitRadius": 0.02,
                //   "bones": [
                //     97,
                //     99,
                //     101,
                //     113,
                //     114
                //   ],
                //   "colliderGroups": [
                //     3,
                //     4,
                //     5
                //   ]
                // },
                foreach (var y in x["bones"].ArrayItems())
                {
                    var comment = x.GetObjectValueOrDefault("comment", "");
                    var spring  = new UniGLTF.Extensions.VRMC_springBone.Spring
                    {
                        Name      = comment,
                        Colliders = x["colliderGroups"].ArrayItems().Select(z => colliderNodes[z.GetInt32()]).ToArray(),
                        Joints    = new List <UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint>(),
                    };

                    foreach (var z in EnumJoint(gltf.nodes, gltf.nodes[y.GetInt32()]))
                    {
                        spring.Joints.Add(new UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint
                        {
                            Node         = gltf.nodes.IndexOf(z),
                            DragForce    = x["dragForce"].GetSingle(),
                            GravityDir   = ReverseZ(x["gravityDir"]),
                            GravityPower = x["gravityPower"].GetSingle(),
                            HitRadius    = x["hitRadius"].GetSingle(),
                            Stiffness    = x["stiffiness"].GetSingle(),
                        });
                    }

                    springBone.Springs.Add(spring);
                }
            }

            return(springBone);
        }
Exemplo n.º 31
0
 internal override uint FromJson(JsonNode node) => (uint)node;
Exemplo n.º 32
0
        static UniGLTF.Extensions.VRMC_vrm.Humanoid MigrateHumanoid(JsonNode vrm0)
        {
            var humanoid = new UniGLTF.Extensions.VRMC_vrm.Humanoid
            {
                HumanBones = new UniGLTF.Extensions.VRMC_vrm.HumanBones()
            };

            foreach (var humanoidBone in vrm0["humanBones"].ArrayItems())
            {
                var boneType = humanoidBone["bone"].GetString();
                switch (boneType)
                {
                case "hips": humanoid.HumanBones.Hips = MigrateHumanoidBone(humanoidBone); break;

                case "leftUpperLeg": humanoid.HumanBones.LeftUpperLeg = MigrateHumanoidBone(humanoidBone); break;

                case "rightUpperLeg": humanoid.HumanBones.RightUpperLeg = MigrateHumanoidBone(humanoidBone); break;

                case "leftLowerLeg": humanoid.HumanBones.LeftLowerLeg = MigrateHumanoidBone(humanoidBone); break;

                case "rightLowerLeg": humanoid.HumanBones.RightLowerLeg = MigrateHumanoidBone(humanoidBone); break;

                case "leftFoot": humanoid.HumanBones.LeftFoot = MigrateHumanoidBone(humanoidBone); break;

                case "rightFoot": humanoid.HumanBones.RightFoot = MigrateHumanoidBone(humanoidBone); break;

                case "spine": humanoid.HumanBones.Spine = MigrateHumanoidBone(humanoidBone); break;

                case "chest": humanoid.HumanBones.Chest = MigrateHumanoidBone(humanoidBone); break;

                case "neck": humanoid.HumanBones.Neck = MigrateHumanoidBone(humanoidBone); break;

                case "head": humanoid.HumanBones.Head = MigrateHumanoidBone(humanoidBone); break;

                case "leftShoulder": humanoid.HumanBones.LeftShoulder = MigrateHumanoidBone(humanoidBone); break;

                case "rightShoulder": humanoid.HumanBones.RightShoulder = MigrateHumanoidBone(humanoidBone); break;

                case "leftUpperArm": humanoid.HumanBones.LeftUpperArm = MigrateHumanoidBone(humanoidBone); break;

                case "rightUpperArm": humanoid.HumanBones.RightUpperArm = MigrateHumanoidBone(humanoidBone); break;

                case "leftLowerArm": humanoid.HumanBones.LeftLowerArm = MigrateHumanoidBone(humanoidBone); break;

                case "rightLowerArm": humanoid.HumanBones.RightLowerArm = MigrateHumanoidBone(humanoidBone); break;

                case "leftHand": humanoid.HumanBones.LeftHand = MigrateHumanoidBone(humanoidBone); break;

                case "rightHand": humanoid.HumanBones.RightHand = MigrateHumanoidBone(humanoidBone); break;

                case "leftToes": humanoid.HumanBones.LeftToes = MigrateHumanoidBone(humanoidBone); break;

                case "rightToes": humanoid.HumanBones.RightToes = MigrateHumanoidBone(humanoidBone); break;

                case "leftEye": humanoid.HumanBones.LeftEye = MigrateHumanoidBone(humanoidBone); break;

                case "rightEye": humanoid.HumanBones.RightEye = MigrateHumanoidBone(humanoidBone); break;

                case "jaw": humanoid.HumanBones.Jaw = MigrateHumanoidBone(humanoidBone); break;

                case "leftThumbProximal": humanoid.HumanBones.LeftThumbProximal = MigrateHumanoidBone(humanoidBone); break;

                case "leftThumbIntermediate": humanoid.HumanBones.LeftThumbIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "leftThumbDistal": humanoid.HumanBones.LeftThumbDistal = MigrateHumanoidBone(humanoidBone); break;

                case "leftIndexProximal": humanoid.HumanBones.LeftIndexProximal = MigrateHumanoidBone(humanoidBone); break;

                case "leftIndexIntermediate": humanoid.HumanBones.LeftIndexIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "leftIndexDistal": humanoid.HumanBones.LeftIndexDistal = MigrateHumanoidBone(humanoidBone); break;

                case "leftMiddleProximal": humanoid.HumanBones.LeftMiddleProximal = MigrateHumanoidBone(humanoidBone); break;

                case "leftMiddleIntermediate": humanoid.HumanBones.LeftMiddleIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "leftMiddleDistal": humanoid.HumanBones.LeftMiddleDistal = MigrateHumanoidBone(humanoidBone); break;

                case "leftRingProximal": humanoid.HumanBones.LeftRingProximal = MigrateHumanoidBone(humanoidBone); break;

                case "leftRingIntermediate": humanoid.HumanBones.LeftRingIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "leftRingDistal": humanoid.HumanBones.LeftRingDistal = MigrateHumanoidBone(humanoidBone); break;

                case "leftLittleProximal": humanoid.HumanBones.LeftLittleProximal = MigrateHumanoidBone(humanoidBone); break;

                case "leftLittleIntermediate": humanoid.HumanBones.LeftLittleIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "leftLittleDistal": humanoid.HumanBones.LeftLittleDistal = MigrateHumanoidBone(humanoidBone); break;

                case "rightThumbProximal": humanoid.HumanBones.RightThumbProximal = MigrateHumanoidBone(humanoidBone); break;

                case "rightThumbIntermediate": humanoid.HumanBones.RightThumbIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "rightThumbDistal": humanoid.HumanBones.RightThumbDistal = MigrateHumanoidBone(humanoidBone); break;

                case "rightIndexProximal": humanoid.HumanBones.RightIndexProximal = MigrateHumanoidBone(humanoidBone); break;

                case "rightIndexIntermediate": humanoid.HumanBones.RightIndexIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "rightIndexDistal": humanoid.HumanBones.RightIndexDistal = MigrateHumanoidBone(humanoidBone); break;

                case "rightMiddleProximal": humanoid.HumanBones.RightMiddleProximal = MigrateHumanoidBone(humanoidBone); break;

                case "rightMiddleIntermediate": humanoid.HumanBones.RightMiddleIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "rightMiddleDistal": humanoid.HumanBones.RightMiddleDistal = MigrateHumanoidBone(humanoidBone); break;

                case "rightRingProximal": humanoid.HumanBones.RightRingProximal = MigrateHumanoidBone(humanoidBone); break;

                case "rightRingIntermediate": humanoid.HumanBones.RightRingIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "rightRingDistal": humanoid.HumanBones.RightRingDistal = MigrateHumanoidBone(humanoidBone); break;

                case "rightLittleProximal": humanoid.HumanBones.RightLittleProximal = MigrateHumanoidBone(humanoidBone); break;

                case "rightLittleIntermediate": humanoid.HumanBones.RightLittleIntermediate = MigrateHumanoidBone(humanoidBone); break;

                case "rightLittleDistal": humanoid.HumanBones.RightLittleDistal = MigrateHumanoidBone(humanoidBone); break;

                case "upperChest": humanoid.HumanBones.UpperChest = MigrateHumanoidBone(humanoidBone); break;

                default: throw new NotImplementedException($"unknown bone: {boneType}");
                }
            }

            return(humanoid);
        }
Exemplo n.º 33
0
 internal override decimal FromJson(JsonNode node)
 {
     return((decimal)node);
 }
Exemplo n.º 34
0
        static IEnumerable <UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(UniGLTF.glTF gltf, JsonNode json)
        {
            foreach (var x in json.ArrayItems())
            {
                var meshIndex        = x["mesh"].GetInt32();
                var morphTargetIndex = x["index"].GetInt32();
                var weight           = x["weight"].GetSingle();

                var bind = new UniGLTF.Extensions.VRMC_vrm.MorphTargetBind();

                // https://github.com/vrm-c/vrm-specification/pull/106
                // https://github.com/vrm-c/vrm-specification/pull/153
                bind.Node  = gltf.nodes.IndexOf(gltf.nodes.First(y => y.mesh == meshIndex));
                bind.Index = morphTargetIndex;
                // https://github.com/vrm-c/vrm-specification/issues/209
                bind.Weight = weight * 0.01f;

                yield return(bind);
            }
        }
 internal override JsonObject FromJson(JsonNode node) => (JsonObject)node;
Exemplo n.º 36
0
 static IEnumerable <UniGLTF.Extensions.VRMC_vrm.Expression> MigrateExpression(UniGLTF.glTF gltf, JsonNode json)
 {
     foreach (var blendShapeClip in json["blendShapeGroups"].ArrayItems())
     {
         var name       = blendShapeClip["name"].GetString();
         var expression = new UniGLTF.Extensions.VRMC_vrm.Expression
         {
             Name     = name,
             Preset   = ToPreset(blendShapeClip["presetName"]),
             IsBinary = blendShapeClip["isBinary"].GetBoolean(),
         };
         expression.MorphTargetBinds = ToMorphTargetBinds(gltf, blendShapeClip["binds"]).ToList();
         ToMaterialColorBinds(gltf, blendShapeClip["materialValues"], expression);
         yield return(expression);
     }
 }
Exemplo n.º 37
0
 internal abstract T FromJson(JsonNode node);
Exemplo n.º 38
0
        public override void constract()
        {
            int    brace   = 0;
            int    bracket = 0;
            int    index   = 0;
            string data    = this.value;

            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == ',' && brace == 0 && bracket == 0)
                {
                    string[] tmp  = data.Substring(index, i - index).Split(':');
                    JsonTree node = null;
                    for (int j = 0; j < tmp[1].Length; j++)
                    {
                        if (tmp[1][j] == '"')
                        {
                            node       = new JsonNode();
                            node.value = tmp[1].Trim(' ', '\n', '\r');
                            break;
                        }
                        else if (tmp[1][j] == '{')
                        {
                            string rowStr = "";
                            for (int k = 1; k < tmp.Length; k++)
                            {
                                rowStr += ":" + tmp[k];
                            }
                            node       = new JsonObject();
                            node.value = rowStr.Substring(1).Trim(' ', '{', '}', '\n', '\r');
                            break;
                        }
                        else if (tmp[1][j] == '[')
                        {
                            string rowStr = "";
                            for (int k = 1; k < tmp.Length; k++)
                            {
                                rowStr += ":" + tmp[k];
                            }
                            node       = new JsonArray();
                            node.value = rowStr.Substring(1).Trim(' ', '[', ']', '\n', '\r');
                            break;
                        }
                        else if (j == tmp[1].Length - 1)
                        {
                            node       = new JsonNode();
                            node.value = tmp[1].Trim(' ', '\n', '\r');
                        }
                    }
                    node.name = tmp[0].Trim(' ', '\n', '\r', '"', ',');
                    this.nodes.Add(node);
                    index = i + 1;
                }
                if (data[i] == '{')
                {
                    brace++;
                }
                else if (data[i] == '}')
                {
                    brace--;
                }
                else if (data[i] == '[')
                {
                    bracket++;
                }
                else if (data[i] == ']')
                {
                    bracket--;
                }
            }
            if (brace == 0 && bracket == 0)
            {
                string[] tmp  = data.Substring(index, data.Length - index).Split(':');
                JsonTree node = null;
                for (int j = 0; j < tmp[1].Length; j++)
                {
                    if (tmp[1][j] == '"')
                    {
                        node       = new JsonNode();
                        node.value = tmp[1].Trim(' ', '\n', '\r');
                        break;
                    }
                    else if (tmp[1][j] == '{')
                    {
                        string rowStr = "";
                        for (int k = 1; k < tmp.Length; k++)
                        {
                            rowStr += ":" + tmp[k];
                        }
                        node       = new JsonObject();
                        node.value = rowStr.Substring(1).Trim(' ', '{', '}', '\n', '\r');
                        break;
                    }
                    else if (tmp[1][j] == '[')
                    {
                        string rowStr = "";
                        for (int k = 1; k < tmp.Length; k++)
                        {
                            rowStr += ":" + tmp[k];
                        }
                        node       = new JsonArray();
                        node.value = rowStr.Substring(1).Trim(' ', '[', ']', '\n', '\r');
                        break;
                    }
                    else if (j == tmp[1].Length - 1)
                    {
                        node       = new JsonNode();
                        node.value = tmp[1].Trim(' ', '\n', '\r');
                    }
                }
                node.name = tmp[0].Trim(' ', '\n', '\r', '"', ',');
                this.nodes.Add(node);
            }
        }
Exemplo n.º 39
0
 internal override JsonArray FromJson(JsonNode node) => (JsonArray)node;
Exemplo n.º 40
0
 public Region(JsonNode json)
 {
     Left = (int)json["Left"].Get<long>();
     Right = (int)json["Right"].Get<long>();
     Bottom = (int)json["Bottom"].Get<long>();
     Top = (int)json["Top"].Get<long>();
     Height = (int)json["Height"].Get<long>();
 }
Exemplo n.º 41
0
            public Gimmick(JsonNode json)
                : base(json)
            {
                Values = new List<double>();

                Debug.Log(json["Values"].Count);

                foreach (var item in json["Values"])
                {
                    Values.Add(item.Get<double>());
                }
            }
Exemplo n.º 42
0
 public Item(JsonNode json)
     : base(json)
 {
 }
 public void Init()
 {
     instance = new JsonNode();
 }
Exemplo n.º 44
0
            public Enemy(JsonNode json)
                : base(json)
            {
                Values = new List<double>();

                foreach (var item in json["Values"])
                {
                    Values.Add(item.Get<double>());
                }
            }
Exemplo n.º 45
0
        public override void constract()
        {
            int    brace   = 0;
            int    bracket = 0;
            int    index   = 0;
            string data    = this.value;

            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == ',' && brace == 0 && bracket == 0)
                {
                    string   tmp  = data.Substring(index, i - index);
                    JsonTree node = null;
                    for (int j = 0; j < tmp.Length; j++)
                    {
                        if (tmp[j] == '"')
                        {
                            node       = new JsonNode();
                            node.value = tmp.Trim(' ', '\n', '\r');
                            break;
                        }
                        else if (tmp[j] == '{')
                        {
                            node       = new JsonObject();
                            node.value = tmp.Trim(' ', '\n', '\r', '{', '}');
                            break;
                        }
                        else if (tmp[j] == '[')
                        {
                            node       = new JsonArray();
                            node.value = tmp.Trim(' ', '\n', '\r', '[', ']');
                            break;
                        }
                        else if (j == tmp.Length - 1)
                        {
                            node       = new JsonNode();
                            node.value = tmp.Trim(' ', '\n', '\r');
                        }
                    }
                    node.name           = this.name;
                    node.isArrayElement = true;
                    this.nodes.Add(node);
                    index = i + 1;
                }
                if (data[i] == '{')
                {
                    brace++;
                }
                else if (data[i] == '}')
                {
                    brace--;
                }
                else if (data[i] == '[')
                {
                    bracket++;
                }
                else if (data[i] == ']')
                {
                    bracket--;
                }
            }
            if (brace == 0 && bracket == 0)
            {
                string   tmp  = data.Substring(index, data.Length - index);
                JsonTree node = null;
                for (int j = 0; j < tmp.Length; j++)
                {
                    if (tmp[j] == '"')
                    {
                        node       = new JsonNode();
                        node.value = tmp.Trim(' ', '\n', '\r');
                        break;
                    }
                    else if (tmp[j] == '{')
                    {
                        node       = new JsonObject();
                        node.value = tmp.Trim(' ', '\n', '\r', '{', '}');
                        break;
                    }
                    else if (tmp[j] == '[')
                    {
                        node       = new JsonArray();
                        node.value = tmp.Trim(' ', '\n', '\r', '[', ']');
                        break;
                    }
                    else if (j == tmp.Length - 1)
                    {
                        node       = new JsonNode();
                        node.value = tmp.Trim(' ', '\n', '\r');
                    }
                }
                node.name           = this.name;
                node.isArrayElement = true;
                this.nodes.Add(node);
            }
        }
Exemplo n.º 46
0
 private JsonNode ParseNumber()
 {
     if (lexer.GetCurrentTokenType() != TokenType.Number)
         throw CreateExpectedException(lexer.GetCurrentToken(), TokenType.Number);
     JsonNode result = new JsonNode(NodeType.Integer);
     result.Assign(Convert.ToInt64(lexer.GetCurrentToken().Value));
     lexer.NextToken();
     return result;
 }
Exemplo n.º 47
0
 private void BuildCollection(IFileViewModel fileViewModel, JsonNode jsonNode, Schema schema, List<string> path, CancellationToken? token)
 {
     if (token.HasValue && token.Value.IsCancellationRequested)
     return;
       foreach (JsonElement jsonElement in jsonNode)
       {
     path.Add(jsonElement.Key);
     SchemaObject schemaObject = schema.GetSchemaObject(path);
     if (schemaObject != null)
     {
       if (schemaObject.AutoCompleteTargetKey != null)
       {
     string prefix = schemaObject.Prefix;
     AddParameters(ref prefix, fileViewModel);
     if (jsonElement.Value is JsonNode)
       AddRange(schemaObject.AutoCompleteTargetKey, ((JsonNode)jsonElement.Value).Keys, prefix, fileViewModel);
     else
       Add(schemaObject.AutoCompleteTargetKey, jsonElement.Value.ToString(), prefix,fileViewModel);
       }
       JsonNode node = jsonElement.Value as JsonNode;
       if (node != null)
     BuildCollection(fileViewModel, node, schema, path, token);
       else
       {
     JsonArray array = jsonElement.Value as JsonArray;
     if (array != null)
       BuildCollection(fileViewModel, array, schema, path, token);
       }
     }
     path.RemoveAt(path.Count - 1);
       }
 }
Exemplo n.º 48
0
 public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm1, MeshIndexToNodeIndexFunc meshToNode)
 {
     MigrationVrmMeta.Check(vrm0["meta"], vrm1.Meta);
     MigrationVrmHumanoid.Check(vrm0["humanoid"], vrm1.Humanoid);
     MigrationVrmExpression.Check(vrm0["blendShapeMaster"], vrm1.Expressions, meshToNode);
 }
Exemplo n.º 49
0
 public void SaveSetup()
 {
     JsonNode root = new JsonNode {{"layouttype", m_selectedLayoutType}};
       JsonArray layouts = new JsonArray();
       foreach (LayoutElementViewModel editorLayoutViewModel in m_layoutElements)
       {
     JsonNode layout = new JsonNode();
     JsonArray openFiles = new JsonArray();
     foreach (IFileViewModel fileViewModel in editorLayoutViewModel.OpenFiles.Where(n => n.Path != null))
       openFiles.Add(fileViewModel.Path);
     layout.Add(new JsonElement("openfiles", openFiles));
     if (editorLayoutViewModel.SelectedFile != null && editorLayoutViewModel.SelectedFile.Path != null)
       layout.Add(new JsonElement("selectedFile", editorLayoutViewModel.SelectedFile.Path));
     layout.Add("isactive", editorLayoutViewModel == m_activeLayoutElement);
     layouts.Add(layout);
       }
       root.Add("layouts", layouts);
       StreamWriter streamWriter = File.CreateText(Properties.Settings.Default.SettingPath + "\\openFiles.json");
       streamWriter.Write(root.ToString());
       streamWriter.Close();
 }
Exemplo n.º 50
0
 public void Save()
 {
     JsonNode root = new JsonNode();
       JsonNode collections = new JsonNode();
       foreach (KeyValuePair<string, List<List<string>>> keyValuePair in m_collections)
       {
     JsonArray jsonArray = new JsonArray();
     foreach (string item in keyValuePair.Value.SelectMany(n => n))
       jsonArray.Add(item);
     collections.Add(new JsonElement(keyValuePair.Key, jsonArray));
       }
       root.Add(new JsonElement("collections", collections));
       JsonNode filetimeStamps = new JsonNode();
       foreach (KeyValuePair<string, DateTime> keyValuePair in m_fileTimeStamps)
       {
     filetimeStamps.Add(new JsonElement(keyValuePair.Key.Replace("\\", "\\\\"), keyValuePair.Value));
       }
       root.Add(new JsonElement("fileTimeStamps", filetimeStamps));
       StreamWriter streamWriter = File.CreateText(m_project.Children[0].Path + "\\autocompletdata.json");
       streamWriter.Write(root.ToString());
       streamWriter.Close();
 }
Exemplo n.º 51
0
        public static JsonObject Parse(string text, out JsonException exception)
        {
            exception = null;
              if (!text.TrimStart().StartsWith("{"))
              {
            exception = new JsonException("JsonNode should start with {", 0, 0);
            return null;
              }
              Stack<string> path = new Stack<string>();
              Stack<JsonObject> nodeStack = new Stack<JsonObject>();
              JsonObject currentNode = null;
              bool inQuats = false;
              bool isEscaped = false;
              string key = null;
              StringBuilder stringBuilder = new StringBuilder();
              int textLineIndex = 0;
              int textCharIndex = 0;
              int keyLineIndex = 0;
              int keyCharIndex = 0;
              int seperatorLineIndex = 0;
              int seperatorCharIndex = 0;
              int charIndex = 0;
              int lineIndex = 0;
              bool needSeperator = false;
              StringBuilder lineBuilder = new StringBuilder();
              for (int index = 0; index < text.Length; index++)
              {
            char c = text[index];
            lineBuilder.Append(c);
            charIndex++;
            if (lineBuilder.Length > 1 & (c == '\n' || c == '\r'))
            {
              lineIndex++;
              lineBuilder.Remove(0, lineBuilder.Length);
              charIndex = 0;
            }
            if (!inQuats && Char.IsWhiteSpace(c))
            {
              continue;
            }
            if (inQuats && (c != '"' || isEscaped))
            {
              if (stringBuilder.Length == 0)
              {
            textLineIndex = lineIndex;
            textCharIndex = charIndex;
              }
              if (c == '\\' && !isEscaped)
              {
            isEscaped = true;
            continue;
              }
              if (isEscaped)
              {
            switch (c)
            {
              case 't':
                stringBuilder.Append('\t');
                break;
              case '"':
                stringBuilder.Append('"');
                break;
              case '\'':
                stringBuilder.Append('\'');
                break;
              case 'r':
                stringBuilder.Append('\r');
                break;
              case 'n':
                stringBuilder.Append('\n');
                break;
              case '\\':
                stringBuilder.Append('\\');
                break;
              default:
                exception = new JsonException("unknown escape charctar \\" + c, lineIndex, charIndex);
                return null;
            }
            isEscaped = false;
            continue;
              }
              stringBuilder.Append(c);
              continue;
            }
            switch (c)
            {
              case '{':
            {
              if (needSeperator)
              {
                SetError(seperatorLineIndex, seperatorCharIndex, "expected comma.", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              needSeperator = false;
              if (key == null && currentNode == null)
              {
                currentNode = new JsonNode(lineIndex, charIndex);
                nodeStack.Push(currentNode);
                break;
              }
              JsonNode newJsonNode = new JsonNode(lineIndex, charIndex);
              JsonNode parentJsonNode = currentNode as JsonNode;
              if (parentJsonNode != null)
              {
                path.Push(key);
                parentJsonNode.Add(key, newJsonNode, lineIndex, charIndex);
                key = null;
              }
              else
              {
                if (!(currentNode is JsonArray))
                  throw new JsonException("Exspected JsonArray", lineIndex, charIndex);
                path.Push("[" + DeterminArrayIndex(text, index) + "]");
                ((JsonArray)currentNode).Add(newJsonNode);
              }
              nodeStack.Push(currentNode);
              currentNode = newJsonNode;
            }
            break;
              case '}':
            {
              needSeperator = true;
              seperatorCharIndex = charIndex + 1;
              seperatorLineIndex = lineIndex;
              path.Push(key);
              CheckForNumboerAndBool(stringBuilder, currentNode, ref key, textLineIndex, textCharIndex, keyLineIndex, keyCharIndex);
              path.Pop();
              if (currentNode is JsonArray)
              {
                SetError(lineIndex, charIndex, "] expected first.", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              if (nodeStack.Count == 0)
              {
                SetError(lineIndex, charIndex, "To many }", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              if (path.Count > 0)
                path.Pop();
              currentNode = nodeStack.Pop();
            }
            break;
              case '[':
            {
              if (needSeperator)
              {
                SetError(seperatorLineIndex, seperatorCharIndex, "expected comma.", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              needSeperator = false;
              if (key == null && currentNode == null)
              {
                currentNode = new JsonArray(lineIndex, charIndex);
                nodeStack.Push(currentNode);
                break;
              }
              JsonArray newJsonArray = new JsonArray(lineIndex, charIndex);
              JsonNode parentJsonNode = currentNode as JsonNode;
              if (parentJsonNode != null)
              {
                path.Push(key);

                parentJsonNode.Add(key, newJsonArray, lineIndex, charIndex);
                key = null;
              }
              else
              {
                if (!(currentNode is JsonArray))
                  throw new JsonException("Exspected JsonArray", lineIndex, charIndex);
                path.Push("[" + DeterminArrayIndex(text, index) + "]");
                ((JsonArray)currentNode).Add(newJsonArray);
              }
              nodeStack.Push(currentNode);
              currentNode = newJsonArray;
            }
            break;
              case ']':
            {
              needSeperator = true;
              seperatorCharIndex = charIndex + 1;
              seperatorLineIndex = lineIndex;
              path.Push(key);
              CheckForNumboerAndBool(stringBuilder, currentNode, ref key, lineIndex, charIndex, keyLineIndex, keyCharIndex);
              path.Pop();
              if (currentNode is JsonNode)
              {
                SetError(lineIndex, charIndex, "} expected first.", out exception);
                return null;
              }
              if (nodeStack.Count == 0)
              {
                SetError(lineIndex, charIndex, "To many ]", out exception);
                return null;
              }
              path.Pop();
              currentNode = nodeStack.Pop();
            }
            break;
              case ':':
            if (key == null)
            {
              SetError(keyLineIndex, keyCharIndex, "value missing", out exception);
              while (nodeStack.Count > 0)
                currentNode = nodeStack.Pop();
              return currentNode;
            }
            break;
              case '"':
            if (isEscaped)
            {
              stringBuilder.Append("\"");
              isEscaped = false;
              break;
            }
            if (needSeperator)
            {
              SetError(seperatorLineIndex, seperatorCharIndex, "expected comma.", out exception);
              while (nodeStack.Count > 0)
                currentNode = nodeStack.Pop();
              return currentNode;
            }
            if (inQuats)
            {
              inQuats = false;
              JsonNode node = currentNode as JsonNode;
              if (node != null)
              {
                if (key == null)
                {
                  key = stringBuilder.ToString();
                  keyLineIndex = lineIndex;
                  keyCharIndex = charIndex;
                  path.Push(key);

                  path.Pop();
                }
                else
                {
                  path.Push(key);
                  node.Add(key, new JsonValue(stringBuilder.ToString(), textLineIndex, textCharIndex), lineIndex, charIndex);
                  path.Pop();
                  key = null;
                  needSeperator = true;
                  seperatorCharIndex = charIndex + 1;
                  seperatorLineIndex = lineIndex;
                }
              }
              else
              {
                if (!(currentNode is JsonArray))
                  throw new JsonException("Exspected JsonArray", lineIndex, charIndex);
                JsonArray jsonArray = currentNode as JsonArray;
                jsonArray.Add(new JsonValue(stringBuilder.ToString(), textLineIndex, textCharIndex));
              }
              stringBuilder.Remove(0, stringBuilder.Length);
            }
            else
            {
              if (stringBuilder.Length > 0)
              {
                SetError(textLineIndex, textCharIndex, "text in unexpected place", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              inQuats = true;
            }
            break;
              case '\\':
            if (!inQuats)
            {
              SetError(lineIndex, charIndex, "\\ found in wrong place", out exception);
              while (nodeStack.Count > 0)
                currentNode = nodeStack.Pop();
              return currentNode;
            }
            if (isEscaped)
            {
              stringBuilder.Append("\\");
              isEscaped = false;
            }
            else
              isEscaped = true;
            break;
              case ',':
            {
              if (key == null && !needSeperator && currentNode is JsonNode)
              {
                SetError(lineIndex, charIndex, "extra comma found", out exception);
                while (nodeStack.Count > 0)
                  currentNode = nodeStack.Pop();
                return currentNode;
              }
              needSeperator = false;
              path.Push(key);
              CheckForNumboerAndBool(stringBuilder, currentNode, ref key, lineIndex, charIndex, keyLineIndex, keyCharIndex);
              path.Pop();
            }
            break;
              default:
            isEscaped = false;
            if (needSeperator)
            {
              SetError(seperatorLineIndex, seperatorCharIndex, "expected comma.", out exception);
              while (nodeStack.Count > 0)
                currentNode = nodeStack.Pop();
              return currentNode;
            }
            if (stringBuilder.Length == 0)
            {
              textLineIndex = lineIndex;
              textCharIndex = charIndex;
            }
            stringBuilder.Append(c);
            break;
            }
              }
              if (stringBuilder.Length > 0)
            SetError(textLineIndex, textCharIndex, "text in unexpected place", out exception);
              if (key != null)
            SetError(keyLineIndex, keyCharIndex, "value missing", out exception);
              if (nodeStack.Count > 0)
              {
            SetError(lineBuilder.Length > 0 ? lineIndex : lineIndex - 1, charIndex, currentNode is JsonArray ? "missing ]" : "missing }", out exception);
              }
              while (nodeStack.Count > 0)
            currentNode = nodeStack.Pop();
              return currentNode;
        }
Exemplo n.º 52
0
 private JsonNode ParseDictionary()
 {
     if (lexer.GetCurrentTokenType() != TokenType.DictionaryStart)
         throw CreateExpectedException(lexer.GetCurrentToken(), TokenType.DictionaryStart);
     JsonNode result = new JsonNode(NodeType.Dictionary);
     lexer.NextToken();
     while (true)
     {
         if (lexer.GetCurrentTokenType() == TokenType.DictionaryEnd)
         {
             lexer.NextToken();
             break;
         }
         if (lexer.GetCurrentTokenType() != TokenType.String)
             throw CreateExpectedException(lexer.GetCurrentToken(), TokenType.String);
         string key = lexer.GetCurrentToken().Value;
         lexer.NextToken();
         if (lexer.GetCurrentTokenType() != TokenType.Colon)
             throw CreateExpectedException(lexer.GetCurrentToken(), TokenType.Colon);
         lexer.NextToken();
         JsonNode child = Parse();
         result.Add(key, child);
         if (lexer.GetCurrentTokenType() != TokenType.Comma)
         {
             if (lexer.GetCurrentTokenType() == TokenType.DictionaryEnd)
             {
                 lexer.NextToken();
                 break;
             }
             throw CreateExpectedException(lexer.GetCurrentToken(), new TokenType[] { TokenType.DictionaryEnd, TokenType.Comma });
         }
         lexer.NextToken();
     }
     return result;
 }
Exemplo n.º 53
0
 private JsonNode ParseString()
 {
     if (lexer.GetCurrentTokenType() != TokenType.String)
         throw CreateExpectedException(lexer.GetCurrentToken(), TokenType.String);
     JsonNode result = new JsonNode(NodeType.String);
     result.Assign(lexer.GetCurrentToken().Value);
     lexer.NextToken();
     return result;
 }
Exemplo n.º 54
0
 public StageObject(JsonNode json)
 {
     PosX = json["PosX"].Get<double>();
     PosY = json["PosY"].Get<double>();
     PosZ = json["PosZ"].Get<double>();
     RotX = json["RotX"].Get<double>();
     RotY = json["RotY"].Get<double>();
     RotZ = json["RotZ"].Get<double>();
     RotW = json["RotW"].Get<double>();
     PrefabName = json["PrefabName"].Get<string>();
 }
Exemplo n.º 55
0
        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 == "sourceSpace")
                {
                    value.SourceSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
                    continue;
                }

                if (key == "destinationSpace")
                {
                    value.DestinationSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
                    continue;
                }

                if (key == "aimVector")
                {
                    value.AimVector = __constraint__aim_Deserialize_AimVector(kv.Value);
                    continue;
                }

                if (key == "upVector")
                {
                    value.UpVector = __constraint__aim_Deserialize_UpVector(kv.Value);
                    continue;
                }

                if (key == "freezeAxes")
                {
                    value.FreezeAxes = __constraint__aim_Deserialize_FreezeAxes(kv.Value);
                    continue;
                }

                if (key == "weight")
                {
                    value.Weight = kv.Value.GetSingle();
                    continue;
                }
            }
            return(value);
        }
Exemplo n.º 56
0
 public Terrain(JsonNode json)
     : base(json)
 {
 }
Exemplo n.º 57
0
		private void CreateActors(JsonNode root)
		{
			var entityArray = root["layers"][1]["objects"];
			for (int entity = 0; entity < entityArray.NumberOfNodes; entity++)
				CreateActor(entityArray[entity]);
		}
Exemplo n.º 58
0
 object IJsonConverter.FromJson(JsonNode node) => FromJson(node);
Exemplo n.º 59
-1
 public Schema(string path, SchemaManager schemaManager)
 {
     m_path = path;
       m_schemaManager = schemaManager;
       m_jsonNode = (JsonNode)JsonObject.Load(path);
       m_name = System.IO.Path.GetFileName(path);
       m_root = new SchemaObject(m_jsonNode, this);
 }
Exemplo n.º 60
-1
        public string GetValueString(JsonNode value)
        {
            if (value.Type == JsonType.Date)
            {
                return options.DateFormatter.Format((XDate)value);
            }

            return value.ToString();
        }