コード例 #1
0
        public static BoundingBox ReadBoundingBox(TWXmlNode node)
        {
            Vector3 min = ReadVector3(node.FindChildNode("Min"));
            Vector3 max = ReadVector3(node.FindChildNode("Max"));

            return(new BoundingBox(min, max));
        }
コード例 #2
0
        public static VertexDeclaration ReadVertexDeclaration(XNAGame game, TWXmlNode node)
        {
            if (node.Value == "NULL")
            {
                return(null);
            }

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

            VertexElement[] elements = new VertexElement[elementsNode.GetAttributeInt("count")];

            TWXmlNode[] elementNodes = elementsNode.FindChildNodes("VertexElement");
            if (elementNodes.Length != elements.Length)
            {
                throw new InvalidOperationException("Invalid XML format!");
            }
            for (int i = 0; i < elementNodes.Length; i++)
            {
                TWXmlNode     elementNode = elementNodes[i];
                VertexElement element     = new VertexElement();
                element.Offset              = short.Parse(elementNode.ReadChildNodeValue("Offset"));
                element.Stream              = short.Parse(elementNode.ReadChildNodeValue("Stream"));
                element.UsageIndex          = byte.Parse(elementNode.ReadChildNodeValue("UsageIndex"));
                element.VertexElementFormat = (VertexElementFormat)System.Enum.Parse(typeof(VertexElementFormat), elementNode.ReadChildNodeValue("VertexElementFormat"));
                element.VertexElementMethod = (VertexElementMethod)System.Enum.Parse(typeof(VertexElementMethod), elementNode.ReadChildNodeValue("VertexElementMethod"));
                element.VertexElementUsage  = (VertexElementUsage)System.Enum.Parse(typeof(VertexElementUsage), elementNode.ReadChildNodeValue("VertexElementUsage"));
                elements[i] = element;
            }

            return(new VertexDeclaration(game.GraphicsDevice, elements));
        }
コード例 #3
0
        public static BoundingSphere ReadBoundingSphere(TWXmlNode node)
        {
            Vector3 center = ReadVector3(node.FindChildNode("Center"));
            float   radius = float.Parse(node.ReadChildNodeValue("Radius"));

            return(new BoundingSphere(center, radius));
        }
コード例 #4
0
        public static Color ReadColor(TWXmlNode node)
        {
            node = node.FindChildNode("Color");
            Color c = new Color((byte)node.GetAttributeInt("R"), (byte)node.GetAttributeInt("G"), (byte)node.GetAttributeInt("B")
                                , (byte)node.GetAttributeInt("A"));


            return(c);
        }
コード例 #5
0
        public static Matrix ReadMatrix(TWXmlNode node)
        {
            TWXmlNode rowMatrixNode = node.FindChildNode("MatrixRows");

            float[] floats = ReadFloatArray(rowMatrixNode);
            Matrix  mat    = new Matrix(
                floats[0], floats[1], floats[2], floats[3],
                floats[4], floats[5], floats[6], floats[7],
                floats[8], floats[9], floats[10], floats[11],
                floats[12], floats[13], floats[14], floats[15]);

            return(mat);
        }
コード例 #6
0
        public static VertexBuffer ReadVertexBuffer(TWXmlNode node, XNAGame game)
        {
            if (node.Value == "NULL")
            {
                return(null);
            }

            BufferUsage bufferUsage = (BufferUsage)Enum.Parse(typeof(BufferUsage), node.ReadChildNodeValue("BufferUsage"));

            TWXmlNode dataNode = node.FindChildNode("Data");
            int       length   = dataNode.GetAttributeInt("length");

            byte[] data = new byte[length];
            data = Convert.FromBase64String(dataNode.ReadCData());


            VertexBuffer vb = new VertexBuffer(game.GraphicsDevice, length, bufferUsage);

            vb.SetData <byte>(data);

            return(vb);
        }