/// <summary> /// Constructor /// </summary> /// <param name="device">Device</param> /// <param name="model">Model Data</param> public SharpModel(SharpDevice device, ModelData model) { this.Name = model.Name; this.Device = device; Children = new List<Node>(); Geometries = new List<Geometry>(); Animations = new List<AnimationManager>(); foreach (var m in model.Nodes) { var c = new Node(Device, m, this); Children.Add(c); } //Animations Animations = new List<AnimationManager>(); foreach (Animation anim in model.Animations) { //carica le animazioni Animations.Add(new AnimationManager(anim)); } Initialize(); SetTime(0); }
/// <summary> /// Load From File /// </summary> /// <param name="filename">Filename</param> /// <param name="association">Custom Semantic Association</param> /// <returns>Model</returns> public static ModelData Import(string filename, SemanticAssociations association) { ModelData data = new ModelData(); XDocument doc = XDocument.Load(filename); //search for visual scene //instance_visual_scene XElement scene = doc.GetNode("instance_visual_scene"); if (scene == null) return null; XElement sceneReference = doc.GetReference(scene); data.Name = sceneReference.GetAttribute("name"); //Search for Nodes foreach (XElement c in sceneReference.GetChildren("node")) { data.Nodes.Add(LoadNodes(c, association)); } //Search for Animations XElement animation = doc.GetNode("library_animations"); Animation anim = new Animation(); if (animation != null) { var list = animation.GetNodes("animation"); foreach (XElement a in list) anim.Nodes.Add(CreateAnimationTrack(a)); } data.Animations.Add(anim); return data; }