/// <summary> /// Adds the given FieldNodeGroup to the childNodeGroups Dictionary. /// </summary> /// <param name="nodeGroup"></param> public void AddNodeGroup(FieldNodeGroup nodeGroup) { if (!childNodeGroups.ContainsKey(nodeGroup.NodeGroupID)) { childNodeGroups.Add(nodeGroup.NodeGroupID, nodeGroup); } }
/// <summary> /// Iterates through each child FieldNodeGroup and adds all FieldNodes to the given FieldNodeGroup. /// </summary> /// <param name="reader"></param> /// <param name="fieldNodeGroup"></param> private static void ReadFieldNodeGroup_2_2(XmlReader reader, FieldNodeGroup fieldNodeGroup) { foreach (string name in IOUtilities.AllElements(reader)) { switch (name) { case "Node": // Add the FieldNode to fieldNodeGroup. fieldNodeGroup.AddNode(ReadFieldNode_2_2(reader.ReadSubtree())); break; case "NodeGroup": // If an ID has not been assigned to the current FieldNodeGroup. if (fieldNodeGroup.NodeGroupID.Equals(BXDFProperties.BXDF_DEFAULT_NAME)) { // Assign the ID attribute value to the NodeGroupID property. fieldNodeGroup.NodeGroupID = reader["ID"]; } else { // Creates a new FieldNodeGroup. FieldNodeGroup childNodeGroup = new FieldNodeGroup(BXDFProperties.BXDF_DEFAULT_NAME); // Re-iterate as the childNodeGroup. ReadFieldNodeGroup_2_2(reader.ReadSubtree(), childNodeGroup); // Add the processed FieldNodeGroup to fieldNodeGroup. fieldNodeGroup.AddNodeGroup(childNodeGroup); } break; } } }
/// <summary> /// Initailizes a new instance of the FieldDefinition class. /// </summary> /// <param name="guid"></param> protected FieldDefinition(Guid guid, string name) { GUID = guid; NodeGroup = new FieldNodeGroup(name); propertySets = new Dictionary <string, PropertySet>(); mesh = new BXDAMesh(GUID); }
/// <summary> /// Used for setting or getting a FieldNode from the path supplied. /// </summary> /// <param name="path"></param> /// <returns></returns> public FieldNode this[string path] { set { ProcessNextChild(path, new HandleChildInfo((string childName, string childPath, bool lastChild) => { if (lastChild) { FieldNode node = GetNode(childName); if (node == null) { AddNode(value); } else { node = value; } } else { FieldNodeGroup nodeGroup = GetNodeGroup(childName); if (nodeGroup == null) { nodeGroup = AddNodeGroup(childName); } nodeGroup[childPath] = value; } return(null); })); } get { return(ProcessNextChild(path, new HandleChildInfo((string childName, string childPath, bool lastChild) => { if (lastChild) { return GetNode(childName); } else { FieldNodeGroup nodeGroup = GetNodeGroup(childName); if (nodeGroup == null) { return null; } return nodeGroup[childPath]; } }))); } }
/// <summary> /// Adds a new FieldNodeGroup with the given ID. /// </summary> /// <param name="nodeGroupID"></param> public FieldNodeGroup AddNodeGroup(string nodeGroupID) { if (!childNodeGroups.ContainsKey(nodeGroupID)) { FieldNodeGroup nodeGroup = new FieldNodeGroup(nodeGroupID); childNodeGroups.Add(nodeGroupID, nodeGroup); return(nodeGroup); } return(null); }
/// <summary> /// Writes all the data included in a FieldNodeGroup. /// </summary> /// <param name="writer"></param> /// <param name="fieldNodeGroup"></param> private static void WriteFieldNodeGroup(XmlWriter writer, FieldNodeGroup fieldNodeGroup) { // Starts the assembly element. writer.WriteStartElement("NodeGroup"); // Writes the NodeGroupID property. writer.WriteAttributeString("ID", fieldNodeGroup.NodeGroupID); foreach (FieldNode node in fieldNodeGroup.EnumerateFieldNodes()) { // Starts the element. writer.WriteStartElement("Node"); // Writes the NodeID attribute. writer.WriteAttributeString("ID", node.NodeID); // Writes the Position property as a BXDVector3. WriteBXDVector3(writer, node.Position, "Position"); // Write the EulerRotation property as a BXDQuaternion. WriteBXDQuaternion(writer, node.Rotation, "Rotation"); // Writes the MeshID element. writer.WriteElementString("SubMeshID", node.SubMeshID.ToString()); // Writes the CollisionMeshID element if a collider has been assigned. if (node.CollisionMeshID != -1) { writer.WriteElementString("CollisionMeshID", node.CollisionMeshID.ToString()); } // Writes the PropertySetID element if a PropertySet has been assigned. if (node.PropertySetID != BXDF_DEFAULT_NAME) { writer.WriteElementString("PropertySetID", node.PropertySetID); } // Ends the element. writer.WriteEndElement(); } foreach (FieldNodeGroup nodeGroup in fieldNodeGroup.EnumerateFieldNodeGroups()) { // Reiterates as the current FieldNodeGroup. WriteFieldNodeGroup(writer, nodeGroup); } // Ends the assembly element. writer.WriteEndElement(); }