Пример #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);
                }
            }
        }
Пример #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);
                }
            }
        }