/// <summary> /// Adds a new component to the set. /// </summary> /// <param name="component">The component to add</param> internal void AddComponent(MeshCube component) { if (Components == null) { Components = new List <MeshCube>(); } Components.Add(component); }
public void Seal() { BoundingBox = new MeshCube { Length = Components.Max(c => c.RelPosition.X + c.Length), Width = Components.Max(c => c.RelPosition.Y + c.Width), Height = Components.Max(c => c.RelPosition.Z + c.Height) }; if (ComponentsByID == null) { ComponentsByID = Components.ToArray(); } }
public void LoadXML(XmlNode node) { // Read components int componentID = 0; foreach (var childNode in node.FirstChild.ChildNodes.OfType <XmlNode>()) { MeshCube cube = new MeshCube(); cube.ID = componentID++; cube.LoadXML(childNode); AddComponent(cube); } // Seal Seal(); }
public void LoadXML(XmlNode node) { // ID this.ID = int.Parse(node.Attributes[Helper.Check(() => this.ID)].Value, ExportationConstants.XML_FORMATTER); // Mesh MeshCube mesh = new MeshCube(); mesh.LoadXML(node.SelectSingleNode(ExportationConstants.XML_MESHCUBE_IDENT)); Mesh = mesh; // Virtual pieces VirtualPieces = new List <VirtualPiece>(); if (node.SelectSingleNode(ExportationConstants.XML_VIRTUAL_PIECE_COLLECTION_IDENT) != null) { foreach (var virtualPieceNode in node.SelectSingleNode(ExportationConstants.XML_VIRTUAL_PIECE_COLLECTION_IDENT).ChildNodes.OfType <XmlNode>()) { VirtualPiece virtualPiece = new VirtualPiece(); virtualPiece.LoadXML(virtualPieceNode); virtualPiece.Container = this; VirtualPieces.Add(virtualPiece); } } // Slants Slants = new List <Slant>(); if (node.SelectSingleNode(ExportationConstants.XML_SLANT_COLLECTION_IDENT) != null) { foreach (var slantNode in node.SelectSingleNode(ExportationConstants.XML_SLANT_COLLECTION_IDENT).ChildNodes.OfType <XmlNode>()) { Slant slant = new Slant(); slant.LoadXML(slantNode); slant.Container = this; Slants.Add(slant); } } // Seal this.Seal(); }