public static IrrScene Get(IrrData data) { IrrScene scene = new IrrScene(); Copy(data, scene); return scene; }
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; } } }
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; }
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; }