Exemple #1
0
        private static void WriteAttributes(XmlDocument doc, List <BfshaLibrary.Attribute> attributes, ResDict attributeDictionary, string Name, XmlNode node)
        {
            XmlNode rootNode = doc.CreateElement(Name);

            foreach (var attribute in attributes)
            {
                XmlNode childNode = doc.CreateElement("attribute");
                AddAttribute(doc, "name", attributeDictionary.GetKey(attribute.Index), childNode);
                AddAttribute(doc, "location", attribute.Location.ToString(), childNode);
                AddAttribute(doc, "index", attribute.Index.ToString(), childNode);
                rootNode.AppendChild(childNode);
            }
            node.AppendChild(rootNode);
        }
Exemple #2
0
        private static void WriteSamplers(XmlDocument doc, List <Sampler> samplers, ResDict samplerDictionary, string Name, XmlNode node)
        {
            XmlNode rootNode = doc.CreateElement(Name);

            foreach (var sampler in samplers)
            {
                XmlNode childNode = doc.CreateElement("sampler");
                AddAttribute(doc, "name", samplerDictionary.GetKey(sampler.Index), childNode);
                AddAttribute(doc, "alt", sampler.AltAnnotation, childNode);
                AddAttribute(doc, "index", sampler.Index.ToString(), childNode);
                rootNode.AppendChild(childNode);
            }
            node.AppendChild(rootNode);
        }
Exemple #3
0
        private static void WriteUniformBlocks(XmlDocument doc, List <UniformBlock> uniformBlocks, ResDict uniformBlockeDictionary, string Name, XmlNode node)
        {
            XmlNode rootNode = doc.CreateElement(Name);

            foreach (var block in uniformBlocks)
            {
                XmlNode childNode = doc.CreateElement("uniform_block");
                AddAttribute(doc, "name", uniformBlockeDictionary.GetKey(block.Index), childNode);
                AddAttribute(doc, "size", block.Size.ToString(), childNode);
                AddAttribute(doc, "type", block.Type.ToString(), childNode);
                rootNode.AppendChild(childNode);

                int ind = 0;
                foreach (var uniform in block.Uniforms)
                {
                    XmlNode uniformsNode = doc.CreateElement("uniform");
                    if (ind < block.UniformDict.Count && ind >= 0)
                    {
                        AddAttribute(doc, "name", block.UniformDict.GetKey(ind), uniformsNode);
                    }
                    AddAttribute(doc, "index", uniform.Index.ToString(), uniformsNode);
                    AddAttribute(doc, "block_index", uniform.BlockIndex.ToString(), uniformsNode);
                    AddAttribute(doc, "offset", uniform.Offset.ToString(), uniformsNode);

                    if (ind < (block.UniformDict.Count - 1) && ind >= 0)
                    {
                        uint nextOffset    = block.Uniforms[ind + 1].Offset;
                        uint currentOffset = block.Uniforms[ind].Offset;

                        uint Size = nextOffset - currentOffset;

                        AddAttribute(doc, "size", Size.ToString(), uniformsNode);
                    }
                    if (ind == (block.UniformDict.Count - 1))
                    {
                        AddAttribute(doc, "size", (block.Size - uniform.Offset).ToString(), uniformsNode);
                    }

                    childNode.AppendChild(uniformsNode);

                    ind++;
                }
            }
            node.AppendChild(rootNode);
        }