opensim – Blame information for rev 1

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