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 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 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));
        }