/*public static void WriteTransformation( TWXmlNode node, Transformation transformation ) * { * WriteVector3( node.CreateChildNode( "Scaling" ), transformation.Scaling ); * WriteQuaternion( node.CreateChildNode( "Rotation" ), transformation.Rotation ); * WriteVector3( node.CreateChildNode( "Translation" ), transformation.Translation ); * } * * public static Transformation ReadTransformation( TWXmlNode node ) * { * Transformation transformation = new Transformation(); * transformation.Scaling = ReadVector3( node.FindChildNode( "Scaling" ) ); * transformation.Rotation = ReadQuaternion( node.FindChildNode( "Rotation" ) ); * transformation.Translation = ReadVector3( node.FindChildNode( "Translation" ) ); * * * return transformation; * }*/ private static void WriteQuaternion(TWXmlNode node, Quaternion rotation) { node.AddChildNode("X", rotation.X.ToString()); node.AddChildNode("Y", rotation.Y.ToString()); node.AddChildNode("Z", rotation.Z.ToString()); node.AddChildNode("W", rotation.W.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 WriteIndexBuffer(TWXmlNode node, IndexBuffer indexBuffer) { if (indexBuffer == null) { node.Value = "NULL"; return; } byte[] data = new byte[indexBuffer.SizeInBytes]; indexBuffer.GetData <byte>(data); if (data.Length != indexBuffer.SizeInBytes) { throw new Exception("While writing this method, i assumed those were equal"); } node.AddChildNode("BufferUsage", indexBuffer.BufferUsage.ToString()); node.AddChildNode("IndexElementSize", indexBuffer.IndexElementSize.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 WriteBoundingSphere(TWXmlNode node, BoundingSphere sphere) { WriteVector3(node.CreateChildNode("Center"), sphere.Center); node.AddChildNode("Radius", sphere.Radius.ToString()); }
public static void WriteVector2(TWXmlNode node, Vector2 v) { node.AddChildNode("X", v.X.ToString()); node.AddChildNode("Y", v.Y.ToString()); }