static void SOGToXml2(XmlTextWriter writer, Linkset linkset) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); SOPToXml(writer, linkset.Parent, null); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); foreach (Primitive child in linkset.Children) SOPToXml(writer, child, linkset.Parent); writer.WriteEndElement(); writer.WriteEndElement(); }
public static void SavePrims(DoubleDictionary<uint, UUID, Primitive> prims, string path) { // Delete all of the old linkset files try { Directory.Delete(path, true); Directory.CreateDirectory(path); } catch (Exception ex) { Logger.Log("Failed saving prims: " + ex.Message, Helpers.LogLevel.Error); return; } // Copy the double dictionary to a temporary list for iterating List<Primitive> primList = new List<Primitive>(); prims.ForEach(delegate(Primitive prim) { primList.Add(prim); }); foreach (Primitive p in primList) { if (p.ParentID == 0) { Linkset linkset = new Linkset(); linkset.Parent = p; prims.ForEach(delegate(Primitive q) { if (q.ParentID == p.LocalID) linkset.Children.Add(q); }); SaveLinkset(linkset, path + "/Primitive_" + linkset.Parent.ID.ToString() + ".xml"); } } }
static void SaveLinkset(Linkset linkset, string filename) { try { using (StreamWriter stream = new StreamWriter(filename)) { XmlTextWriter writer = new XmlTextWriter(stream); SOGToXml2(writer, linkset); writer.Flush(); } } catch (Exception ex) { Logger.Log("Failed saving linkset: " + ex.Message, Helpers.LogLevel.Error); } }