29 using System.Collections.Generic;
32 using System.Reflection;
36 using OpenSim.Framework;
37 using OpenSim.Region.Framework.Interfaces;
38 using OpenSim.Region.Framework.Scenes;
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 return ToXml(coa,
true);
72 using (StringWriter sw =
new StringWriter())
74 using (XmlTextWriter writer =
new XmlTextWriter(sw))
78 List<SceneObjectGroup> coaObjects = coa.Objects;
85 Vector3[] offsets = coa.GetSizeAndOffsets(out size);
87 writer.WriteStartElement(
"CoalescedObject");
89 writer.WriteAttributeString(
"x", size.X.ToString());
90 writer.WriteAttributeString(
"y", size.Y.ToString());
91 writer.WriteAttributeString(
"z", size.Z.ToString());
94 for (
int i = 0; i < coaObjects.Count; i++)
102 writer.WriteStartElement(
"SceneObjectGroup");
103 writer.WriteAttributeString(
"offsetx", offsets[i].X.ToString());
104 writer.WriteAttributeString(
"offsety", offsets[i].Y.ToString());
105 writer.WriteAttributeString(
"offsetz", offsets[i].Z.ToString());
107 SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, doScriptStates);
109 writer.WriteEndElement();
112 writer.WriteEndElement();
115 string output = sw.ToString();
132 using (StringReader sr =
new StringReader(xml))
134 using (XmlTextReader reader =
new XmlTextReader(sr))
136 reader.MoveToContent();
138 if (reader.Name !=
"CoalescedObject")
149 XmlDocument doc =
new XmlDocument();
151 XmlElement e = (XmlElement)doc.SelectSingleNode(
"/CoalescedObject");
157 XmlNodeList groups = e.SelectNodes(
"SceneObjectGroup");
160 foreach (XmlNode n
in groups)
162 SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
172 "[COALESCED SCENE OBJECTS SERIALIZER]: Deserialization of xml for component {0} failed. Continuing.",
181 m_log.Error(
"[COALESCED SCENE OBJECTS SERIALIZER]: Deserialization of xml failed ", e);
182 Util.LogFailedXML(
"[COALESCED SCENE OBJECTS SERIALIZER]:", xml);
static bool TryFromXml(string xml, out CoalescedSceneObjects coa)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Interactive OpenSim region server
Serialize and deserialize coalesced scene objects.
static string ToXml(CoalescedSceneObjects coa, bool doScriptStates)
Serialize coalesced objects to Xml
static string ToXml(CoalescedSceneObjects coa)
Serialize coalesced objects to Xml
Represents a coalescene of scene objects. A coalescence occurs when objects that are not in the same ...