Ejemplo n.º 1
0
        public static VertexLayout LoadFromXPathNavigator(XPathNavigator navigator)
        {
            if (navigator == null)
            {
                return null;
            }

            VertexLayout vertexLayout = new VertexLayout();

            //name
            vertexLayout.Name = navigator.GetAttribute("Name", String.Empty);

            //name hash
            vertexLayout.NameHash = Cryptography.JenkinsOneAtATime(vertexLayout.Name);

            //entries
            XPathNodeIterator entries = navigator.Select("./Array[@Name='Entries']/Object[@Class='LayoutEntry']");

            while (entries.MoveNext())
            {
                navigator = entries.Current;

                VertexLayout.Entry entry = new Entry();

                //stream
                entry.Stream = UInt32.Parse(navigator.GetAttribute("Stream", String.Empty));

                //data type
                string dataTypeString = navigator.GetAttribute("Type", String.Empty);
                Entry.GetDataTypeFromString(dataTypeString, out entry.DataType);

                //data usage
                string dataUsageString = navigator.GetAttribute("Usage", String.Empty);
                Entry.GetDataUsageFromString(dataUsageString, out entry.DataUsage);

                //data usage index
                entry.DataUsageIndex = UInt32.Parse(navigator.GetAttribute("UsageIndex", String.Empty));

                vertexLayout.Entries.Add(entry);
            }

            return vertexLayout;
        }
Ejemplo n.º 2
0
        public static VertexLayout LoadFromXPathNavigator(XPathNavigator navigator)
        {
            if (navigator == null)
            {
                return(null);
            }

            VertexLayout vertexLayout = new VertexLayout();

            //name
            vertexLayout.Name = navigator.GetAttribute("Name", String.Empty);

            //name hash
            vertexLayout.NameHash = Cryptography.JenkinsOneAtATime(vertexLayout.Name);

            //entries
            XPathNodeIterator entries = navigator.Select("./Array[@Name='Entries']/Object[@Class='LayoutEntry']");

            while (entries.MoveNext())
            {
                navigator = entries.Current;

                VertexLayout.Entry entry = new Entry();

                //stream
                entry.Stream = UInt32.Parse(navigator.GetAttribute("Stream", String.Empty));

                //data type
                string dataTypeString = navigator.GetAttribute("Type", String.Empty);
                Entry.GetDataTypeFromString(dataTypeString, out entry.DataType);

                //data usage
                string dataUsageString = navigator.GetAttribute("Usage", String.Empty);
                Entry.GetDataUsageFromString(dataUsageString, out entry.DataUsage);

                //data usage index
                entry.DataUsageIndex = UInt32.Parse(navigator.GetAttribute("UsageIndex", String.Empty));

                vertexLayout.Entries.Add(entry);
            }

            return(vertexLayout);
        }
Ejemplo n.º 3
0
        private void loadVertexLayoutsByXPathNavigator(XPathNavigator navigator)
        {
            //material definitions
            XPathNodeIterator vertexLayouts = null;

            try
            {
                vertexLayouts = navigator.Select("/Object/Array[@Name='InputLayouts']/Object[@Class='InputLayout']");
            }
            catch (Exception)
            {
                return;
            }

            while (vertexLayouts.MoveNext())
            {
                VertexLayout vertexLayout = VertexLayout.LoadFromXPathNavigator(vertexLayouts.Current);

                if (vertexLayout != null && false == VertexLayouts.ContainsKey(vertexLayout.NameHash))
                {
                    VertexLayouts.Add(vertexLayout.NameHash, vertexLayout);
                }
            }
        }