Esempio n. 1
0
        public bool Deserialize(object data)
        {
            JObject jm = data as JObject;

            if (jm == null)
            {
                return(false);
            }

            if (jm["BoneCount"] != null)
            {
                BoneCount = jm["BoneCount"].Value <int>();
            }

            if (jm["Mesh"] != null)
            {
                Mesh.Deserialize(jm["Mesh"]);
            }

            //
            JArray jmats = jm["Materials"].Value <JArray>();

            foreach (JObject jmat in jmats)
            {
                string linked_subsetname = jmat["LinkedSubset"].Value <string>().ToLower();
                if (Materials.ContainsKey(linked_subsetname) == false)
                {
                    string    mat_type = jmat["Type"].Value <string>();
                    CMaterial material = CMaterial.Create(mat_type, linked_subsetname);

                    if (material.Deserialize(jmat) == false)
                    {
                        continue;
                    }

                    Materials.Add(linked_subsetname, material);
                }
            }

            // anim
            JObject janimCtrl = jm["AnimCtrl"].Value <JObject>();
            JArray  janims    = janimCtrl["Anims"].Value <JArray>();

            if (janims.Count != 0)
            {
                Anim.Deserialize(janims.First.Value <JObject>());
            }

            return(true);
        }