Пример #1
0
        public static MaterialDefinition LoadFromXPathNavigator(XPathNavigator navigator)
        {
            if (navigator == null)
            {
                return null;
            }

            MaterialDefinition materialDefinition = new MaterialDefinition();

            //name
            materialDefinition.Name = navigator.GetAttribute("Name", string.Empty);
            materialDefinition.NameHash = Cryptography.JenkinsOneAtATime(materialDefinition.Name);

            //type
            materialDefinition.Type = navigator.GetAttribute("Type", string.Empty);
            materialDefinition.TypeHash = Cryptography.JenkinsOneAtATime(materialDefinition.Type);

            //draw styles
            XPathNodeIterator entries = navigator.Select("./Array[@Name='DrawStyles']/Object[@Class='DrawStyle']");

            while (entries.MoveNext())
            {
                DrawStyle drawStyle = DrawStyle.LoadFromXPathNavigator(entries.Current);

                if (drawStyle != null)
                {
                    materialDefinition.DrawStyles.Add(drawStyle);
                }
            }

            return materialDefinition;
        }
Пример #2
0
        public static MaterialDefinition LoadFromXPathNavigator(XPathNavigator navigator)
        {
            if (navigator == null)
            {
                return(null);
            }

            MaterialDefinition materialDefinition = new MaterialDefinition();

            //name
            materialDefinition.Name     = navigator.GetAttribute("Name", string.Empty);
            materialDefinition.NameHash = Cryptography.JenkinsOneAtATime(materialDefinition.Name);

            //type
            materialDefinition.Type     = navigator.GetAttribute("Type", string.Empty);
            materialDefinition.TypeHash = Cryptography.JenkinsOneAtATime(materialDefinition.Type);

            //draw styles
            XPathNodeIterator entries = navigator.Select("./Array[@Name='DrawStyles']/Object[@Class='DrawStyle']");

            while (entries.MoveNext())
            {
                DrawStyle drawStyle = DrawStyle.LoadFromXPathNavigator(entries.Current);

                if (drawStyle != null)
                {
                    materialDefinition.DrawStyles.Add(drawStyle);
                }
            }

            return(materialDefinition);
        }
Пример #3
0
        public MaterialDefinition GetMaterialDefinitionFromHash(UInt32 materialDefinitionHash)
        {
            MaterialDefinition materialDefinition = null;

            try
            {
                MaterialDefinitions.TryGetValue(materialDefinitionHash, out materialDefinition);
            }
            catch (Exception)
            {
                throw new Exception("Material definition could not be found.");
            }

            return(materialDefinition);
        }
Пример #4
0
        private void loadMaterialDefinitionsByXPathNavigator(XPathNavigator navigator)
        {
            XPathNodeIterator materialDefinitions = null;

            try
            {
                materialDefinitions = navigator.Select("/Object/Array[@Name='MaterialDefinitions']/Object[@Class='MaterialDefinition']");
            }
            catch (Exception)
            {
                return;
            }

            while (materialDefinitions.MoveNext())
            {
                MaterialDefinition materialDefinition = MaterialDefinition.LoadFromXPathNavigator(materialDefinitions.Current);

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