SceneObjectSerializer.cs 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Drawing;
  30. using System.IO;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Xml;
  34. using log4net;
  35. using OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Serialization.External;
  38. using OpenSim.Region.Framework.Interfaces;
  39. using OpenSim.Region.Framework.Scenes;
  40. using OpenSim.Services.Interfaces;
  41. namespace OpenSim.Region.Framework.Scenes.Serialization
  42. {
  43. /// <summary>
  44. /// Serialize and deserialize scene objects.
  45. /// </summary>
  46. /// This should really be in OpenSim.Framework.Serialization but this would mean circular dependency problems
  47. /// right now - hopefully this isn't forever.
  48. public class SceneObjectSerializer
  49. {
  50. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  51. private static IUserManagement m_UserManagement;
  52. /// <summary>
  53. /// Deserialize a scene object from the original xml format
  54. /// </summary>
  55. /// <param name="xmlData"></param>
  56. /// <returns>The scene object deserialized. Null on failure.</returns>
  57. public static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
  58. {
  59. String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
  60. using (XmlTextReader wrappedReader = new XmlTextReader(fixedData, XmlNodeType.Element, null))
  61. {
  62. using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
  63. {
  64. try
  65. {
  66. return FromOriginalXmlFormat(reader);
  67. }
  68. catch (Exception e)
  69. {
  70. m_log.Error("[SERIALIZER]: Deserialization of xml failed ", e);
  71. Util.LogFailedXML("[SERIALIZER]:", fixedData);
  72. return null;
  73. }
  74. }
  75. }
  76. }
  77. public static SceneObjectGroup FromOriginalXmlData(byte[] data)
  78. {
  79. int len = data.Length;
  80. if(len < 32)
  81. return null;
  82. if(data[len -1 ] == 0)
  83. --len;
  84. XmlReaderSettings xset = new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, CloseInput = true };
  85. XmlParserContext xpc = new XmlParserContext(null, null, null, XmlSpace.None);
  86. xpc.Encoding = Util.UTF8NoBomEncoding;
  87. MemoryStream ms = new MemoryStream(data, 0, len, false);
  88. using (XmlReader reader = XmlReader.Create(ms, xset, xpc))
  89. {
  90. try
  91. {
  92. return FromOriginalXmlFormat(reader);
  93. }
  94. catch (Exception e)
  95. {
  96. m_log.Error("[SERIALIZER]: Deserialization of xml data failed ", e);
  97. return null;
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// Deserialize a scene object from the original xml format
  103. /// </summary>
  104. /// <param name="xmlData"></param>
  105. /// <returns>The scene object deserialized. Null on failure.</returns>
  106. public static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader)
  107. {
  108. //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
  109. //int time = System.Environment.TickCount;
  110. int linkNum;
  111. reader.ReadToFollowing("RootPart");
  112. reader.ReadToFollowing("SceneObjectPart");
  113. SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
  114. reader.ReadToFollowing("OtherParts");
  115. if (reader.ReadToDescendant("Part"))
  116. {
  117. do
  118. {
  119. if (reader.ReadToDescendant("SceneObjectPart"))
  120. {
  121. SceneObjectPart part = SceneObjectPart.FromXml(reader);
  122. linkNum = part.LinkNum;
  123. sceneObject.AddPart(part);
  124. part.LinkNum = linkNum;
  125. part.TrimPermissions();
  126. }
  127. }
  128. while (reader.ReadToNextSibling("Part"));
  129. reader.ReadEndElement();
  130. }
  131. else
  132. reader.Read();
  133. if (reader.Name == "KeyframeMotion" && reader.NodeType == XmlNodeType.Element)
  134. {
  135. string innerkeytxt = reader.ReadElementContentAsString();
  136. sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(innerkeytxt));
  137. }
  138. else
  139. sceneObject.RootPart.KeyframeMotion = null;
  140. // Script state may, or may not, exist. Not having any, is NOT
  141. // ever a problem.
  142. sceneObject.LoadScriptState(reader);
  143. sceneObject.InvalidateDeepEffectivePerms();
  144. return sceneObject;
  145. }
  146. /// <summary>
  147. /// Serialize a scene object to the original xml format
  148. /// </summary>
  149. /// <param name="sceneObject"></param>
  150. /// <returns></returns>
  151. public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
  152. {
  153. return ToOriginalXmlFormat(sceneObject, true);
  154. }
  155. /// <summary>
  156. /// Serialize a scene object to the original xml format
  157. /// </summary>
  158. /// <param name="sceneObject"></param>
  159. /// <param name="doScriptStates">Control whether script states are also serialized.</para>
  160. /// <returns></returns>
  161. public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates)
  162. {
  163. using (StringWriter sw = new StringWriter())
  164. {
  165. using (XmlTextWriter writer = new XmlTextWriter(sw))
  166. {
  167. ToOriginalXmlFormat(sceneObject, writer, doScriptStates);
  168. }
  169. return sw.ToString();
  170. }
  171. }
  172. /// <summary>
  173. /// Serialize a scene object to the original xml format
  174. /// </summary>
  175. /// <param name="sceneObject"></param>
  176. /// <returns></returns>
  177. public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates)
  178. {
  179. ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false);
  180. }
  181. public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, string scriptedState)
  182. {
  183. using (StringWriter sw = new StringWriter())
  184. {
  185. using (XmlTextWriter writer = new XmlTextWriter(sw))
  186. {
  187. writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
  188. ToOriginalXmlFormat(sceneObject, writer, false, true);
  189. writer.WriteRaw(scriptedState);
  190. writer.WriteEndElement();
  191. }
  192. return sw.ToString();
  193. }
  194. }
  195. /// <summary>
  196. /// Serialize a scene object to the original xml format
  197. /// </summary>
  198. /// <param name="sceneObject"></param>
  199. /// <param name="writer"></param>
  200. /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param>
  201. /// <returns></returns>
  202. public static void ToOriginalXmlFormat(
  203. SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement)
  204. {
  205. // m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", sceneObject.Name);
  206. // int time = System.Environment.TickCount;
  207. if (!noRootElement)
  208. writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
  209. writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
  210. ToXmlFormat(sceneObject.RootPart, writer);
  211. writer.WriteEndElement();
  212. writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
  213. SceneObjectPart[] parts = sceneObject.Parts;
  214. for (int i = 0; i < parts.Length; i++)
  215. {
  216. SceneObjectPart part = parts[i];
  217. if (part.UUID != sceneObject.RootPart.UUID)
  218. {
  219. writer.WriteStartElement(String.Empty, "Part", String.Empty);
  220. ToXmlFormat(part, writer);
  221. writer.WriteEndElement();
  222. }
  223. }
  224. writer.WriteEndElement(); // OtherParts
  225. if (sceneObject.RootPart.KeyframeMotion != null)
  226. {
  227. Byte[] data = sceneObject.RootPart.KeyframeMotion.Serialize();
  228. writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
  229. writer.WriteBase64(data, 0, data.Length);
  230. writer.WriteEndElement();
  231. }
  232. if (doScriptStates)
  233. sceneObject.SaveScriptedState(writer);
  234. if (!noRootElement)
  235. writer.WriteEndElement(); // SceneObjectGroup
  236. // m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", sceneObject.Name, System.Environment.TickCount - time);
  237. }
  238. protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
  239. {
  240. SOPToXml2(writer, part, new Dictionary<string, object>());
  241. }
  242. public static SceneObjectGroup FromXml2Format(string xmlData)
  243. {
  244. //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
  245. //int time = System.Environment.TickCount;
  246. try
  247. {
  248. XmlDocument doc = new XmlDocument();
  249. doc.LoadXml(xmlData);
  250. XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
  251. if (parts.Count == 0)
  252. {
  253. m_log.Error("[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes");
  254. Util.LogFailedXML("[SERIALIZER]:", xmlData);
  255. return null;
  256. }
  257. SceneObjectGroup sceneObject;
  258. using(StringReader sr = new StringReader(parts[0].OuterXml))
  259. {
  260. using(XmlTextReader reader = new XmlTextReader(sr))
  261. sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
  262. }
  263. // Then deal with the rest
  264. SceneObjectPart part;
  265. for (int i = 1; i < parts.Count; i++)
  266. {
  267. using(StringReader sr = new StringReader(parts[i].OuterXml))
  268. {
  269. using(XmlTextReader reader = new XmlTextReader(sr))
  270. {
  271. part = SceneObjectPart.FromXml(reader);
  272. }
  273. }
  274. int originalLinkNum = part.LinkNum;
  275. sceneObject.AddPart(part);
  276. // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
  277. // We override that here
  278. if (originalLinkNum != 0)
  279. part.LinkNum = originalLinkNum;
  280. }
  281. XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion");
  282. if (keymotion.Count > 0)
  283. sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText));
  284. else
  285. sceneObject.RootPart.KeyframeMotion = null;
  286. // Script state may, or may not, exist. Not having any, is NOT
  287. // ever a problem.
  288. sceneObject.LoadScriptState(doc);
  289. // sceneObject.AggregatePerms();
  290. return sceneObject;
  291. }
  292. catch (Exception e)
  293. {
  294. m_log.Error("[SERIALIZER]: Deserialization of xml failed ", e);
  295. Util.LogFailedXML("[SERIALIZER]:", xmlData);
  296. return null;
  297. }
  298. }
  299. /// <summary>
  300. /// Serialize a scene object to the 'xml2' format.
  301. /// </summary>
  302. /// <param name="sceneObject"></param>
  303. /// <returns></returns>
  304. public static string ToXml2Format(SceneObjectGroup sceneObject)
  305. {
  306. using (StringWriter sw = new StringWriter())
  307. {
  308. using (XmlTextWriter writer = new XmlTextWriter(sw))
  309. {
  310. SOGToXml2(writer, sceneObject, new Dictionary<string,object>());
  311. }
  312. return sw.ToString();
  313. }
  314. }
  315. /// <summary>
  316. /// Modifies a SceneObjectGroup.
  317. /// </summary>
  318. /// <param name="sog">The object</param>
  319. /// <returns>Whether the object was actually modified</returns>
  320. public delegate bool SceneObjectModifier(SceneObjectGroup sog);
  321. /// <summary>
  322. /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing.
  323. /// </summary>
  324. /// <param name="assetId">The object's UUID</param>
  325. /// <param name="data">Serialized data</param>
  326. /// <param name="modifier">The function to run on each SceneObjectGroup</param>
  327. /// <returns>The new serialized object's data, or null if an error occurred</returns>
  328. public static byte[] ModifySerializedObject(UUID assetId, byte[] data, SceneObjectModifier modifier)
  329. {
  330. List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
  331. CoalescedSceneObjects coa = null;
  332. string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data));
  333. if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
  334. {
  335. // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);
  336. if (coa.Objects.Count == 0)
  337. {
  338. m_log.WarnFormat("[SERIALIZER]: Aborting load of coalesced object from asset {0} as it has zero loaded components", assetId);
  339. return null;
  340. }
  341. sceneObjects.AddRange(coa.Objects);
  342. }
  343. else
  344. {
  345. SceneObjectGroup deserializedObject = FromOriginalXmlFormat(xmlData);
  346. if (deserializedObject != null)
  347. {
  348. sceneObjects.Add(deserializedObject);
  349. }
  350. else
  351. {
  352. m_log.WarnFormat("[SERIALIZER]: Aborting load of object from asset {0} as deserialization failed", assetId);
  353. return null;
  354. }
  355. }
  356. bool modified = false;
  357. foreach (SceneObjectGroup sog in sceneObjects)
  358. {
  359. if (modifier(sog))
  360. modified = true;
  361. }
  362. if (modified)
  363. {
  364. if (coa != null)
  365. data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
  366. else
  367. data = Utils.StringToBytes(ToOriginalXmlFormat(sceneObjects[0]));
  368. }
  369. return data;
  370. }
  371. #region manual serialization
  372. private static Dictionary<string, Action<SceneObjectPart, XmlReader>> m_SOPXmlProcessors
  373. = new Dictionary<string, Action<SceneObjectPart, XmlReader>>();
  374. private static Dictionary<string, Action<TaskInventoryItem, XmlReader>> m_TaskInventoryXmlProcessors
  375. = new Dictionary<string, Action<TaskInventoryItem, XmlReader>>();
  376. private static Dictionary<string, Action<PrimitiveBaseShape, XmlReader>> m_ShapeXmlProcessors
  377. = new Dictionary<string, Action<PrimitiveBaseShape, XmlReader>>();
  378. static SceneObjectSerializer()
  379. {
  380. #region SOPXmlProcessors initialization
  381. m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop);
  382. m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID);
  383. m_SOPXmlProcessors.Add("CreatorData", ProcessCreatorData);
  384. m_SOPXmlProcessors.Add("FolderID", ProcessFolderID);
  385. m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial);
  386. m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory);
  387. m_SOPXmlProcessors.Add("UUID", ProcessUUID);
  388. m_SOPXmlProcessors.Add("LocalId", ProcessLocalId);
  389. m_SOPXmlProcessors.Add("Name", ProcessName);
  390. m_SOPXmlProcessors.Add("Material", ProcessMaterial);
  391. m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches);
  392. m_SOPXmlProcessors.Add("PassCollisions", ProcessPassCollisions);
  393. m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle);
  394. m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin);
  395. m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition);
  396. m_SOPXmlProcessors.Add("OffsetPosition", ProcessOffsetPosition);
  397. m_SOPXmlProcessors.Add("RotationOffset", ProcessRotationOffset);
  398. m_SOPXmlProcessors.Add("Velocity", ProcessVelocity);
  399. m_SOPXmlProcessors.Add("AngularVelocity", ProcessAngularVelocity);
  400. m_SOPXmlProcessors.Add("Acceleration", ProcessAcceleration);
  401. m_SOPXmlProcessors.Add("Description", ProcessDescription);
  402. m_SOPXmlProcessors.Add("Color", ProcessColor);
  403. m_SOPXmlProcessors.Add("Text", ProcessText);
  404. m_SOPXmlProcessors.Add("SitName", ProcessSitName);
  405. m_SOPXmlProcessors.Add("TouchName", ProcessTouchName);
  406. m_SOPXmlProcessors.Add("LinkNum", ProcessLinkNum);
  407. m_SOPXmlProcessors.Add("ClickAction", ProcessClickAction);
  408. m_SOPXmlProcessors.Add("Shape", ProcessShape);
  409. m_SOPXmlProcessors.Add("Scale", ProcessScale);
  410. m_SOPXmlProcessors.Add("SitTargetOrientation", ProcessSitTargetOrientation);
  411. m_SOPXmlProcessors.Add("SitTargetPosition", ProcessSitTargetPosition);
  412. m_SOPXmlProcessors.Add("SitTargetPositionLL", ProcessSitTargetPositionLL);
  413. m_SOPXmlProcessors.Add("SitTargetOrientationLL", ProcessSitTargetOrientationLL);
  414. m_SOPXmlProcessors.Add("StandTarget", ProcessStandTarget);
  415. m_SOPXmlProcessors.Add("ParentID", ProcessParentID);
  416. m_SOPXmlProcessors.Add("CreationDate", ProcessCreationDate);
  417. m_SOPXmlProcessors.Add("Category", ProcessCategory);
  418. m_SOPXmlProcessors.Add("SalePrice", ProcessSalePrice);
  419. m_SOPXmlProcessors.Add("ObjectSaleType", ProcessObjectSaleType);
  420. m_SOPXmlProcessors.Add("OwnershipCost", ProcessOwnershipCost);
  421. m_SOPXmlProcessors.Add("GroupID", ProcessGroupID);
  422. m_SOPXmlProcessors.Add("OwnerID", ProcessOwnerID);
  423. m_SOPXmlProcessors.Add("LastOwnerID", ProcessLastOwnerID);
  424. m_SOPXmlProcessors.Add("RezzerID", ProcessRezzerID);
  425. m_SOPXmlProcessors.Add("BaseMask", ProcessBaseMask);
  426. m_SOPXmlProcessors.Add("OwnerMask", ProcessOwnerMask);
  427. m_SOPXmlProcessors.Add("GroupMask", ProcessGroupMask);
  428. m_SOPXmlProcessors.Add("EveryoneMask", ProcessEveryoneMask);
  429. m_SOPXmlProcessors.Add("NextOwnerMask", ProcessNextOwnerMask);
  430. m_SOPXmlProcessors.Add("Flags", ProcessFlags);
  431. m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound);
  432. m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume);
  433. m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl);
  434. m_SOPXmlProcessors.Add("AttachedPos", ProcessAttachedPos);
  435. m_SOPXmlProcessors.Add("DynAttrs", ProcessDynAttrs);
  436. m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation);
  437. m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem);
  438. m_SOPXmlProcessors.Add("PayPrice0", ProcessPayPrice0);
  439. m_SOPXmlProcessors.Add("PayPrice1", ProcessPayPrice1);
  440. m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2);
  441. m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3);
  442. m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
  443. m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
  444. m_SOPXmlProcessors.Add("Force", ProcessForce);
  445. m_SOPXmlProcessors.Add("Torque", ProcessTorque);
  446. m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
  447. m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
  448. m_SOPXmlProcessors.Add("PhysicsInertia", ProcessPhysicsInertia);
  449. m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks);
  450. m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
  451. m_SOPXmlProcessors.Add("Density", ProcessDensity);
  452. m_SOPXmlProcessors.Add("Friction", ProcessFriction);
  453. m_SOPXmlProcessors.Add("Bounce", ProcessBounce);
  454. m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier);
  455. m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset);
  456. m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset);
  457. m_SOPXmlProcessors.Add("SoundID", ProcessSoundID);
  458. m_SOPXmlProcessors.Add("SoundGain", ProcessSoundGain);
  459. m_SOPXmlProcessors.Add("SoundFlags", ProcessSoundFlags);
  460. m_SOPXmlProcessors.Add("SoundRadius", ProcessSoundRadius);
  461. m_SOPXmlProcessors.Add("SoundQueueing", ProcessSoundQueueing);
  462. m_SOPXmlProcessors.Add("SOPAnims", ProcessSOPAnims);
  463. m_SOPXmlProcessors.Add("SitActRange", ProcessSitActRange);
  464. #endregion
  465. #region TaskInventoryXmlProcessors initialization
  466. m_TaskInventoryXmlProcessors.Add("AssetID", ProcessTIAssetID);
  467. m_TaskInventoryXmlProcessors.Add("BasePermissions", ProcessTIBasePermissions);
  468. m_TaskInventoryXmlProcessors.Add("CreationDate", ProcessTICreationDate);
  469. m_TaskInventoryXmlProcessors.Add("CreatorID", ProcessTICreatorID);
  470. m_TaskInventoryXmlProcessors.Add("CreatorData", ProcessTICreatorData);
  471. m_TaskInventoryXmlProcessors.Add("Description", ProcessTIDescription);
  472. m_TaskInventoryXmlProcessors.Add("EveryonePermissions", ProcessTIEveryonePermissions);
  473. m_TaskInventoryXmlProcessors.Add("Flags", ProcessTIFlags);
  474. m_TaskInventoryXmlProcessors.Add("GroupID", ProcessTIGroupID);
  475. m_TaskInventoryXmlProcessors.Add("GroupPermissions", ProcessTIGroupPermissions);
  476. m_TaskInventoryXmlProcessors.Add("InvType", ProcessTIInvType);
  477. m_TaskInventoryXmlProcessors.Add("ItemID", ProcessTIItemID);
  478. m_TaskInventoryXmlProcessors.Add("OldItemID", ProcessTIOldItemID);
  479. m_TaskInventoryXmlProcessors.Add("LastOwnerID", ProcessTILastOwnerID);
  480. m_TaskInventoryXmlProcessors.Add("Name", ProcessTIName);
  481. m_TaskInventoryXmlProcessors.Add("NextPermissions", ProcessTINextPermissions);
  482. m_TaskInventoryXmlProcessors.Add("OwnerID", ProcessTIOwnerID);
  483. m_TaskInventoryXmlProcessors.Add("CurrentPermissions", ProcessTICurrentPermissions);
  484. m_TaskInventoryXmlProcessors.Add("ParentID", ProcessTIParentID);
  485. m_TaskInventoryXmlProcessors.Add("ParentPartID", ProcessTIParentPartID);
  486. m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter);
  487. m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask);
  488. m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType);
  489. m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged);
  490. #endregion
  491. #region ShapeXmlProcessors initialization
  492. m_ShapeXmlProcessors.Add("ProfileCurve", ProcessShpProfileCurve);
  493. m_ShapeXmlProcessors.Add("TextureEntry", ProcessShpTextureEntry);
  494. m_ShapeXmlProcessors.Add("ExtraParams", ProcessShpExtraParams);
  495. m_ShapeXmlProcessors.Add("PathBegin", ProcessShpPathBegin);
  496. m_ShapeXmlProcessors.Add("PathCurve", ProcessShpPathCurve);
  497. m_ShapeXmlProcessors.Add("PathEnd", ProcessShpPathEnd);
  498. m_ShapeXmlProcessors.Add("PathRadiusOffset", ProcessShpPathRadiusOffset);
  499. m_ShapeXmlProcessors.Add("PathRevolutions", ProcessShpPathRevolutions);
  500. m_ShapeXmlProcessors.Add("PathScaleX", ProcessShpPathScaleX);
  501. m_ShapeXmlProcessors.Add("PathScaleY", ProcessShpPathScaleY);
  502. m_ShapeXmlProcessors.Add("PathShearX", ProcessShpPathShearX);
  503. m_ShapeXmlProcessors.Add("PathShearY", ProcessShpPathShearY);
  504. m_ShapeXmlProcessors.Add("PathSkew", ProcessShpPathSkew);
  505. m_ShapeXmlProcessors.Add("PathTaperX", ProcessShpPathTaperX);
  506. m_ShapeXmlProcessors.Add("PathTaperY", ProcessShpPathTaperY);
  507. m_ShapeXmlProcessors.Add("PathTwist", ProcessShpPathTwist);
  508. m_ShapeXmlProcessors.Add("PathTwistBegin", ProcessShpPathTwistBegin);
  509. m_ShapeXmlProcessors.Add("PCode", ProcessShpPCode);
  510. m_ShapeXmlProcessors.Add("ProfileBegin", ProcessShpProfileBegin);
  511. m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd);
  512. m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow);
  513. m_ShapeXmlProcessors.Add("Scale", ProcessShpScale);
  514. m_ShapeXmlProcessors.Add("LastAttachPoint", ProcessShpLastAttach);
  515. m_ShapeXmlProcessors.Add("State", ProcessShpState);
  516. m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape);
  517. m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape);
  518. m_ShapeXmlProcessors.Add("SculptTexture", ProcessShpSculptTexture);
  519. m_ShapeXmlProcessors.Add("SculptType", ProcessShpSculptType);
  520. // Ignore "SculptData"; this element is deprecated
  521. m_ShapeXmlProcessors.Add("FlexiSoftness", ProcessShpFlexiSoftness);
  522. m_ShapeXmlProcessors.Add("FlexiTension", ProcessShpFlexiTension);
  523. m_ShapeXmlProcessors.Add("FlexiDrag", ProcessShpFlexiDrag);
  524. m_ShapeXmlProcessors.Add("FlexiGravity", ProcessShpFlexiGravity);
  525. m_ShapeXmlProcessors.Add("FlexiWind", ProcessShpFlexiWind);
  526. m_ShapeXmlProcessors.Add("FlexiForceX", ProcessShpFlexiForceX);
  527. m_ShapeXmlProcessors.Add("FlexiForceY", ProcessShpFlexiForceY);
  528. m_ShapeXmlProcessors.Add("FlexiForceZ", ProcessShpFlexiForceZ);
  529. m_ShapeXmlProcessors.Add("LightColorR", ProcessShpLightColorR);
  530. m_ShapeXmlProcessors.Add("LightColorG", ProcessShpLightColorG);
  531. m_ShapeXmlProcessors.Add("LightColorB", ProcessShpLightColorB);
  532. m_ShapeXmlProcessors.Add("LightColorA", ProcessShpLightColorA);
  533. m_ShapeXmlProcessors.Add("LightRadius", ProcessShpLightRadius);
  534. m_ShapeXmlProcessors.Add("LightCutoff", ProcessShpLightCutoff);
  535. m_ShapeXmlProcessors.Add("LightFalloff", ProcessShpLightFalloff);
  536. m_ShapeXmlProcessors.Add("LightIntensity", ProcessShpLightIntensity);
  537. m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry);
  538. m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry);
  539. m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry);
  540. m_ShapeXmlProcessors.Add("Media", ProcessShpMedia);
  541. #endregion
  542. }
  543. #region SOPXmlProcessors
  544. private static void ProcessAllowedDrop(SceneObjectPart obj, XmlReader reader)
  545. {
  546. obj.AllowedDrop = Util.ReadBoolean(reader);
  547. }
  548. private static void ProcessCreatorID(SceneObjectPart obj, XmlReader reader)
  549. {
  550. obj.CreatorID = Util.ReadUUID(reader, "CreatorID");
  551. }
  552. private static void ProcessCreatorData(SceneObjectPart obj, XmlReader reader)
  553. {
  554. obj.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty);
  555. }
  556. private static void ProcessFolderID(SceneObjectPart obj, XmlReader reader)
  557. {
  558. obj.FolderID = Util.ReadUUID(reader, "FolderID");
  559. }
  560. private static void ProcessInventorySerial(SceneObjectPart obj, XmlReader reader)
  561. {
  562. obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty);
  563. }
  564. private static void ProcessTaskInventory(SceneObjectPart obj, XmlReader reader)
  565. {
  566. obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory");
  567. }
  568. private static void ProcessUUID(SceneObjectPart obj, XmlReader reader)
  569. {
  570. obj.UUID = Util.ReadUUID(reader, "UUID");
  571. }
  572. private static void ProcessLocalId(SceneObjectPart obj, XmlReader reader)
  573. {
  574. obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
  575. }
  576. private static void ProcessName(SceneObjectPart obj, XmlReader reader)
  577. {
  578. obj.Name = reader.ReadElementString("Name");
  579. }
  580. private static void ProcessMaterial(SceneObjectPart obj, XmlReader reader)
  581. {
  582. obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty);
  583. }
  584. private static void ProcessPassTouches(SceneObjectPart obj, XmlReader reader)
  585. {
  586. obj.PassTouches = Util.ReadBoolean(reader);
  587. }
  588. private static void ProcessPassCollisions(SceneObjectPart obj, XmlReader reader)
  589. {
  590. obj.PassCollisions = Util.ReadBoolean(reader);
  591. }
  592. private static void ProcessRegionHandle(SceneObjectPart obj, XmlReader reader)
  593. {
  594. obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty);
  595. }
  596. private static void ProcessScriptAccessPin(SceneObjectPart obj, XmlReader reader)
  597. {
  598. obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);
  599. }
  600. private static void ProcessGroupPosition(SceneObjectPart obj, XmlReader reader)
  601. {
  602. obj.GroupPosition = Util.ReadVector(reader, "GroupPosition");
  603. }
  604. private static void ProcessOffsetPosition(SceneObjectPart obj, XmlReader reader)
  605. {
  606. obj.OffsetPosition = Util.ReadVector(reader, "OffsetPosition"); ;
  607. }
  608. private static void ProcessRotationOffset(SceneObjectPart obj, XmlReader reader)
  609. {
  610. obj.RotationOffset = Util.ReadQuaternion(reader, "RotationOffset");
  611. }
  612. private static void ProcessVelocity(SceneObjectPart obj, XmlReader reader)
  613. {
  614. obj.Velocity = Util.ReadVector(reader, "Velocity");
  615. }
  616. private static void ProcessAngularVelocity(SceneObjectPart obj, XmlReader reader)
  617. {
  618. obj.AngularVelocity = Util.ReadVector(reader, "AngularVelocity");
  619. }
  620. private static void ProcessAcceleration(SceneObjectPart obj, XmlReader reader)
  621. {
  622. obj.Acceleration = Util.ReadVector(reader, "Acceleration");
  623. }
  624. private static void ProcessDescription(SceneObjectPart obj, XmlReader reader)
  625. {
  626. obj.Description = reader.ReadElementString("Description");
  627. }
  628. private static void ProcessColor(SceneObjectPart obj, XmlReader reader)
  629. {
  630. reader.ReadStartElement("Color");
  631. if (reader.Name == "R")
  632. {
  633. float r = reader.ReadElementContentAsFloat("R", String.Empty);
  634. float g = reader.ReadElementContentAsFloat("G", String.Empty);
  635. float b = reader.ReadElementContentAsFloat("B", String.Empty);
  636. float a = reader.ReadElementContentAsFloat("A", String.Empty);
  637. obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b);
  638. reader.ReadEndElement();
  639. }
  640. }
  641. private static void ProcessText(SceneObjectPart obj, XmlReader reader)
  642. {
  643. obj.Text = reader.ReadElementString("Text", String.Empty);
  644. }
  645. private static void ProcessSitName(SceneObjectPart obj, XmlReader reader)
  646. {
  647. obj.SitName = reader.ReadElementString("SitName", String.Empty);
  648. }
  649. private static void ProcessTouchName(SceneObjectPart obj, XmlReader reader)
  650. {
  651. obj.TouchName = reader.ReadElementString("TouchName", String.Empty);
  652. }
  653. private static void ProcessLinkNum(SceneObjectPart obj, XmlReader reader)
  654. {
  655. obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty);
  656. }
  657. private static void ProcessClickAction(SceneObjectPart obj, XmlReader reader)
  658. {
  659. obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
  660. }
  661. private static void ProcessRotationAxisLocks(SceneObjectPart obj, XmlReader reader)
  662. {
  663. obj.RotationAxisLocks = (byte)reader.ReadElementContentAsInt("RotationAxisLocks", String.Empty);
  664. }
  665. private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlReader reader)
  666. {
  667. obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty);
  668. }
  669. private static void ProcessDensity(SceneObjectPart obj, XmlReader reader)
  670. {
  671. obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty);
  672. }
  673. private static void ProcessFriction(SceneObjectPart obj, XmlReader reader)
  674. {
  675. obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
  676. }
  677. private static void ProcessBounce(SceneObjectPart obj, XmlReader reader)
  678. {
  679. obj.Restitution = reader.ReadElementContentAsFloat("Bounce", String.Empty);
  680. }
  681. private static void ProcessGravityModifier(SceneObjectPart obj, XmlReader reader)
  682. {
  683. obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
  684. }
  685. private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlReader reader)
  686. {
  687. obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset"));
  688. }
  689. private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlReader reader)
  690. {
  691. obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset"));
  692. }
  693. private static void ProcessSoundID(SceneObjectPart obj, XmlReader reader)
  694. {
  695. obj.Sound = Util.ReadUUID(reader, "SoundID");
  696. }
  697. private static void ProcessSoundGain(SceneObjectPart obj, XmlReader reader)
  698. {
  699. obj.SoundGain = reader.ReadElementContentAsDouble("SoundGain", String.Empty);
  700. }
  701. private static void ProcessSoundFlags(SceneObjectPart obj, XmlReader reader)
  702. {
  703. obj.SoundFlags = (byte)reader.ReadElementContentAsInt("SoundFlags", String.Empty);
  704. }
  705. private static void ProcessSoundRadius(SceneObjectPart obj, XmlReader reader)
  706. {
  707. obj.SoundRadius = reader.ReadElementContentAsDouble("SoundRadius", String.Empty);
  708. }
  709. private static void ProcessSoundQueueing(SceneObjectPart obj, XmlReader reader)
  710. {
  711. obj.SoundQueueing = Util.ReadBoolean(reader);
  712. }
  713. private static void ProcessSitActRange(SceneObjectPart obj, XmlReader reader)
  714. {
  715. obj.SitActiveRange = reader.ReadElementContentAsFloat("SitActRange", String.Empty);
  716. }
  717. private static void ProcessVehicle(SceneObjectPart obj, XmlReader reader)
  718. {
  719. SOPVehicle vehicle = SOPVehicle.FromXml2(reader);
  720. if (vehicle == null)
  721. {
  722. obj.VehicleParams = null;
  723. m_log.DebugFormat(
  724. "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
  725. obj.Name, obj.UUID);
  726. }
  727. else
  728. {
  729. obj.VehicleParams = vehicle;
  730. }
  731. }
  732. private static void ProcessPhysicsInertia(SceneObjectPart obj, XmlReader reader)
  733. {
  734. PhysicsInertiaData pdata = PhysicsInertiaData.FromXml2(reader);
  735. if (pdata == null)
  736. {
  737. obj.PhysicsInertia = null;
  738. m_log.DebugFormat(
  739. "[SceneObjectSerializer]: Parsing PhysicsInertiaData for object part {0} {1} encountered errors. Please see earlier log entries.",
  740. obj.Name, obj.UUID);
  741. }
  742. else
  743. {
  744. obj.PhysicsInertia = pdata;
  745. }
  746. }
  747. private static void ProcessSOPAnims(SceneObjectPart obj, XmlReader reader)
  748. {
  749. obj.Animations = null;
  750. try
  751. {
  752. string datastr;
  753. datastr = reader.ReadElementContentAsString();
  754. if(string.IsNullOrEmpty(datastr))
  755. return;
  756. byte[] pdata = Convert.FromBase64String(datastr);
  757. obj.DeSerializeAnimations(pdata);
  758. return;
  759. }
  760. catch {}
  761. m_log.DebugFormat(
  762. "[SceneObjectSerializer]: Parsing ProcessSOPAnims for object part {0} {1} encountered errors",
  763. obj.Name, obj.UUID);
  764. }
  765. private static void ProcessShape(SceneObjectPart obj, XmlReader reader)
  766. {
  767. List<string> errorNodeNames;
  768. obj.Shape = ReadShape(reader, "Shape", out errorNodeNames, obj);
  769. if (errorNodeNames != null)
  770. {
  771. m_log.DebugFormat(
  772. "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors in properties {2}.",
  773. obj.Name, obj.UUID, string.Join(", ", errorNodeNames.ToArray()));
  774. }
  775. }
  776. private static void ProcessScale(SceneObjectPart obj, XmlReader reader)
  777. {
  778. obj.Scale = Util.ReadVector(reader, "Scale");
  779. }
  780. private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlReader reader)
  781. {
  782. obj.SitTargetOrientation = Util.ReadQuaternion(reader, "SitTargetOrientation");
  783. }
  784. private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlReader reader)
  785. {
  786. obj.SitTargetPosition = Util.ReadVector(reader, "SitTargetPosition");
  787. }
  788. private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlReader reader)
  789. {
  790. obj.SitTargetPositionLL = Util.ReadVector(reader, "SitTargetPositionLL");
  791. }
  792. private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlReader reader)
  793. {
  794. obj.SitTargetOrientationLL = Util.ReadQuaternion(reader, "SitTargetOrientationLL");
  795. }
  796. private static void ProcessStandTarget(SceneObjectPart obj, XmlReader reader)
  797. {
  798. obj.StandOffset = Util.ReadVector(reader, "StandTarget");
  799. }
  800. private static void ProcessParentID(SceneObjectPart obj, XmlReader reader)
  801. {
  802. string str = reader.ReadElementContentAsString("ParentID", String.Empty);
  803. obj.ParentID = Convert.ToUInt32(str);
  804. }
  805. private static void ProcessCreationDate(SceneObjectPart obj, XmlReader reader)
  806. {
  807. obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
  808. }
  809. private static void ProcessCategory(SceneObjectPart obj, XmlReader reader)
  810. {
  811. obj.Category = (uint)reader.ReadElementContentAsInt("Category", String.Empty);
  812. }
  813. private static void ProcessSalePrice(SceneObjectPart obj, XmlReader reader)
  814. {
  815. obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
  816. }
  817. private static void ProcessObjectSaleType(SceneObjectPart obj, XmlReader reader)
  818. {
  819. obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
  820. }
  821. private static void ProcessOwnershipCost(SceneObjectPart obj, XmlReader reader)
  822. {
  823. obj.OwnershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
  824. }
  825. private static void ProcessGroupID(SceneObjectPart obj, XmlReader reader)
  826. {
  827. obj.GroupID = Util.ReadUUID(reader, "GroupID");
  828. }
  829. private static void ProcessOwnerID(SceneObjectPart obj, XmlReader reader)
  830. {
  831. obj.OwnerID = Util.ReadUUID(reader, "OwnerID");
  832. }
  833. private static void ProcessLastOwnerID(SceneObjectPart obj, XmlReader reader)
  834. {
  835. obj.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
  836. }
  837. private static void ProcessRezzerID(SceneObjectPart obj, XmlReader reader)
  838. {
  839. obj.RezzerID = Util.ReadUUID(reader, "RezzerID");
  840. }
  841. private static void ProcessBaseMask(SceneObjectPart obj, XmlReader reader)
  842. {
  843. obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
  844. }
  845. private static void ProcessOwnerMask(SceneObjectPart obj, XmlReader reader)
  846. {
  847. obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
  848. }
  849. private static void ProcessGroupMask(SceneObjectPart obj, XmlReader reader)
  850. {
  851. obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
  852. }
  853. private static void ProcessEveryoneMask(SceneObjectPart obj, XmlReader reader)
  854. {
  855. obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
  856. }
  857. private static void ProcessNextOwnerMask(SceneObjectPart obj, XmlReader reader)
  858. {
  859. obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);
  860. }
  861. private static void ProcessFlags(SceneObjectPart obj, XmlReader reader)
  862. {
  863. obj.Flags = Util.ReadEnum<PrimFlags>(reader, "Flags");
  864. }
  865. private static void ProcessCollisionSound(SceneObjectPart obj, XmlReader reader)
  866. {
  867. obj.CollisionSound = Util.ReadUUID(reader, "CollisionSound");
  868. }
  869. private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlReader reader)
  870. {
  871. obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
  872. }
  873. private static void ProcessMediaUrl(SceneObjectPart obj, XmlReader reader)
  874. {
  875. obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty);
  876. }
  877. private static void ProcessAttachedPos(SceneObjectPart obj, XmlReader reader)
  878. {
  879. obj.AttachedPos = Util.ReadVector(reader, "AttachedPos");
  880. }
  881. private static void ProcessDynAttrs(SceneObjectPart obj, XmlReader reader)
  882. {
  883. DAMap waste = new DAMap();
  884. waste.ReadXml(reader);
  885. if(waste.CountNamespaces > 0)
  886. obj.DynAttrs = waste;
  887. else
  888. obj.DynAttrs = null;
  889. }
  890. private static void ProcessTextureAnimation(SceneObjectPart obj, XmlReader reader)
  891. {
  892. obj.TextureAnimation = Convert.FromBase64String(reader.ReadElementContentAsString("TextureAnimation", String.Empty));
  893. }
  894. private static void ProcessParticleSystem(SceneObjectPart obj, XmlReader reader)
  895. {
  896. obj.ParticleSystem = Convert.FromBase64String(reader.ReadElementContentAsString("ParticleSystem", String.Empty));
  897. }
  898. private static void ProcessPayPrice0(SceneObjectPart obj, XmlReader reader)
  899. {
  900. obj.PayPrice[0] = (int)reader.ReadElementContentAsInt("PayPrice0", String.Empty);
  901. }
  902. private static void ProcessPayPrice1(SceneObjectPart obj, XmlReader reader)
  903. {
  904. obj.PayPrice[1] = (int)reader.ReadElementContentAsInt("PayPrice1", String.Empty);
  905. }
  906. private static void ProcessPayPrice2(SceneObjectPart obj, XmlReader reader)
  907. {
  908. obj.PayPrice[2] = (int)reader.ReadElementContentAsInt("PayPrice2", String.Empty);
  909. }
  910. private static void ProcessPayPrice3(SceneObjectPart obj, XmlReader reader)
  911. {
  912. obj.PayPrice[3] = (int)reader.ReadElementContentAsInt("PayPrice3", String.Empty);
  913. }
  914. private static void ProcessPayPrice4(SceneObjectPart obj, XmlReader reader)
  915. {
  916. obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty);
  917. }
  918. private static void ProcessBuoyancy(SceneObjectPart obj, XmlReader reader)
  919. {
  920. obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty);
  921. }
  922. private static void ProcessForce(SceneObjectPart obj, XmlReader reader)
  923. {
  924. obj.Force = Util.ReadVector(reader, "Force");
  925. }
  926. private static void ProcessTorque(SceneObjectPart obj, XmlReader reader)
  927. {
  928. obj.Torque = Util.ReadVector(reader, "Torque");
  929. }
  930. private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlReader reader)
  931. {
  932. obj.VolumeDetectActive = Util.ReadBoolean(reader);
  933. }
  934. #endregion
  935. #region TaskInventoryXmlProcessors
  936. private static void ProcessTIAssetID(TaskInventoryItem item, XmlReader reader)
  937. {
  938. item.AssetID = Util.ReadUUID(reader, "AssetID");
  939. }
  940. private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlReader reader)
  941. {
  942. item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
  943. }
  944. private static void ProcessTICreationDate(TaskInventoryItem item, XmlReader reader)
  945. {
  946. item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty);
  947. }
  948. private static void ProcessTICreatorID(TaskInventoryItem item, XmlReader reader)
  949. {
  950. item.CreatorID = Util.ReadUUID(reader, "CreatorID");
  951. }
  952. private static void ProcessTICreatorData(TaskInventoryItem item, XmlReader reader)
  953. {
  954. item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty);
  955. }
  956. private static void ProcessTIDescription(TaskInventoryItem item, XmlReader reader)
  957. {
  958. item.Description = reader.ReadElementContentAsString("Description", String.Empty);
  959. }
  960. private static void ProcessTIEveryonePermissions(TaskInventoryItem item, XmlReader reader)
  961. {
  962. item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty);
  963. }
  964. private static void ProcessTIFlags(TaskInventoryItem item, XmlReader reader)
  965. {
  966. item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
  967. }
  968. private static void ProcessTIGroupID(TaskInventoryItem item, XmlReader reader)
  969. {
  970. item.GroupID = Util.ReadUUID(reader, "GroupID");
  971. }
  972. private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlReader reader)
  973. {
  974. item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty);
  975. }
  976. private static void ProcessTIInvType(TaskInventoryItem item, XmlReader reader)
  977. {
  978. item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
  979. }
  980. private static void ProcessTIItemID(TaskInventoryItem item, XmlReader reader)
  981. {
  982. item.ItemID = Util.ReadUUID(reader, "ItemID");
  983. }
  984. private static void ProcessTIOldItemID(TaskInventoryItem item, XmlReader reader)
  985. {
  986. item.OldItemID = Util.ReadUUID(reader, "OldItemID");
  987. }
  988. private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlReader reader)
  989. {
  990. item.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
  991. }
  992. private static void ProcessTIName(TaskInventoryItem item, XmlReader reader)
  993. {
  994. item.Name = reader.ReadElementContentAsString("Name", String.Empty);
  995. }
  996. private static void ProcessTINextPermissions(TaskInventoryItem item, XmlReader reader)
  997. {
  998. item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
  999. }
  1000. private static void ProcessTIOwnerID(TaskInventoryItem item, XmlReader reader)
  1001. {
  1002. item.OwnerID = Util.ReadUUID(reader, "OwnerID");
  1003. }
  1004. private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlReader reader)
  1005. {
  1006. item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
  1007. }
  1008. private static void ProcessTIParentID(TaskInventoryItem item, XmlReader reader)
  1009. {
  1010. item.ParentID = Util.ReadUUID(reader, "ParentID");
  1011. }
  1012. private static void ProcessTIParentPartID(TaskInventoryItem item, XmlReader reader)
  1013. {
  1014. item.ParentPartID = Util.ReadUUID(reader, "ParentPartID");
  1015. }
  1016. private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlReader reader)
  1017. {
  1018. item.PermsGranter = Util.ReadUUID(reader, "PermsGranter");
  1019. }
  1020. private static void ProcessTIPermsMask(TaskInventoryItem item, XmlReader reader)
  1021. {
  1022. item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty);
  1023. }
  1024. private static void ProcessTIType(TaskInventoryItem item, XmlReader reader)
  1025. {
  1026. item.Type = reader.ReadElementContentAsInt("Type", String.Empty);
  1027. }
  1028. private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlReader reader)
  1029. {
  1030. item.OwnerChanged = Util.ReadBoolean(reader);
  1031. }
  1032. #endregion
  1033. #region ShapeXmlProcessors
  1034. private static void ProcessShpProfileCurve(PrimitiveBaseShape shp, XmlReader reader)
  1035. {
  1036. shp.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
  1037. }
  1038. private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlReader reader)
  1039. {
  1040. byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
  1041. shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
  1042. }
  1043. private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlReader reader)
  1044. {
  1045. shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString("ExtraParams"));
  1046. }
  1047. private static void ProcessShpPathBegin(PrimitiveBaseShape shp, XmlReader reader)
  1048. {
  1049. shp.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty);
  1050. }
  1051. private static void ProcessShpPathCurve(PrimitiveBaseShape shp, XmlReader reader)
  1052. {
  1053. shp.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty);
  1054. }
  1055. private static void ProcessShpPathEnd(PrimitiveBaseShape shp, XmlReader reader)
  1056. {
  1057. shp.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty);
  1058. }
  1059. private static void ProcessShpPathRadiusOffset(PrimitiveBaseShape shp, XmlReader reader)
  1060. {
  1061. shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty);
  1062. }
  1063. private static void ProcessShpPathRevolutions(PrimitiveBaseShape shp, XmlReader reader)
  1064. {
  1065. shp.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty);
  1066. }
  1067. private static void ProcessShpPathScaleX(PrimitiveBaseShape shp, XmlReader reader)
  1068. {
  1069. shp.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty);
  1070. }
  1071. private static void ProcessShpPathScaleY(PrimitiveBaseShape shp, XmlReader reader)
  1072. {
  1073. shp.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty);
  1074. }
  1075. private static void ProcessShpPathShearX(PrimitiveBaseShape shp, XmlReader reader)
  1076. {
  1077. shp.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty);
  1078. }
  1079. private static void ProcessShpPathShearY(PrimitiveBaseShape shp, XmlReader reader)
  1080. {
  1081. shp.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty);
  1082. }
  1083. private static void ProcessShpPathSkew(PrimitiveBaseShape shp, XmlReader reader)
  1084. {
  1085. shp.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty);
  1086. }
  1087. private static void ProcessShpPathTaperX(PrimitiveBaseShape shp, XmlReader reader)
  1088. {
  1089. shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty);
  1090. }
  1091. private static void ProcessShpPathTaperY(PrimitiveBaseShape shp, XmlReader reader)
  1092. {
  1093. shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty);
  1094. }
  1095. private static void ProcessShpPathTwist(PrimitiveBaseShape shp, XmlReader reader)
  1096. {
  1097. shp.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty);
  1098. }
  1099. private static void ProcessShpPathTwistBegin(PrimitiveBaseShape shp, XmlReader reader)
  1100. {
  1101. shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty);
  1102. }
  1103. private static void ProcessShpPCode(PrimitiveBaseShape shp, XmlReader reader)
  1104. {
  1105. shp.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty);
  1106. }
  1107. private static void ProcessShpProfileBegin(PrimitiveBaseShape shp, XmlReader reader)
  1108. {
  1109. shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty);
  1110. }
  1111. private static void ProcessShpProfileEnd(PrimitiveBaseShape shp, XmlReader reader)
  1112. {
  1113. shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty);
  1114. }
  1115. private static void ProcessShpProfileHollow(PrimitiveBaseShape shp, XmlReader reader)
  1116. {
  1117. shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty);
  1118. }
  1119. private static void ProcessShpScale(PrimitiveBaseShape shp, XmlReader reader)
  1120. {
  1121. shp.Scale = Util.ReadVector(reader, "Scale");
  1122. }
  1123. private static void ProcessShpState(PrimitiveBaseShape shp, XmlReader reader)
  1124. {
  1125. shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);
  1126. }
  1127. private static void ProcessShpLastAttach(PrimitiveBaseShape shp, XmlReader reader)
  1128. {
  1129. shp.LastAttachPoint = (byte)reader.ReadElementContentAsInt("LastAttachPoint", String.Empty);
  1130. }
  1131. private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlReader reader)
  1132. {
  1133. shp.ProfileShape = Util.ReadEnum<ProfileShape>(reader, "ProfileShape");
  1134. }
  1135. private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlReader reader)
  1136. {
  1137. shp.HollowShape = Util.ReadEnum<HollowShape>(reader, "HollowShape");
  1138. }
  1139. private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlReader reader)
  1140. {
  1141. shp.SculptTexture = Util.ReadUUID(reader, "SculptTexture");
  1142. }
  1143. private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlReader reader)
  1144. {
  1145. shp.SculptType = (byte)reader.ReadElementContentAsInt("SculptType", String.Empty);
  1146. }
  1147. private static void ProcessShpFlexiSoftness(PrimitiveBaseShape shp, XmlReader reader)
  1148. {
  1149. shp.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
  1150. }
  1151. private static void ProcessShpFlexiTension(PrimitiveBaseShape shp, XmlReader reader)
  1152. {
  1153. shp.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
  1154. }
  1155. private static void ProcessShpFlexiDrag(PrimitiveBaseShape shp, XmlReader reader)
  1156. {
  1157. shp.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
  1158. }
  1159. private static void ProcessShpFlexiGravity(PrimitiveBaseShape shp, XmlReader reader)
  1160. {
  1161. shp.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
  1162. }
  1163. private static void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlReader reader)
  1164. {
  1165. shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
  1166. }
  1167. private static void ProcessShpFlexiForceX(PrimitiveBaseShape shp, XmlReader reader)
  1168. {
  1169. shp.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
  1170. }
  1171. private static void ProcessShpFlexiForceY(PrimitiveBaseShape shp, XmlReader reader)
  1172. {
  1173. shp.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
  1174. }
  1175. private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlReader reader)
  1176. {
  1177. shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);
  1178. }
  1179. private static void ProcessShpLightColorR(PrimitiveBaseShape shp, XmlReader reader)
  1180. {
  1181. shp.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
  1182. }
  1183. private static void ProcessShpLightColorG(PrimitiveBaseShape shp, XmlReader reader)
  1184. {
  1185. shp.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
  1186. }
  1187. private static void ProcessShpLightColorB(PrimitiveBaseShape shp, XmlReader reader)
  1188. {
  1189. shp.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
  1190. }
  1191. private static void ProcessShpLightColorA(PrimitiveBaseShape shp, XmlReader reader)
  1192. {
  1193. shp.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
  1194. }
  1195. private static void ProcessShpLightRadius(PrimitiveBaseShape shp, XmlReader reader)
  1196. {
  1197. shp.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
  1198. }
  1199. private static void ProcessShpLightCutoff(PrimitiveBaseShape shp, XmlReader reader)
  1200. {
  1201. shp.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
  1202. }
  1203. private static void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlReader reader)
  1204. {
  1205. shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
  1206. }
  1207. private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlReader reader)
  1208. {
  1209. shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
  1210. }
  1211. private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlReader reader)
  1212. {
  1213. shp.FlexiEntry = Util.ReadBoolean(reader);
  1214. }
  1215. private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlReader reader)
  1216. {
  1217. shp.LightEntry = Util.ReadBoolean(reader);
  1218. }
  1219. private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlReader reader)
  1220. {
  1221. shp.SculptEntry = Util.ReadBoolean(reader);
  1222. }
  1223. private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlReader reader)
  1224. {
  1225. string value = String.Empty;
  1226. try
  1227. {
  1228. // The STANDARD content of Media elemet is escaped XML string (with &gt; etc).
  1229. value = reader.ReadElementContentAsString("Media", String.Empty);
  1230. shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
  1231. }
  1232. catch (XmlException)
  1233. {
  1234. // There are versions of OAR files that contain unquoted XML.
  1235. // ie ONE comercial fork that never wanted their oars to be read by our code
  1236. try
  1237. {
  1238. value = reader.ReadInnerXml();
  1239. shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
  1240. }
  1241. catch
  1242. {
  1243. m_log.ErrorFormat("[SERIALIZER] Failed parsing halcyon MOAP information");
  1244. }
  1245. }
  1246. }
  1247. #endregion
  1248. ////////// Write /////////
  1249. public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options)
  1250. {
  1251. writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
  1252. SOPToXml2(writer, sog.RootPart, options);
  1253. writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
  1254. sog.ForEachPart(delegate(SceneObjectPart sop)
  1255. {
  1256. if (sop.UUID != sog.RootPart.UUID)
  1257. SOPToXml2(writer, sop, options);
  1258. });
  1259. writer.WriteEndElement();
  1260. if (sog.RootPart.KeyframeMotion != null)
  1261. {
  1262. Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
  1263. writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
  1264. writer.WriteBase64(data, 0, data.Length);
  1265. writer.WriteEndElement();
  1266. }
  1267. writer.WriteEndElement();
  1268. }
  1269. public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary<string, object> options)
  1270. {
  1271. writer.WriteStartElement("SceneObjectPart");
  1272. writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
  1273. writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
  1274. writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower());
  1275. WriteUUID(writer, "CreatorID", sop.CreatorID, options);
  1276. if (!string.IsNullOrEmpty(sop.CreatorData))
  1277. writer.WriteElementString("CreatorData", sop.CreatorData);
  1278. else if (options.ContainsKey("home"))
  1279. {
  1280. if (m_UserManagement == null)
  1281. m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<IUserManagement>();
  1282. string name = m_UserManagement.GetUserName(sop.CreatorID);
  1283. writer.WriteElementString("CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options["home"], name));
  1284. }
  1285. WriteUUID(writer, "FolderID", sop.FolderID, options);
  1286. writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString());
  1287. WriteTaskInventory(writer, sop.TaskInventory, options, sop.ParentGroup.Scene);
  1288. WriteUUID(writer, "UUID", sop.UUID, options);
  1289. writer.WriteElementString("LocalId", sop.LocalId.ToString());
  1290. writer.WriteElementString("Name", sop.Name);
  1291. writer.WriteElementString("Material", sop.Material.ToString());
  1292. writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower());
  1293. writer.WriteElementString("PassCollisions", sop.PassCollisions.ToString().ToLower());
  1294. writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString());
  1295. writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString());
  1296. WriteVector(writer, "GroupPosition", sop.GroupPosition);
  1297. WriteVector(writer, "OffsetPosition", sop.OffsetPosition);
  1298. WriteQuaternion(writer, "RotationOffset", sop.RotationOffset);
  1299. WriteVector(writer, "Velocity", sop.Velocity);
  1300. WriteVector(writer, "AngularVelocity", sop.AngularVelocity);
  1301. WriteVector(writer, "Acceleration", sop.Acceleration);
  1302. writer.WriteElementString("Description", sop.Description);
  1303. writer.WriteStartElement("Color");
  1304. writer.WriteElementString("R", sop.Color.R.ToString(Culture.FormatProvider));
  1305. writer.WriteElementString("G", sop.Color.G.ToString(Culture.FormatProvider));
  1306. writer.WriteElementString("B", sop.Color.B.ToString(Culture.FormatProvider));
  1307. writer.WriteElementString("A", sop.Color.A.ToString(Culture.FormatProvider));
  1308. writer.WriteEndElement();
  1309. writer.WriteElementString("Text", sop.Text);
  1310. writer.WriteElementString("SitName", sop.SitName);
  1311. writer.WriteElementString("TouchName", sop.TouchName);
  1312. writer.WriteElementString("LinkNum", sop.LinkNum.ToString());
  1313. writer.WriteElementString("ClickAction", sop.ClickAction.ToString());
  1314. WriteShape(writer, sop.Shape, options);
  1315. WriteVector(writer, "Scale", sop.Scale);
  1316. WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation);
  1317. WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition);
  1318. WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL);
  1319. WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL);
  1320. if(sop.StandOffset != Vector3.Zero)
  1321. WriteVector(writer, "StandTarget", sop.StandOffset);
  1322. writer.WriteElementString("ParentID", sop.ParentID.ToString());
  1323. writer.WriteElementString("CreationDate", sop.CreationDate.ToString());
  1324. writer.WriteElementString("Category", sop.Category.ToString());
  1325. writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
  1326. writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
  1327. writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
  1328. UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.GroupID;
  1329. WriteUUID(writer, "GroupID", groupID, options);
  1330. UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID;
  1331. WriteUUID(writer, "OwnerID", ownerID, options);
  1332. UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.LastOwnerID;
  1333. WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
  1334. UUID rezzerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.RezzerID;
  1335. WriteUUID(writer, "RezzerID", rezzerID, options);
  1336. writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
  1337. writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
  1338. writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
  1339. writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString());
  1340. writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString());
  1341. WriteFlags(writer, "Flags", sop.Flags.ToString(), options);
  1342. WriteUUID(writer, "CollisionSound", sop.CollisionSound, options);
  1343. writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString(Culture.FormatProvider));
  1344. if (sop.MediaUrl != null)
  1345. writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
  1346. WriteVector(writer, "AttachedPos", sop.AttachedPos);
  1347. if (sop.DynAttrs != null && sop.DynAttrs.CountNamespaces > 0)
  1348. {
  1349. writer.WriteStartElement("DynAttrs");
  1350. sop.DynAttrs.WriteXml(writer);
  1351. writer.WriteEndElement();
  1352. }
  1353. WriteBytes(writer, "TextureAnimation", sop.TextureAnimation);
  1354. WriteBytes(writer, "ParticleSystem", sop.ParticleSystem);
  1355. writer.WriteElementString("PayPrice0", sop.PayPrice[0].ToString());
  1356. writer.WriteElementString("PayPrice1", sop.PayPrice[1].ToString());
  1357. writer.WriteElementString("PayPrice2", sop.PayPrice[2].ToString());
  1358. writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString());
  1359. writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString());
  1360. writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString(Culture.FormatProvider));
  1361. WriteVector(writer, "Force", sop.Force);
  1362. WriteVector(writer, "Torque", sop.Torque);
  1363. writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
  1364. if (sop.VehicleParams != null)
  1365. sop.VehicleParams.ToXml2(writer);
  1366. if (sop.PhysicsInertia != null)
  1367. sop.PhysicsInertia.ToXml2(writer);
  1368. if(sop.RotationAxisLocks != 0)
  1369. writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower());
  1370. writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
  1371. if (sop.Density != 1000.0f)
  1372. writer.WriteElementString("Density", sop.Density.ToString(Culture.FormatProvider));
  1373. if (sop.Friction != 0.6f)
  1374. writer.WriteElementString("Friction", sop.Friction.ToString(Culture.FormatProvider));
  1375. if (sop.Restitution != 0.5f)
  1376. writer.WriteElementString("Bounce", sop.Restitution.ToString(Culture.FormatProvider));
  1377. if (sop.GravityModifier != 1.0f)
  1378. writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString(Culture.FormatProvider));
  1379. WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset());
  1380. WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset());
  1381. // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim
  1382. {
  1383. WriteUUID(writer, "SoundID", sop.Sound, options);
  1384. writer.WriteElementString("SoundGain", sop.SoundGain.ToString(Culture.FormatProvider));
  1385. writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower());
  1386. writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString(Culture.FormatProvider));
  1387. }
  1388. writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower());
  1389. if (sop.Animations != null)
  1390. {
  1391. Byte[] data = sop.SerializeAnimations();
  1392. if(data != null && data.Length > 0)
  1393. writer.WriteElementString("SOPAnims", Convert.ToBase64String(data));
  1394. }
  1395. if(Math.Abs(sop.SitActiveRange) > 1e-5)
  1396. writer.WriteElementString("SitActRange", sop.SitActiveRange.ToString(Culture.FormatProvider));
  1397. writer.WriteEndElement();
  1398. }
  1399. static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary<string, object> options)
  1400. {
  1401. writer.WriteStartElement(name);
  1402. if (options.ContainsKey("old-guids"))
  1403. writer.WriteElementString("Guid", id.ToString());
  1404. else
  1405. writer.WriteElementString("UUID", id.ToString());
  1406. writer.WriteEndElement();
  1407. }
  1408. static void WriteVector(XmlTextWriter writer, string name, Vector3 vec)
  1409. {
  1410. writer.WriteStartElement(name);
  1411. writer.WriteElementString("X", vec.X.ToString(Culture.FormatProvider));
  1412. writer.WriteElementString("Y", vec.Y.ToString(Culture.FormatProvider));
  1413. writer.WriteElementString("Z", vec.Z.ToString(Culture.FormatProvider));
  1414. writer.WriteEndElement();
  1415. }
  1416. static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat)
  1417. {
  1418. writer.WriteStartElement(name);
  1419. writer.WriteElementString("X", quat.X.ToString(Culture.FormatProvider));
  1420. writer.WriteElementString("Y", quat.Y.ToString(Culture.FormatProvider));
  1421. writer.WriteElementString("Z", quat.Z.ToString(Culture.FormatProvider));
  1422. writer.WriteElementString("W", quat.W.ToString(Culture.FormatProvider));
  1423. writer.WriteEndElement();
  1424. }
  1425. static void WriteBytes(XmlTextWriter writer, string name, byte[] data)
  1426. {
  1427. writer.WriteStartElement(name);
  1428. byte[] d;
  1429. if (data != null)
  1430. d = data;
  1431. else
  1432. d = Utils.EmptyBytes;
  1433. writer.WriteBase64(d, 0, d.Length);
  1434. writer.WriteEndElement(); // name
  1435. }
  1436. static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary<string, object> options)
  1437. {
  1438. // Older versions of serialization can't cope with commas, so we eliminate the commas
  1439. writer.WriteElementString(name, flagsStr.Replace(",", ""));
  1440. }
  1441. public static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene)
  1442. {
  1443. if (tinv.Count > 0) // otherwise skip this
  1444. {
  1445. writer.WriteStartElement("TaskInventory");
  1446. foreach (TaskInventoryItem item in tinv.Values)
  1447. {
  1448. writer.WriteStartElement("TaskInventoryItem");
  1449. WriteUUID(writer, "AssetID", item.AssetID, options);
  1450. writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
  1451. writer.WriteElementString("CreationDate", item.CreationDate.ToString());
  1452. WriteUUID(writer, "CreatorID", item.CreatorID, options);
  1453. if (!string.IsNullOrEmpty(item.CreatorData))
  1454. writer.WriteElementString("CreatorData", item.CreatorData);
  1455. else if (options.ContainsKey("home"))
  1456. {
  1457. if (m_UserManagement == null)
  1458. m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
  1459. string name = m_UserManagement.GetUserName(item.CreatorID);
  1460. writer.WriteElementString("CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options["home"], name));
  1461. }
  1462. writer.WriteElementString("Description", item.Description);
  1463. writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
  1464. writer.WriteElementString("Flags", item.Flags.ToString());
  1465. UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.GroupID;
  1466. WriteUUID(writer, "GroupID", groupID, options);
  1467. writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
  1468. writer.WriteElementString("InvType", item.InvType.ToString());
  1469. WriteUUID(writer, "ItemID", item.ItemID, options);
  1470. WriteUUID(writer, "OldItemID", item.OldItemID, options);
  1471. UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.LastOwnerID;
  1472. WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
  1473. writer.WriteElementString("Name", item.Name);
  1474. writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
  1475. UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.OwnerID;
  1476. WriteUUID(writer, "OwnerID", ownerID, options);
  1477. writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
  1478. WriteUUID(writer, "ParentID", item.ParentID, options);
  1479. WriteUUID(writer, "ParentPartID", item.ParentPartID, options);
  1480. WriteUUID(writer, "PermsGranter", item.PermsGranter, options);
  1481. writer.WriteElementString("PermsMask", item.PermsMask.ToString());
  1482. writer.WriteElementString("Type", item.Type.ToString());
  1483. bool ownerChanged = options.ContainsKey("wipe-owners") ? false : item.OwnerChanged;
  1484. writer.WriteElementString("OwnerChanged", ownerChanged.ToString().ToLower());
  1485. writer.WriteEndElement(); // TaskInventoryItem
  1486. }
  1487. writer.WriteEndElement(); // TaskInventory
  1488. }
  1489. }
  1490. public static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
  1491. {
  1492. if (shp != null)
  1493. {
  1494. writer.WriteStartElement("Shape");
  1495. writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString());
  1496. writer.WriteStartElement("TextureEntry");
  1497. byte[] te;
  1498. if (shp.TextureEntry != null)
  1499. te = shp.TextureEntry;
  1500. else
  1501. te = Utils.EmptyBytes;
  1502. writer.WriteBase64(te, 0, te.Length);
  1503. writer.WriteEndElement(); // TextureEntry
  1504. writer.WriteStartElement("ExtraParams");
  1505. byte[] ep;
  1506. if (shp.ExtraParams != null)
  1507. ep = shp.ExtraParams;
  1508. else
  1509. ep = Utils.EmptyBytes;
  1510. writer.WriteBase64(ep, 0, ep.Length);
  1511. writer.WriteEndElement(); // ExtraParams
  1512. writer.WriteElementString("PathBegin", shp.PathBegin.ToString());
  1513. writer.WriteElementString("PathCurve", shp.PathCurve.ToString());
  1514. writer.WriteElementString("PathEnd", shp.PathEnd.ToString());
  1515. writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString());
  1516. writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString());
  1517. writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString());
  1518. writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString());
  1519. writer.WriteElementString("PathShearX", shp.PathShearX.ToString());
  1520. writer.WriteElementString("PathShearY", shp.PathShearY.ToString());
  1521. writer.WriteElementString("PathSkew", shp.PathSkew.ToString());
  1522. writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString());
  1523. writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString());
  1524. writer.WriteElementString("PathTwist", shp.PathTwist.ToString());
  1525. writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString());
  1526. writer.WriteElementString("PCode", shp.PCode.ToString());
  1527. writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString());
  1528. writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString());
  1529. writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString());
  1530. writer.WriteElementString("State", shp.State.ToString());
  1531. writer.WriteElementString("LastAttachPoint", shp.LastAttachPoint.ToString());
  1532. WriteFlags(writer, "ProfileShape", shp.ProfileShape.ToString(), options);
  1533. WriteFlags(writer, "HollowShape", shp.HollowShape.ToString(), options);
  1534. WriteUUID(writer, "SculptTexture", shp.SculptTexture, options);
  1535. writer.WriteElementString("SculptType", shp.SculptType.ToString());
  1536. // Don't serialize SculptData. It's just a copy of the asset, which can be loaded separately using 'SculptTexture'.
  1537. writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString());
  1538. writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString(Culture.FormatProvider));
  1539. writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString(Culture.FormatProvider));
  1540. writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString(Culture.FormatProvider));
  1541. writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString(Culture.FormatProvider));
  1542. writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString(Culture.FormatProvider));
  1543. writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString(Culture.FormatProvider));
  1544. writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString(Culture.FormatProvider));
  1545. writer.WriteElementString("LightColorR", shp.LightColorR.ToString(Culture.FormatProvider));
  1546. writer.WriteElementString("LightColorG", shp.LightColorG.ToString(Culture.FormatProvider));
  1547. writer.WriteElementString("LightColorB", shp.LightColorB.ToString(Culture.FormatProvider));
  1548. writer.WriteElementString("LightColorA", shp.LightColorA.ToString(Culture.FormatProvider));
  1549. writer.WriteElementString("LightRadius", shp.LightRadius.ToString(Culture.FormatProvider));
  1550. writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString(Culture.FormatProvider));
  1551. writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString(Culture.FormatProvider));
  1552. writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString(Culture.FormatProvider));
  1553. writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower());
  1554. writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower());
  1555. writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower());
  1556. if (shp.Media != null)
  1557. writer.WriteElementString("Media", shp.Media.ToXml());
  1558. writer.WriteEndElement(); // Shape
  1559. }
  1560. }
  1561. public static SceneObjectPart Xml2ToSOP(XmlReader reader)
  1562. {
  1563. SceneObjectPart obj = new SceneObjectPart();
  1564. reader.ReadStartElement("SceneObjectPart");
  1565. bool errors = ExternalRepresentationUtils.ExecuteReadProcessors(
  1566. obj,
  1567. m_SOPXmlProcessors,
  1568. reader,
  1569. (o, nodeName, e) => {
  1570. m_log.Debug(string.Format("[SceneObjectSerializer]: Error while parsing element {0} in object {1} {2} ",
  1571. nodeName, ((SceneObjectPart)o).Name, ((SceneObjectPart)o).UUID), e);
  1572. });
  1573. if (errors)
  1574. throw new XmlException(string.Format("Error parsing object {0} {1}", obj.Name, obj.UUID));
  1575. reader.ReadEndElement(); // SceneObjectPart
  1576. obj.AggregateInnerPerms();
  1577. // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID);
  1578. return obj;
  1579. }
  1580. public static TaskInventoryDictionary ReadTaskInventory(XmlReader reader, string name)
  1581. {
  1582. TaskInventoryDictionary tinv = new TaskInventoryDictionary();
  1583. reader.ReadStartElement(name, String.Empty);
  1584. while (reader.Name == "TaskInventoryItem")
  1585. {
  1586. reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory
  1587. TaskInventoryItem item = new TaskInventoryItem();
  1588. ExternalRepresentationUtils.ExecuteReadProcessors(
  1589. item,
  1590. m_TaskInventoryXmlProcessors,
  1591. reader);
  1592. reader.ReadEndElement(); // TaskInventoryItem
  1593. tinv.Add(item.ItemID, item);
  1594. }
  1595. if (reader.NodeType == XmlNodeType.EndElement)
  1596. reader.ReadEndElement(); // TaskInventory
  1597. return tinv;
  1598. }
  1599. /// <summary>
  1600. /// Read a shape from xml input
  1601. /// </summary>
  1602. /// <param name="reader"></param>
  1603. /// <param name="name">The name of the xml element containing the shape</param>
  1604. /// <param name="errors">a list containing the failing node names. If no failures then null.</param>
  1605. /// <returns>The shape parsed</returns>
  1606. public static PrimitiveBaseShape ReadShape(XmlReader reader, string name, out List<string> errorNodeNames, SceneObjectPart obj)
  1607. {
  1608. List<string> internalErrorNodeNames = null;
  1609. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  1610. if (reader.IsEmptyElement)
  1611. {
  1612. reader.Read();
  1613. errorNodeNames = null;
  1614. return shape;
  1615. }
  1616. reader.ReadStartElement(name, String.Empty); // Shape
  1617. ExternalRepresentationUtils.ExecuteReadProcessors(
  1618. shape,
  1619. m_ShapeXmlProcessors,
  1620. reader,
  1621. (o, nodeName, e) => {
  1622. m_log.Debug(string.Format("[SceneObjectSerializer]: Error while parsing element {0} in Shape property of object {1} {2} ",
  1623. nodeName, obj.Name, obj.UUID), e);
  1624. if (internalErrorNodeNames == null)
  1625. internalErrorNodeNames = new List<string>();
  1626. internalErrorNodeNames.Add(nodeName);
  1627. });
  1628. reader.ReadEndElement(); // Shape
  1629. errorNodeNames = internalErrorNodeNames;
  1630. return shape;
  1631. }
  1632. #endregion
  1633. }
  1634. }