Ejemplo n.º 1
0
        protected override BoneWeight[] Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, BoneWeight[] existingInstance)
        {
            string[] s = input.Xml.ReadContentAsString().Trim().Split(' ');
            if (s.Length > 0 && s.Length % 8 != 0)
            {
                throw new Exception("Too few data items for the BoneWeight");
            }
            BoneWeight[] boneWeights = new BoneWeight[(int)(s.Length / 8)];
            int          index       = 0;

            for (int i = 0; i < s.Length; i += 8, index++)
            {
                BoneWeight bw = new BoneWeight();
                bw.weights.x       = Single.Parse(s[i]);
                bw.weights.y       = Single.Parse(s[i + 1]);
                bw.weights.z       = Single.Parse(s[i + 2]);
                bw.weights.w       = Single.Parse(s[i + 3]);
                bw.boneIndex0      = Int32.Parse(s[i + 4]);
                bw.boneIndex1      = Int32.Parse(s[i + 5]);
                bw.boneIndex2      = Int32.Parse(s[i + 6]);
                bw.boneIndex3      = Int32.Parse(s[i + 7]);
                boneWeights[index] = bw;
            }
            return(boneWeights);
        }
Ejemplo n.º 2
0
        protected override AudioClip Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, AudioClip existingInstance)
        {
            string    s = input.Xml.ReadContentAsString();
            AudioClip c = new AudioClip()
            {
                clip = s
            };

            return(c);
        }
Ejemplo n.º 3
0
        protected override Color Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, Color existingInstance)
        {
            string s = input.Xml.ReadContentAsString();

            if (s.Length != 8 && s.Length != 6)
            {
                throw new Exception("Color string must either be AARRGGBB or RRGGBB. Was: " + s);
            }
            return(Color.Parse(s));
        }
Ejemplo n.º 4
0
        protected override Guid Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, Guid existingInstance)
        {
            string s = input.Xml.ReadContentAsString();
            Guid   g;

            if (Guid.TryParse(s, out g))
            {
                return(g);
            }
            return(Guid.Empty);
        }
Ejemplo n.º 5
0
        protected override Rect Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, Rect existingInstance)
        {
            string[] s = input.Xml.ReadContentAsString().Split(' ');
            if (s.Length != 4)
            {
                throw new Exception("We need four floats to convert to a Rect. Was " + s);
            }
            Rect r = new Rect();

            r.x      = Single.Parse(s[0]);
            r.y      = Single.Parse(s[1]);
            r.width  = Single.Parse(s[2]);
            r.height = Single.Parse(s[3]);
            return(r);
        }
Ejemplo n.º 6
0
        protected override BoneWeight Deserialize(IntermediateReader input, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format, BoneWeight existingInstance)
        {
            string[] s = input.Xml.ReadContentAsString().Trim().Split(' ');
            if (s.Length != 8)
            {
                throw new Exception("Too few data items for the BoneWeight");
            }
            BoneWeight bw = new BoneWeight();

            bw.weights.x  = Single.Parse(s[0]);
            bw.weights.y  = Single.Parse(s[1]);
            bw.weights.z  = Single.Parse(s[2]);
            bw.weights.w  = Single.Parse(s[3]);
            bw.boneIndex0 = Int32.Parse(s[4]);
            bw.boneIndex1 = Int32.Parse(s[5]);
            bw.boneIndex2 = Int32.Parse(s[6]);
            bw.boneIndex3 = Int32.Parse(s[7]);
            return(bw);
        }
Ejemplo n.º 7
0
 protected override void Serialize(IntermediateWriter output, BoneWeight w, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format)
 {
     output.Xml.WriteString(String.Format("{0} {1} {2} {3} {4} {5} {6} {7}", w.weights.x, w.weights.y, w.weights.z, w.weights.w, w.boneIndex0, w.boneIndex1, w.boneIndex2, w.boneIndex3));
 }
Ejemplo n.º 8
0
 protected override void Serialize(IntermediateWriter output, Rect value, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 protected override void Serialize(IntermediateWriter output, Guid value, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format)
 {
     output.Xml.WriteElementString(format.ElementName, value.ToString());
 }
Ejemplo n.º 10
0
 protected override void Serialize(IntermediateWriter output, Color c, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format)
 {
     output.Xml.WriteElementString(format.ElementName, ((int)(c.a * 255)).ToString("X") + ((int)(c.r * 255)).ToString("X") + ((int)(c.g * 255)).ToString("X") + ((int)(c.b * 255)).ToString("X"));
 }