Exemplo n.º 1
0
        public void SetMetricsAndCreateChildrenFromXml(ISkeleton skeleton, XElement boneData)
        {
            _relativePosition = new Vector2((float)boneData.Attribute("offset-x"), (float)boneData.Attribute("offset-y"));
            _relativeRotation = boneData.Attribute("rotation") == null ? 0.0f : MathHelper.ToRadians((float)boneData.Attribute("rotation"));
            _relativeScale    = boneData.Attribute("scale") == null ? 1.0f : (float)boneData.Attribute("scale");
            _relativeDepth    = (float)boneData.Attribute("depth");
            _relativeTint     = Color.White;

            if (boneData.Elements("bone") != null)
            {
                foreach (XElement bone in boneData.Elements("bone"))
                {
                    StorableBone newBone = new StorableBone();
                    newBone.ID = bone.Attribute("id").Value;
                    skeleton.AddBone(newBone, boneData.Attribute("id").Value);
                    newBone.SetMetricsAndCreateChildrenFromXml(skeleton, bone);
                }
            }
        }
Exemplo n.º 2
0
        public void SetMetricsAndCreateChildrenFromXml(ISkeleton skeleton, XElement boneData)
        {
            _relativePosition = new Vector2((float)boneData.Attribute("offset-x"), (float)boneData.Attribute("offset-y"));
            _relativeRotation = boneData.Attribute("rotation") == null ? 0.0f : MathHelper.ToRadians((float)boneData.Attribute("rotation"));
            _relativeScale = boneData.Attribute("scale") == null ? 1.0f : (float)boneData.Attribute("scale");
            _relativeDepth = (float)boneData.Attribute("depth");
            _relativeTint = Color.White;

            if (boneData.Elements("bone") != null)
            {
                foreach (XElement bone in boneData.Elements("bone"))
                {
                    StorableBone newBone = new StorableBone();
                    newBone.ID = bone.Attribute("id").Value;
                    skeleton.AddBone(newBone, boneData.Attribute("id").Value);
                    newBone.SetMetricsAndCreateChildrenFromXml(skeleton, bone);
                }
            }
        }
        public void CreateBonesFromDataManager(string skeletonName)
        {
            if (SkeletonDataManager.Skeletons.ContainsKey(skeletonName))
            {
                StorableBone newBone = new StorableBone();
                newBone.ID = SkeletonDataManager.Skeletons[skeletonName].Element("bone").Attribute("id").Value;
                AddBone(newBone, "");
                newBone.SetMetricsAndCreateChildrenFromXml(this, SkeletonDataManager.Skeletons[skeletonName].Element("bone"));

                RecalculateBonePositions();
                RecalculateBoneRenderDepths();
                RecalculateSkinTints();
            }
        }