Пример #1
0
        public static IrrScene Get(IrrData data)
        {
            IrrScene scene = new IrrScene();
            Copy(data, scene);

            return scene;
        }
Пример #2
0
        public static void Copy(IrrData data, IrrScene scene)
        {
            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Attr.Name))
                    continue;

                switch (child.Attr.Name.ToLower())
                {
                    case "name":
                        scene.Name = child.Attr.Value as string;
                        break;
                    case "id":
                        scene.ID = (int)child.Attr.Value;
                        break;
                    case "ambientlight":
                        scene.AmbientLight = child.Attr.Value as float[];
                        break;
                }
            }
        }
Пример #3
0
        private IrrScene CreateSceneFromData(IrrData data)
        {
            IrrScene scene = new IrrScene();
            IrrData attributeData = Parser.FindFromName(data, "attributes");
            IrrScene.Copy(attributeData, scene);

            foreach (IrrData child in data.Children)
            {
                if (child.Name == "node")
                    scene.AddNode(GetNode(child));
            }

            return scene;
        }
Пример #4
0
        public bool Run(Stream stream)
        {
            if (stream == null)
                return false;

            XmlDocument doc = new XmlDocument();
            doc.Load(stream);

            IrrData data = new IrrData();
            data.Name = "root";
            foreach (XmlNode node in doc.ChildNodes)
                data.Children.Add(RecursiveNode(doc, node));

            IrrData sceneData = FindFromName(data, "irr_scene");
            if (sceneData == null)
                return false;

            scene = CreateSceneFromData(sceneData);

            return true;
        }