public static void WriteVertexDeclaration(TWXmlNode node, VertexDeclaration decl)
        {
            if (decl == null)
            {
                node.Value = "NULL"; return;
            }
            //TWXmlNode node = parentNode.CreateChildNode( name );

            VertexElement[] elements = decl.GetVertexElements();

            TWXmlNode elementsNode = node.CreateChildNode("Elements");

            elementsNode.AddAttribute("count", elements.Length.ToString());

            for (int i = 0; i < elements.Length; i++)
            {
                TWXmlNode elementNode = elementsNode.CreateChildNode("VertexElement");
                elementNode.AddChildNode("Offset", elements[i].Offset.ToString());
                elementNode.AddChildNode("Stream", elements[i].Stream.ToString());
                elementNode.AddChildNode("UsageIndex", elements[i].UsageIndex.ToString());
                elementNode.AddChildNode("VertexElementFormat", elements[i].VertexElementFormat.ToString());
                elementNode.AddChildNode("VertexElementMethod", elements[i].VertexElementMethod.ToString());
                elementNode.AddChildNode("VertexElementUsage", elements[i].VertexElementUsage.ToString());
            }
        }
 public static void WriteColor(TWXmlNode node, Color c)
 {
     node = node.CreateChildNode("Color");
     node.AddAttributeInt("A", c.A);
     node.AddAttributeInt("R", c.R);
     node.AddAttributeInt("G", c.G);
     node.AddAttributeInt("B", c.B);
 }
        public static void WriteMatrix(TWXmlNode node, Matrix mat)
        {
            TWXmlNode rowMatrixNode = node.CreateChildNode("MatrixRows");

            WriteFloatArray(rowMatrixNode, new float[] {
                mat.M11, mat.M12, mat.M13, mat.M14,
                mat.M21, mat.M22, mat.M23, mat.M24,
                mat.M31, mat.M32, mat.M33, mat.M34,
                mat.M41, mat.M42, mat.M43, mat.M44
            });
        }
 public static void WriteVector3Array(TWXmlNode node, Vector3[] data)
 {
     if (data == null)
     {
         node.Value = "NULL"; return;
     }
     node.AddAttributeInt("Count", data.Length);
     for (int i = 0; i < data.Length; i++)
     {
         TWXmlNode nodeVector = node.CreateChildNode("Vector3");
         nodeVector.AddAttribute("X", data[i].X.ToString());
         nodeVector.AddAttribute("Y", data[i].Y.ToString());
         nodeVector.AddAttribute("Z", data[i].Z.ToString());
     }
 }
        public static void WriteVertexBuffer(TWXmlNode node, VertexBuffer vertexBuffer)
        {
            if (vertexBuffer == null)
            {
                node.Value = "NULL"; return;
            }
            byte[] data = new byte[vertexBuffer.SizeInBytes];
            vertexBuffer.GetData <byte>(data);

            if (data.Length != vertexBuffer.SizeInBytes)
            {
                throw new Exception("While writing this method, i assumed those were equal");
            }

            node.AddChildNode("BufferUsage", vertexBuffer.BufferUsage.ToString());
            TWXmlNode dataNode = node.CreateChildNode("Data");

            dataNode.AddAttribute("length", data.Length.ToString());

            //TODO: this data should be contained in a 'CData' block
            dataNode.AddCData(Convert.ToBase64String(data));
        }
 public static void WriteBoundingBox(TWXmlNode node, BoundingBox box)
 {
     WriteVector3(node.CreateChildNode("Min"), box.Min);
     WriteVector3(node.CreateChildNode("Max"), box.Max);
 }
 public static void WriteBoundingSphere(TWXmlNode node, BoundingSphere sphere)
 {
     WriteVector3(node.CreateChildNode("Center"), sphere.Center);
     node.AddChildNode("Radius", sphere.Radius.ToString());
 }