29 using System.Collections.Generic;
33 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Serialization.External;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Services.Interfaces;
43 namespace OpenSim.
Region.Framework.Scenes.Serialization
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
63 String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
64 using (XmlTextReader wrappedReader =
new XmlTextReader(fixedData, XmlNodeType.Element, null))
66 using (XmlReader reader = XmlReader.Create(wrappedReader,
new XmlReaderSettings() { IgnoreWhitespace =
true, ConformanceLevel = ConformanceLevel.Fragment }))
69 return FromOriginalXmlFormat(reader);
73 m_log.Error(
"[SERIALIZER]: Deserialization of xml failed ", e);
74 Util.LogFailedXML(
"[SERIALIZER]:", fixedData);
93 reader.ReadToFollowing(
"RootPart");
94 reader.ReadToFollowing(
"SceneObjectPart");
96 reader.ReadToFollowing(
"OtherParts");
98 if (reader.ReadToDescendant(
"Part"))
102 if (reader.ReadToDescendant(
"SceneObjectPart"))
105 linkNum = part.LinkNum;
106 sceneObject.AddPart(part);
107 part.LinkNum = linkNum;
108 part.TrimPermissions();
111 while (reader.ReadToNextSibling(
"Part"));
116 sceneObject.LoadScriptState(reader);
128 return ToOriginalXmlFormat(sceneObject,
true);
139 using (StringWriter sw =
new StringWriter())
141 using (XmlTextWriter writer =
new XmlTextWriter(sw))
143 ToOriginalXmlFormat(sceneObject, writer, doScriptStates);
146 return sw.ToString();
157 ToOriginalXmlFormat(sceneObject, writer, doScriptStates,
false);
162 using (StringWriter sw =
new StringWriter())
164 using (XmlTextWriter writer =
new XmlTextWriter(sw))
166 writer.WriteStartElement(String.Empty,
"SceneObjectGroup", String.Empty);
168 ToOriginalXmlFormat(sceneObject, writer,
false,
true);
170 writer.WriteRaw(scriptedState);
172 writer.WriteEndElement();
174 return sw.ToString();
186 SceneObjectGroup sceneObject, XmlTextWriter writer,
bool doScriptStates,
bool noRootElement)
192 writer.WriteStartElement(String.Empty,
"SceneObjectGroup", String.Empty);
194 writer.WriteStartElement(String.Empty,
"RootPart", String.Empty);
195 ToXmlFormat(sceneObject.
RootPart, writer);
196 writer.WriteEndElement();
197 writer.WriteStartElement(String.Empty,
"OtherParts", String.Empty);
200 for (
int i = 0; i < parts.Length; i++)
205 writer.WriteStartElement(String.Empty,
"Part", String.Empty);
206 ToXmlFormat(part, writer);
207 writer.WriteEndElement();
211 writer.WriteEndElement();
214 sceneObject.SaveScriptedState(writer);
217 writer.WriteEndElement();
224 SOPToXml2(writer, part,
new Dictionary<string, object>());
234 XmlDocument doc =
new XmlDocument();
235 doc.LoadXml(xmlData);
237 XmlNodeList parts = doc.GetElementsByTagName(
"SceneObjectPart");
239 if (parts.Count == 0)
241 m_log.Error(
"[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes");
242 Util.LogFailedXML(
"[SERIALIZER]:", xmlData);
246 StringReader sr =
new StringReader(parts[0].OuterXml);
247 XmlTextReader reader =
new XmlTextReader(sr);
253 for (
int i = 1; i < parts.Count; i++)
255 sr =
new StringReader(parts[i].OuterXml);
256 reader =
new XmlTextReader(sr);
259 int originalLinkNum = part.LinkNum;
261 sceneObject.AddPart(part);
265 if (originalLinkNum != 0)
266 part.LinkNum = originalLinkNum;
272 XmlNodeList keymotion = doc.GetElementsByTagName(
"KeyframeMotion");
273 if (keymotion.Count > 0)
274 sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText));
276 sceneObject.RootPart.KeyframeMotion = null;
280 sceneObject.LoadScriptState(doc);
286 m_log.Error(
"[SERIALIZER]: Deserialization of xml failed ", e);
287 Util.LogFailedXML(
"[SERIALIZER]:", xmlData);
299 using (StringWriter sw =
new StringWriter())
301 using (XmlTextWriter writer =
new XmlTextWriter(sw))
303 SOGToXml2(writer, sceneObject,
new Dictionary<string,object>());
306 return sw.ToString();
326 List<SceneObjectGroup> sceneObjects =
new List<SceneObjectGroup>();
329 string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data));
334 if (coa.Objects.Count == 0)
336 m_log.WarnFormat(
"[SERIALIZER]: Aborting load of coalesced object from asset {0} as it has zero loaded components", assetId);
340 sceneObjects.AddRange(coa.Objects);
346 if (deserializedObject != null)
348 sceneObjects.Add(deserializedObject);
352 m_log.WarnFormat(
"[SERIALIZER]: Aborting load of object from asset {0} as deserialization failed", assetId);
357 bool modified =
false;
367 data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
369 data = Utils.StringToBytes(ToOriginalXmlFormat(sceneObjects[0]));
375 #region manual serialization
377 private static Dictionary<string, Action<SceneObjectPart, XmlReader>> m_SOPXmlProcessors
378 =
new Dictionary<string, Action<SceneObjectPart, XmlReader>>();
380 private static Dictionary<string, Action<TaskInventoryItem, XmlReader>> m_TaskInventoryXmlProcessors
381 =
new Dictionary<string, Action<TaskInventoryItem, XmlReader>>();
383 private static Dictionary<string, Action<PrimitiveBaseShape, XmlReader>> m_ShapeXmlProcessors
384 =
new Dictionary<string, Action<PrimitiveBaseShape, XmlReader>>();
388 #region SOPXmlProcessors initialization
389 m_SOPXmlProcessors.Add(
"AllowedDrop", ProcessAllowedDrop);
390 m_SOPXmlProcessors.Add(
"CreatorID", ProcessCreatorID);
391 m_SOPXmlProcessors.Add(
"CreatorData", ProcessCreatorData);
392 m_SOPXmlProcessors.Add(
"FolderID", ProcessFolderID);
393 m_SOPXmlProcessors.Add(
"InventorySerial", ProcessInventorySerial);
394 m_SOPXmlProcessors.Add(
"TaskInventory", ProcessTaskInventory);
395 m_SOPXmlProcessors.Add(
"UUID", ProcessUUID);
396 m_SOPXmlProcessors.Add(
"LocalId", ProcessLocalId);
397 m_SOPXmlProcessors.Add(
"Name", ProcessName);
398 m_SOPXmlProcessors.Add(
"Material", ProcessMaterial);
399 m_SOPXmlProcessors.Add(
"PassTouches", ProcessPassTouches);
400 m_SOPXmlProcessors.Add(
"PassCollisions", ProcessPassCollisions);
401 m_SOPXmlProcessors.Add(
"RegionHandle", ProcessRegionHandle);
402 m_SOPXmlProcessors.Add(
"ScriptAccessPin", ProcessScriptAccessPin);
403 m_SOPXmlProcessors.Add(
"GroupPosition", ProcessGroupPosition);
404 m_SOPXmlProcessors.Add(
"OffsetPosition", ProcessOffsetPosition);
405 m_SOPXmlProcessors.Add(
"RotationOffset", ProcessRotationOffset);
406 m_SOPXmlProcessors.Add(
"Velocity", ProcessVelocity);
407 m_SOPXmlProcessors.Add(
"AngularVelocity", ProcessAngularVelocity);
408 m_SOPXmlProcessors.Add(
"Acceleration", ProcessAcceleration);
409 m_SOPXmlProcessors.Add(
"Description", ProcessDescription);
410 m_SOPXmlProcessors.Add(
"Color", ProcessColor);
411 m_SOPXmlProcessors.Add(
"Text", ProcessText);
412 m_SOPXmlProcessors.Add(
"SitName", ProcessSitName);
413 m_SOPXmlProcessors.Add(
"TouchName", ProcessTouchName);
414 m_SOPXmlProcessors.Add(
"LinkNum", ProcessLinkNum);
415 m_SOPXmlProcessors.Add(
"ClickAction", ProcessClickAction);
416 m_SOPXmlProcessors.Add(
"Shape", ProcessShape);
417 m_SOPXmlProcessors.Add(
"Scale", ProcessScale);
418 m_SOPXmlProcessors.Add(
"SitTargetOrientation", ProcessSitTargetOrientation);
419 m_SOPXmlProcessors.Add(
"SitTargetPosition", ProcessSitTargetPosition);
420 m_SOPXmlProcessors.Add(
"SitTargetPositionLL", ProcessSitTargetPositionLL);
421 m_SOPXmlProcessors.Add(
"SitTargetOrientationLL", ProcessSitTargetOrientationLL);
422 m_SOPXmlProcessors.Add(
"ParentID", ProcessParentID);
423 m_SOPXmlProcessors.Add(
"CreationDate", ProcessCreationDate);
424 m_SOPXmlProcessors.Add(
"Category", ProcessCategory);
425 m_SOPXmlProcessors.Add(
"SalePrice", ProcessSalePrice);
426 m_SOPXmlProcessors.Add(
"ObjectSaleType", ProcessObjectSaleType);
427 m_SOPXmlProcessors.Add(
"OwnershipCost", ProcessOwnershipCost);
428 m_SOPXmlProcessors.Add(
"GroupID", ProcessGroupID);
429 m_SOPXmlProcessors.Add(
"OwnerID", ProcessOwnerID);
430 m_SOPXmlProcessors.Add(
"LastOwnerID", ProcessLastOwnerID);
431 m_SOPXmlProcessors.Add(
"BaseMask", ProcessBaseMask);
432 m_SOPXmlProcessors.Add(
"OwnerMask", ProcessOwnerMask);
433 m_SOPXmlProcessors.Add(
"GroupMask", ProcessGroupMask);
434 m_SOPXmlProcessors.Add(
"EveryoneMask", ProcessEveryoneMask);
435 m_SOPXmlProcessors.Add(
"NextOwnerMask", ProcessNextOwnerMask);
436 m_SOPXmlProcessors.Add(
"Flags", ProcessFlags);
437 m_SOPXmlProcessors.Add(
"CollisionSound", ProcessCollisionSound);
438 m_SOPXmlProcessors.Add(
"CollisionSoundVolume", ProcessCollisionSoundVolume);
439 m_SOPXmlProcessors.Add(
"MediaUrl", ProcessMediaUrl);
440 m_SOPXmlProcessors.Add(
"AttachedPos", ProcessAttachedPos);
441 m_SOPXmlProcessors.Add(
"DynAttrs", ProcessDynAttrs);
442 m_SOPXmlProcessors.Add(
"TextureAnimation", ProcessTextureAnimation);
443 m_SOPXmlProcessors.Add(
"ParticleSystem", ProcessParticleSystem);
444 m_SOPXmlProcessors.Add(
"PayPrice0", ProcessPayPrice0);
445 m_SOPXmlProcessors.Add(
"PayPrice1", ProcessPayPrice1);
446 m_SOPXmlProcessors.Add(
"PayPrice2", ProcessPayPrice2);
447 m_SOPXmlProcessors.Add(
"PayPrice3", ProcessPayPrice3);
448 m_SOPXmlProcessors.Add(
"PayPrice4", ProcessPayPrice4);
450 m_SOPXmlProcessors.Add(
"Buoyancy", ProcessBuoyancy);
451 m_SOPXmlProcessors.Add(
"Force", ProcessForce);
452 m_SOPXmlProcessors.Add(
"Torque", ProcessTorque);
453 m_SOPXmlProcessors.Add(
"VolumeDetectActive", ProcessVolumeDetectActive);
456 m_SOPXmlProcessors.Add(
"Vehicle", ProcessVehicle);
458 m_SOPXmlProcessors.Add(
"RotationAxisLocks", ProcessRotationAxisLocks);
459 m_SOPXmlProcessors.Add(
"PhysicsShapeType", ProcessPhysicsShapeType);
460 m_SOPXmlProcessors.Add(
"Density", ProcessDensity);
461 m_SOPXmlProcessors.Add(
"Friction", ProcessFriction);
462 m_SOPXmlProcessors.Add(
"Bounce", ProcessBounce);
463 m_SOPXmlProcessors.Add(
"GravityModifier", ProcessGravityModifier);
464 m_SOPXmlProcessors.Add(
"CameraEyeOffset", ProcessCameraEyeOffset);
465 m_SOPXmlProcessors.Add(
"CameraAtOffset", ProcessCameraAtOffset);
467 m_SOPXmlProcessors.Add(
"SoundID", ProcessSoundID);
468 m_SOPXmlProcessors.Add(
"SoundGain", ProcessSoundGain);
469 m_SOPXmlProcessors.Add(
"SoundFlags", ProcessSoundFlags);
470 m_SOPXmlProcessors.Add(
"SoundRadius", ProcessSoundRadius);
471 m_SOPXmlProcessors.Add(
"SoundQueueing", ProcessSoundQueueing);
475 #region TaskInventoryXmlProcessors initialization
476 m_TaskInventoryXmlProcessors.Add(
"AssetID", ProcessTIAssetID);
477 m_TaskInventoryXmlProcessors.Add(
"BasePermissions", ProcessTIBasePermissions);
478 m_TaskInventoryXmlProcessors.Add(
"CreationDate", ProcessTICreationDate);
479 m_TaskInventoryXmlProcessors.Add(
"CreatorID", ProcessTICreatorID);
480 m_TaskInventoryXmlProcessors.Add(
"CreatorData", ProcessTICreatorData);
481 m_TaskInventoryXmlProcessors.Add(
"Description", ProcessTIDescription);
482 m_TaskInventoryXmlProcessors.Add(
"EveryonePermissions", ProcessTIEveryonePermissions);
483 m_TaskInventoryXmlProcessors.Add(
"Flags", ProcessTIFlags);
484 m_TaskInventoryXmlProcessors.Add(
"GroupID", ProcessTIGroupID);
485 m_TaskInventoryXmlProcessors.Add(
"GroupPermissions", ProcessTIGroupPermissions);
486 m_TaskInventoryXmlProcessors.Add(
"InvType", ProcessTIInvType);
487 m_TaskInventoryXmlProcessors.Add(
"ItemID", ProcessTIItemID);
488 m_TaskInventoryXmlProcessors.Add(
"OldItemID", ProcessTIOldItemID);
489 m_TaskInventoryXmlProcessors.Add(
"LastOwnerID", ProcessTILastOwnerID);
490 m_TaskInventoryXmlProcessors.Add(
"Name", ProcessTIName);
491 m_TaskInventoryXmlProcessors.Add(
"NextPermissions", ProcessTINextPermissions);
492 m_TaskInventoryXmlProcessors.Add(
"OwnerID", ProcessTIOwnerID);
493 m_TaskInventoryXmlProcessors.Add(
"CurrentPermissions", ProcessTICurrentPermissions);
494 m_TaskInventoryXmlProcessors.Add(
"ParentID", ProcessTIParentID);
495 m_TaskInventoryXmlProcessors.Add(
"ParentPartID", ProcessTIParentPartID);
496 m_TaskInventoryXmlProcessors.Add(
"PermsGranter", ProcessTIPermsGranter);
497 m_TaskInventoryXmlProcessors.Add(
"PermsMask", ProcessTIPermsMask);
498 m_TaskInventoryXmlProcessors.Add(
"Type", ProcessTIType);
499 m_TaskInventoryXmlProcessors.Add(
"OwnerChanged", ProcessTIOwnerChanged);
503 #region ShapeXmlProcessors initialization
504 m_ShapeXmlProcessors.Add(
"ProfileCurve", ProcessShpProfileCurve);
505 m_ShapeXmlProcessors.Add(
"TextureEntry", ProcessShpTextureEntry);
506 m_ShapeXmlProcessors.Add(
"ExtraParams", ProcessShpExtraParams);
507 m_ShapeXmlProcessors.Add(
"PathBegin", ProcessShpPathBegin);
508 m_ShapeXmlProcessors.Add(
"PathCurve", ProcessShpPathCurve);
509 m_ShapeXmlProcessors.Add(
"PathEnd", ProcessShpPathEnd);
510 m_ShapeXmlProcessors.Add(
"PathRadiusOffset", ProcessShpPathRadiusOffset);
511 m_ShapeXmlProcessors.Add(
"PathRevolutions", ProcessShpPathRevolutions);
512 m_ShapeXmlProcessors.Add(
"PathScaleX", ProcessShpPathScaleX);
513 m_ShapeXmlProcessors.Add(
"PathScaleY", ProcessShpPathScaleY);
514 m_ShapeXmlProcessors.Add(
"PathShearX", ProcessShpPathShearX);
515 m_ShapeXmlProcessors.Add(
"PathShearY", ProcessShpPathShearY);
516 m_ShapeXmlProcessors.Add(
"PathSkew", ProcessShpPathSkew);
517 m_ShapeXmlProcessors.Add(
"PathTaperX", ProcessShpPathTaperX);
518 m_ShapeXmlProcessors.Add(
"PathTaperY", ProcessShpPathTaperY);
519 m_ShapeXmlProcessors.Add(
"PathTwist", ProcessShpPathTwist);
520 m_ShapeXmlProcessors.Add(
"PathTwistBegin", ProcessShpPathTwistBegin);
521 m_ShapeXmlProcessors.Add(
"PCode", ProcessShpPCode);
522 m_ShapeXmlProcessors.Add(
"ProfileBegin", ProcessShpProfileBegin);
523 m_ShapeXmlProcessors.Add(
"ProfileEnd", ProcessShpProfileEnd);
524 m_ShapeXmlProcessors.Add(
"ProfileHollow", ProcessShpProfileHollow);
525 m_ShapeXmlProcessors.Add(
"Scale", ProcessShpScale);
526 m_ShapeXmlProcessors.Add(
"LastAttachPoint", ProcessShpLastAttach);
527 m_ShapeXmlProcessors.Add(
"State", ProcessShpState);
528 m_ShapeXmlProcessors.Add(
"ProfileShape", ProcessShpProfileShape);
529 m_ShapeXmlProcessors.Add(
"HollowShape", ProcessShpHollowShape);
530 m_ShapeXmlProcessors.Add(
"SculptTexture", ProcessShpSculptTexture);
531 m_ShapeXmlProcessors.Add(
"SculptType", ProcessShpSculptType);
533 m_ShapeXmlProcessors.Add(
"FlexiSoftness", ProcessShpFlexiSoftness);
534 m_ShapeXmlProcessors.Add(
"FlexiTension", ProcessShpFlexiTension);
535 m_ShapeXmlProcessors.Add(
"FlexiDrag", ProcessShpFlexiDrag);
536 m_ShapeXmlProcessors.Add(
"FlexiGravity", ProcessShpFlexiGravity);
537 m_ShapeXmlProcessors.Add(
"FlexiWind", ProcessShpFlexiWind);
538 m_ShapeXmlProcessors.Add(
"FlexiForceX", ProcessShpFlexiForceX);
539 m_ShapeXmlProcessors.Add(
"FlexiForceY", ProcessShpFlexiForceY);
540 m_ShapeXmlProcessors.Add(
"FlexiForceZ", ProcessShpFlexiForceZ);
541 m_ShapeXmlProcessors.Add(
"LightColorR", ProcessShpLightColorR);
542 m_ShapeXmlProcessors.Add(
"LightColorG", ProcessShpLightColorG);
543 m_ShapeXmlProcessors.Add(
"LightColorB", ProcessShpLightColorB);
544 m_ShapeXmlProcessors.Add(
"LightColorA", ProcessShpLightColorA);
545 m_ShapeXmlProcessors.Add(
"LightRadius", ProcessShpLightRadius);
546 m_ShapeXmlProcessors.Add(
"LightCutoff", ProcessShpLightCutoff);
547 m_ShapeXmlProcessors.Add(
"LightFalloff", ProcessShpLightFalloff);
548 m_ShapeXmlProcessors.Add(
"LightIntensity", ProcessShpLightIntensity);
549 m_ShapeXmlProcessors.Add(
"FlexiEntry", ProcessShpFlexiEntry);
550 m_ShapeXmlProcessors.Add(
"LightEntry", ProcessShpLightEntry);
551 m_ShapeXmlProcessors.Add(
"SculptEntry", ProcessShpSculptEntry);
552 m_ShapeXmlProcessors.Add(
"Media", ProcessShpMedia);
556 #region SOPXmlProcessors
557 private static void ProcessAllowedDrop(
SceneObjectPart obj, XmlReader reader)
559 obj.AllowedDrop = Util.ReadBoolean(reader);
562 private static void ProcessCreatorID(
SceneObjectPart obj, XmlReader reader)
564 obj.CreatorID = Util.ReadUUID(reader,
"CreatorID");
567 private static void ProcessCreatorData(
SceneObjectPart obj, XmlReader reader)
569 obj.CreatorData = reader.ReadElementContentAsString(
"CreatorData", String.Empty);
572 private static void ProcessFolderID(
SceneObjectPart obj, XmlReader reader)
574 obj.FolderID = Util.ReadUUID(reader,
"FolderID");
577 private static void ProcessInventorySerial(
SceneObjectPart obj, XmlReader reader)
579 obj.InventorySerial = (uint)reader.ReadElementContentAsInt(
"InventorySerial",
String.Empty);
582 private static void ProcessTaskInventory(
SceneObjectPart obj, XmlReader reader)
584 obj.TaskInventory = ReadTaskInventory(reader,
"TaskInventory");
589 obj.UUID = Util.ReadUUID(reader,
"UUID");
592 private static void ProcessLocalId(
SceneObjectPart obj, XmlReader reader)
594 obj.LocalId = (uint)reader.ReadElementContentAsLong(
"LocalId",
String.Empty);
599 obj.Name = reader.ReadElementString(
"Name");
602 private static void ProcessMaterial(
SceneObjectPart obj, XmlReader reader)
604 obj.Material = (byte)reader.ReadElementContentAsInt(
"Material",
String.Empty);
607 private static void ProcessPassTouches(
SceneObjectPart obj, XmlReader reader)
609 obj.PassTouches = Util.ReadBoolean(reader);
612 private static void ProcessPassCollisions(
SceneObjectPart obj, XmlReader reader)
614 obj.PassCollisions = Util.ReadBoolean(reader);
617 private static void ProcessRegionHandle(
SceneObjectPart obj, XmlReader reader)
619 obj.RegionHandle = (ulong)reader.ReadElementContentAsLong(
"RegionHandle",
String.Empty);
622 private static void ProcessScriptAccessPin(
SceneObjectPart obj, XmlReader reader)
624 obj.ScriptAccessPin = reader.ReadElementContentAsInt(
"ScriptAccessPin", String.Empty);
627 private static void ProcessGroupPosition(
SceneObjectPart obj, XmlReader reader)
629 obj.GroupPosition = Util.ReadVector(reader,
"GroupPosition");
632 private static void ProcessOffsetPosition(
SceneObjectPart obj, XmlReader reader)
634 obj.OffsetPosition = Util.ReadVector(reader,
"OffsetPosition"); ;
637 private static void ProcessRotationOffset(
SceneObjectPart obj, XmlReader reader)
639 obj.RotationOffset = Util.ReadQuaternion(reader,
"RotationOffset");
642 private static void ProcessVelocity(
SceneObjectPart obj, XmlReader reader)
644 obj.Velocity = Util.ReadVector(reader,
"Velocity");
647 private static void ProcessAngularVelocity(
SceneObjectPart obj, XmlReader reader)
649 obj.AngularVelocity = Util.ReadVector(reader,
"AngularVelocity");
652 private static void ProcessAcceleration(
SceneObjectPart obj, XmlReader reader)
654 obj.Acceleration = Util.ReadVector(reader,
"Acceleration");
657 private static void ProcessDescription(
SceneObjectPart obj, XmlReader reader)
659 obj.Description = reader.ReadElementString(
"Description");
662 private static void ProcessColor(
SceneObjectPart obj, XmlReader reader)
664 reader.ReadStartElement(
"Color");
665 if (reader.Name ==
"R")
667 float r = reader.ReadElementContentAsFloat(
"R", String.Empty);
668 float g = reader.ReadElementContentAsFloat(
"G", String.Empty);
669 float b = reader.ReadElementContentAsFloat(
"B", String.Empty);
670 float a = reader.ReadElementContentAsFloat(
"A", String.Empty);
671 obj.Color = Color.FromArgb((int)a, (
int)r, (
int)g, (
int)b);
672 reader.ReadEndElement();
678 obj.Text = reader.ReadElementString(
"Text", String.Empty);
681 private static void ProcessSitName(
SceneObjectPart obj, XmlReader reader)
683 obj.SitName = reader.ReadElementString(
"SitName", String.Empty);
686 private static void ProcessTouchName(
SceneObjectPart obj, XmlReader reader)
688 obj.TouchName = reader.ReadElementString(
"TouchName", String.Empty);
691 private static void ProcessLinkNum(
SceneObjectPart obj, XmlReader reader)
693 obj.LinkNum = reader.ReadElementContentAsInt(
"LinkNum", String.Empty);
696 private static void ProcessClickAction(
SceneObjectPart obj, XmlReader reader)
698 obj.ClickAction = (byte)reader.ReadElementContentAsInt(
"ClickAction",
String.Empty);
701 private static void ProcessRotationAxisLocks(
SceneObjectPart obj, XmlReader reader)
703 obj.RotationAxisLocks = (byte)reader.ReadElementContentAsInt(
"RotationAxisLocks",
String.Empty);
706 private static void ProcessPhysicsShapeType(
SceneObjectPart obj, XmlReader reader)
708 obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt(
"PhysicsShapeType",
String.Empty);
711 private static void ProcessDensity(
SceneObjectPart obj, XmlReader reader)
713 obj.Density = reader.ReadElementContentAsFloat(
"Density", String.Empty);
716 private static void ProcessFriction(
SceneObjectPart obj, XmlReader reader)
718 obj.Friction = reader.ReadElementContentAsFloat(
"Friction", String.Empty);
721 private static void ProcessBounce(
SceneObjectPart obj, XmlReader reader)
723 obj.Restitution = reader.ReadElementContentAsFloat(
"Bounce", String.Empty);
726 private static void ProcessGravityModifier(
SceneObjectPart obj, XmlReader reader)
728 obj.GravityModifier = reader.ReadElementContentAsFloat(
"GravityModifier", String.Empty);
731 private static void ProcessCameraEyeOffset(
SceneObjectPart obj, XmlReader reader)
733 obj.SetCameraEyeOffset(Util.ReadVector(reader,
"CameraEyeOffset"));
736 private static void ProcessCameraAtOffset(
SceneObjectPart obj, XmlReader reader)
738 obj.SetCameraAtOffset(Util.ReadVector(reader,
"CameraAtOffset"));
741 private static void ProcessSoundID(
SceneObjectPart obj, XmlReader reader)
743 obj.Sound = Util.ReadUUID(reader,
"SoundID");
746 private static void ProcessSoundGain(
SceneObjectPart obj, XmlReader reader)
748 obj.SoundGain = reader.ReadElementContentAsDouble(
"SoundGain", String.Empty);
751 private static void ProcessSoundFlags(
SceneObjectPart obj, XmlReader reader)
753 obj.SoundFlags = (byte)reader.ReadElementContentAsInt(
"SoundFlags",
String.Empty);
756 private static void ProcessSoundRadius(
SceneObjectPart obj, XmlReader reader)
758 obj.SoundRadius = reader.ReadElementContentAsDouble(
"SoundRadius", String.Empty);
761 private static void ProcessSoundQueueing(
SceneObjectPart obj, XmlReader reader)
763 obj.SoundQueueing = Util.ReadBoolean(reader);
766 private static void ProcessVehicle(
SceneObjectPart obj, XmlReader reader)
768 SOPVehicle vehicle = SOPVehicle.FromXml2(reader);
772 obj.VehicleParams = null;
774 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
779 obj.VehicleParams = vehicle;
783 private static void ProcessShape(
SceneObjectPart obj, XmlReader reader)
785 List<string> errorNodeNames;
786 obj.Shape = ReadShape(reader,
"Shape", out errorNodeNames, obj);
788 if (errorNodeNames != null)
791 "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors in properties {2}.",
792 obj.Name, obj.UUID, string.Join(
", ", errorNodeNames.ToArray()));
796 private static void ProcessScale(
SceneObjectPart obj, XmlReader reader)
798 obj.Scale = Util.ReadVector(reader,
"Scale");
801 private static void ProcessSitTargetOrientation(
SceneObjectPart obj, XmlReader reader)
803 obj.SitTargetOrientation = Util.ReadQuaternion(reader,
"SitTargetOrientation");
806 private static void ProcessSitTargetPosition(
SceneObjectPart obj, XmlReader reader)
808 obj.SitTargetPosition = Util.ReadVector(reader,
"SitTargetPosition");
811 private static void ProcessSitTargetPositionLL(
SceneObjectPart obj, XmlReader reader)
813 obj.SitTargetPositionLL = Util.ReadVector(reader,
"SitTargetPositionLL");
816 private static void ProcessSitTargetOrientationLL(
SceneObjectPart obj, XmlReader reader)
818 obj.SitTargetOrientationLL = Util.ReadQuaternion(reader,
"SitTargetOrientationLL");
821 private static void ProcessParentID(
SceneObjectPart obj, XmlReader reader)
823 string str = reader.ReadElementContentAsString(
"ParentID", String.Empty);
824 obj.ParentID = Convert.ToUInt32(str);
827 private static void ProcessCreationDate(
SceneObjectPart obj, XmlReader reader)
829 obj.CreationDate = reader.ReadElementContentAsInt(
"CreationDate", String.Empty);
832 private static void ProcessCategory(
SceneObjectPart obj, XmlReader reader)
834 obj.Category = (uint)reader.ReadElementContentAsInt(
"Category",
String.Empty);
837 private static void ProcessSalePrice(
SceneObjectPart obj, XmlReader reader)
839 obj.SalePrice = reader.ReadElementContentAsInt(
"SalePrice", String.Empty);
842 private static void ProcessObjectSaleType(
SceneObjectPart obj, XmlReader reader)
844 obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt(
"ObjectSaleType",
String.Empty);
847 private static void ProcessOwnershipCost(
SceneObjectPart obj, XmlReader reader)
849 obj.OwnershipCost = reader.ReadElementContentAsInt(
"OwnershipCost", String.Empty);
852 private static void ProcessGroupID(
SceneObjectPart obj, XmlReader reader)
854 obj.GroupID = Util.ReadUUID(reader,
"GroupID");
857 private static void ProcessOwnerID(
SceneObjectPart obj, XmlReader reader)
859 obj.OwnerID = Util.ReadUUID(reader,
"OwnerID");
862 private static void ProcessLastOwnerID(
SceneObjectPart obj, XmlReader reader)
864 obj.LastOwnerID = Util.ReadUUID(reader,
"LastOwnerID");
867 private static void ProcessBaseMask(
SceneObjectPart obj, XmlReader reader)
869 obj.BaseMask = (uint)reader.ReadElementContentAsInt(
"BaseMask",
String.Empty);
872 private static void ProcessOwnerMask(
SceneObjectPart obj, XmlReader reader)
874 obj.OwnerMask = (uint)reader.ReadElementContentAsInt(
"OwnerMask",
String.Empty);
877 private static void ProcessGroupMask(
SceneObjectPart obj, XmlReader reader)
879 obj.GroupMask = (uint)reader.ReadElementContentAsInt(
"GroupMask",
String.Empty);
882 private static void ProcessEveryoneMask(
SceneObjectPart obj, XmlReader reader)
884 obj.EveryoneMask = (uint)reader.ReadElementContentAsInt(
"EveryoneMask",
String.Empty);
887 private static void ProcessNextOwnerMask(
SceneObjectPart obj, XmlReader reader)
889 obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt(
"NextOwnerMask",
String.Empty);
892 private static void ProcessFlags(
SceneObjectPart obj, XmlReader reader)
894 obj.Flags = Util.ReadEnum<
PrimFlags>(reader,
"Flags");
897 private static void ProcessCollisionSound(
SceneObjectPart obj, XmlReader reader)
899 obj.CollisionSound = Util.ReadUUID(reader,
"CollisionSound");
902 private static void ProcessCollisionSoundVolume(
SceneObjectPart obj, XmlReader reader)
904 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat(
"CollisionSoundVolume", String.Empty);
907 private static void ProcessMediaUrl(
SceneObjectPart obj, XmlReader reader)
909 obj.MediaUrl = reader.ReadElementContentAsString(
"MediaUrl", String.Empty);
912 private static void ProcessAttachedPos(
SceneObjectPart obj, XmlReader reader)
914 obj.AttachedPos = Util.ReadVector(reader,
"AttachedPos");
917 private static void ProcessDynAttrs(
SceneObjectPart obj, XmlReader reader)
919 obj.DynAttrs.ReadXml(reader);
922 private static void ProcessTextureAnimation(
SceneObjectPart obj, XmlReader reader)
924 obj.TextureAnimation = Convert.FromBase64String(reader.ReadElementContentAsString(
"TextureAnimation", String.Empty));
927 private static void ProcessParticleSystem(
SceneObjectPart obj, XmlReader reader)
929 obj.ParticleSystem = Convert.FromBase64String(reader.ReadElementContentAsString(
"ParticleSystem", String.Empty));
932 private static void ProcessPayPrice0(
SceneObjectPart obj, XmlReader reader)
934 obj.PayPrice[0] = (int)reader.ReadElementContentAsInt(
"PayPrice0",
String.Empty);
937 private static void ProcessPayPrice1(
SceneObjectPart obj, XmlReader reader)
939 obj.PayPrice[1] = (int)reader.ReadElementContentAsInt(
"PayPrice1",
String.Empty);
942 private static void ProcessPayPrice2(
SceneObjectPart obj, XmlReader reader)
944 obj.PayPrice[2] = (int)reader.ReadElementContentAsInt(
"PayPrice2",
String.Empty);
947 private static void ProcessPayPrice3(
SceneObjectPart obj, XmlReader reader)
949 obj.PayPrice[3] = (int)reader.ReadElementContentAsInt(
"PayPrice3",
String.Empty);
952 private static void ProcessPayPrice4(
SceneObjectPart obj, XmlReader reader)
954 obj.PayPrice[4] = (int)reader.ReadElementContentAsInt(
"PayPrice4",
String.Empty);
957 private static void ProcessBuoyancy(
SceneObjectPart obj, XmlReader reader)
959 obj.Buoyancy = (float)reader.ReadElementContentAsFloat(
"Buoyancy",
String.Empty);
962 private static void ProcessForce(
SceneObjectPart obj, XmlReader reader)
964 obj.Force = Util.ReadVector(reader,
"Force");
966 private static void ProcessTorque(
SceneObjectPart obj, XmlReader reader)
968 obj.Torque = Util.ReadVector(reader,
"Torque");
971 private static void ProcessVolumeDetectActive(
SceneObjectPart obj, XmlReader reader)
973 obj.VolumeDetectActive = Util.ReadBoolean(reader);
978 #region TaskInventoryXmlProcessors
981 item.AssetID = Util.ReadUUID(reader,
"AssetID");
984 private static void ProcessTIBasePermissions(
TaskInventoryItem item, XmlReader reader)
986 item.BasePermissions = (uint)reader.ReadElementContentAsInt(
"BasePermissions",
String.Empty);
989 private static void ProcessTICreationDate(
TaskInventoryItem item, XmlReader reader)
991 item.CreationDate = (uint)reader.ReadElementContentAsInt(
"CreationDate",
String.Empty);
996 item.CreatorID = Util.ReadUUID(reader,
"CreatorID");
999 private static void ProcessTICreatorData(
TaskInventoryItem item, XmlReader reader)
1001 item.CreatorData = reader.ReadElementContentAsString(
"CreatorData", String.Empty);
1004 private static void ProcessTIDescription(
TaskInventoryItem item, XmlReader reader)
1006 item.Description = reader.ReadElementContentAsString(
"Description", String.Empty);
1009 private static void ProcessTIEveryonePermissions(
TaskInventoryItem item, XmlReader reader)
1011 item.EveryonePermissions = (uint)reader.ReadElementContentAsInt(
"EveryonePermissions",
String.Empty);
1016 item.Flags = (uint)reader.ReadElementContentAsInt(
"Flags",
String.Empty);
1021 item.GroupID = Util.ReadUUID(reader,
"GroupID");
1024 private static void ProcessTIGroupPermissions(
TaskInventoryItem item, XmlReader reader)
1026 item.GroupPermissions = (uint)reader.ReadElementContentAsInt(
"GroupPermissions",
String.Empty);
1031 item.InvType = reader.ReadElementContentAsInt(
"InvType", String.Empty);
1036 item.ItemID = Util.ReadUUID(reader,
"ItemID");
1039 private static void ProcessTIOldItemID(
TaskInventoryItem item, XmlReader reader)
1041 item.OldItemID = Util.ReadUUID(reader,
"OldItemID");
1044 private static void ProcessTILastOwnerID(
TaskInventoryItem item, XmlReader reader)
1046 item.LastOwnerID = Util.ReadUUID(reader,
"LastOwnerID");
1051 item.Name = reader.ReadElementContentAsString(
"Name", String.Empty);
1054 private static void ProcessTINextPermissions(
TaskInventoryItem item, XmlReader reader)
1056 item.NextPermissions = (uint)reader.ReadElementContentAsInt(
"NextPermissions",
String.Empty);
1061 item.OwnerID = Util.ReadUUID(reader,
"OwnerID");
1064 private static void ProcessTICurrentPermissions(
TaskInventoryItem item, XmlReader reader)
1066 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt(
"CurrentPermissions",
String.Empty);
1071 item.ParentID = Util.ReadUUID(reader,
"ParentID");
1074 private static void ProcessTIParentPartID(
TaskInventoryItem item, XmlReader reader)
1076 item.ParentPartID = Util.ReadUUID(reader,
"ParentPartID");
1079 private static void ProcessTIPermsGranter(
TaskInventoryItem item, XmlReader reader)
1081 item.PermsGranter = Util.ReadUUID(reader,
"PermsGranter");
1084 private static void ProcessTIPermsMask(
TaskInventoryItem item, XmlReader reader)
1086 item.PermsMask = reader.ReadElementContentAsInt(
"PermsMask", String.Empty);
1091 item.Type = reader.ReadElementContentAsInt(
"Type", String.Empty);
1094 private static void ProcessTIOwnerChanged(
TaskInventoryItem item, XmlReader reader)
1096 item.OwnerChanged = Util.ReadBoolean(reader);
1101 #region ShapeXmlProcessors
1104 shp.ProfileCurve = (byte)reader.ReadElementContentAsInt(
"ProfileCurve",
String.Empty);
1109 byte[] teData = Convert.FromBase64String(reader.ReadElementString(
"TextureEntry"));
1110 shp.Textures =
new Primitive.TextureEntry(teData, 0, teData.Length);
1115 shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString(
"ExtraParams"));
1120 shp.PathBegin = (ushort)reader.ReadElementContentAsInt(
"PathBegin",
String.Empty);
1125 shp.PathCurve = (byte)reader.ReadElementContentAsInt(
"PathCurve",
String.Empty);
1130 shp.PathEnd = (ushort)reader.ReadElementContentAsInt(
"PathEnd",
String.Empty);
1133 private static void ProcessShpPathRadiusOffset(
PrimitiveBaseShape shp, XmlReader reader)
1135 shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt(
"PathRadiusOffset",
String.Empty);
1138 private static void ProcessShpPathRevolutions(
PrimitiveBaseShape shp, XmlReader reader)
1140 shp.PathRevolutions = (byte)reader.ReadElementContentAsInt(
"PathRevolutions",
String.Empty);
1145 shp.PathScaleX = (byte)reader.ReadElementContentAsInt(
"PathScaleX",
String.Empty);
1150 shp.PathScaleY = (byte)reader.ReadElementContentAsInt(
"PathScaleY",
String.Empty);
1155 shp.PathShearX = (byte)reader.ReadElementContentAsInt(
"PathShearX",
String.Empty);
1160 shp.PathShearY = (byte)reader.ReadElementContentAsInt(
"PathShearY",
String.Empty);
1165 shp.PathSkew = (sbyte)reader.ReadElementContentAsInt(
"PathSkew",
String.Empty);
1170 shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt(
"PathTaperX",
String.Empty);
1175 shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt(
"PathTaperY",
String.Empty);
1180 shp.PathTwist = (sbyte)reader.ReadElementContentAsInt(
"PathTwist",
String.Empty);
1183 private static void ProcessShpPathTwistBegin(
PrimitiveBaseShape shp, XmlReader reader)
1185 shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt(
"PathTwistBegin",
String.Empty);
1190 shp.PCode = (byte)reader.ReadElementContentAsInt(
"PCode",
String.Empty);
1195 shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt(
"ProfileBegin",
String.Empty);
1200 shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt(
"ProfileEnd",
String.Empty);
1203 private static void ProcessShpProfileHollow(
PrimitiveBaseShape shp, XmlReader reader)
1205 shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt(
"ProfileHollow",
String.Empty);
1210 shp.Scale = Util.ReadVector(reader,
"Scale");
1215 shp.State = (byte)reader.ReadElementContentAsInt(
"State",
String.Empty);
1220 shp.LastAttachPoint = (byte)reader.ReadElementContentAsInt(
"LastAttachPoint",
String.Empty);
1225 shp.ProfileShape = Util.ReadEnum<
ProfileShape>(reader,
"ProfileShape");
1230 shp.HollowShape = Util.ReadEnum<
HollowShape>(reader,
"HollowShape");
1233 private static void ProcessShpSculptTexture(
PrimitiveBaseShape shp, XmlReader reader)
1235 shp.SculptTexture = Util.ReadUUID(reader,
"SculptTexture");
1240 shp.SculptType = (byte)reader.ReadElementContentAsInt(
"SculptType",
String.Empty);
1243 private static void ProcessShpFlexiSoftness(
PrimitiveBaseShape shp, XmlReader reader)
1245 shp.FlexiSoftness = reader.ReadElementContentAsInt(
"FlexiSoftness", String.Empty);
1250 shp.FlexiTension = reader.ReadElementContentAsFloat(
"FlexiTension", String.Empty);
1255 shp.FlexiDrag = reader.ReadElementContentAsFloat(
"FlexiDrag", String.Empty);
1260 shp.FlexiGravity = reader.ReadElementContentAsFloat(
"FlexiGravity", String.Empty);
1265 shp.FlexiWind = reader.ReadElementContentAsFloat(
"FlexiWind", String.Empty);
1270 shp.FlexiForceX = reader.ReadElementContentAsFloat(
"FlexiForceX", String.Empty);
1275 shp.FlexiForceY = reader.ReadElementContentAsFloat(
"FlexiForceY", String.Empty);
1280 shp.FlexiForceZ = reader.ReadElementContentAsFloat(
"FlexiForceZ", String.Empty);
1285 shp.LightColorR = reader.ReadElementContentAsFloat(
"LightColorR", String.Empty);
1290 shp.LightColorG = reader.ReadElementContentAsFloat(
"LightColorG", String.Empty);
1295 shp.LightColorB = reader.ReadElementContentAsFloat(
"LightColorB", String.Empty);
1300 shp.LightColorA = reader.ReadElementContentAsFloat(
"LightColorA", String.Empty);
1305 shp.LightRadius = reader.ReadElementContentAsFloat(
"LightRadius", String.Empty);
1310 shp.LightCutoff = reader.ReadElementContentAsFloat(
"LightCutoff", String.Empty);
1315 shp.LightFalloff = reader.ReadElementContentAsFloat(
"LightFalloff", String.Empty);
1318 private static void ProcessShpLightIntensity(
PrimitiveBaseShape shp, XmlReader reader)
1320 shp.LightIntensity = reader.ReadElementContentAsFloat(
"LightIntensity", String.Empty);
1325 shp.FlexiEntry = Util.ReadBoolean(reader);
1330 shp.LightEntry = Util.ReadBoolean(reader);
1335 shp.SculptEntry = Util.ReadBoolean(reader);
1340 string value = reader.ReadElementContentAsString(
"Media", String.Empty);
1341 shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
1350 writer.WriteStartElement(String.Empty,
"SceneObjectGroup", String.Empty);
1351 SOPToXml2(writer, sog.
RootPart, options);
1352 writer.WriteStartElement(String.Empty,
"OtherParts", String.Empty);
1357 SOPToXml2(writer, sop, options);
1360 writer.WriteEndElement();
1364 Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
1366 writer.WriteStartElement(String.Empty,
"KeyframeMotion", String.Empty);
1367 writer.WriteBase64(data, 0, data.Length);
1368 writer.WriteEndElement();
1372 writer.WriteEndElement();
1377 writer.WriteStartElement(
"SceneObjectPart");
1378 writer.WriteAttributeString(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
1379 writer.WriteAttributeString(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema");
1381 writer.WriteElementString(
"AllowedDrop", sop.AllowedDrop.ToString().ToLower());
1383 WriteUUID(writer,
"CreatorID", sop.
CreatorID, options);
1386 writer.WriteElementString(
"CreatorData", sop.CreatorData);
1387 else if (options.ContainsKey(
"home"))
1389 if (m_UserManagement == null)
1390 m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface<
IUserManagement>();
1391 string name = m_UserManagement.GetUserName(sop.CreatorID);
1392 writer.WriteElementString(
"CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options[
"home"], name));
1395 WriteUUID(writer,
"FolderID", sop.
FolderID, options);
1396 writer.WriteElementString(
"InventorySerial", sop.InventorySerial.ToString());
1400 WriteUUID(writer,
"UUID", sop.
UUID, options);
1401 writer.WriteElementString(
"LocalId", sop.LocalId.ToString());
1402 writer.WriteElementString(
"Name", sop.Name);
1403 writer.WriteElementString(
"Material", sop.Material.ToString());
1404 writer.WriteElementString(
"PassTouches", sop.PassTouches.ToString().ToLower());
1405 writer.WriteElementString(
"PassCollisions", sop.PassCollisions.ToString().ToLower());
1406 writer.WriteElementString(
"RegionHandle", sop.RegionHandle.ToString());
1407 writer.WriteElementString(
"ScriptAccessPin", sop.ScriptAccessPin.ToString());
1413 WriteVector(writer,
"Velocity", sop.
Velocity);
1416 writer.WriteElementString(
"Description", sop.Description);
1418 writer.WriteStartElement(
"Color");
1419 writer.WriteElementString(
"R", sop.Color.R.ToString(Utils.EnUsCulture));
1420 writer.WriteElementString(
"G", sop.Color.G.ToString(Utils.EnUsCulture));
1421 writer.WriteElementString(
"B", sop.Color.B.ToString(Utils.EnUsCulture));
1422 writer.WriteElementString(
"A", sop.Color.A.ToString(Utils.EnUsCulture));
1423 writer.WriteEndElement();
1425 writer.WriteElementString(
"Text", sop.Text);
1426 writer.WriteElementString(
"SitName", sop.SitName);
1427 writer.WriteElementString(
"TouchName", sop.TouchName);
1429 writer.WriteElementString(
"LinkNum", sop.LinkNum.ToString());
1430 writer.WriteElementString(
"ClickAction", sop.ClickAction.ToString());
1432 WriteShape(writer, sop.
Shape, options);
1434 WriteVector(writer,
"Scale", sop.
Scale);
1439 writer.WriteElementString(
"ParentID", sop.ParentID.ToString());
1440 writer.WriteElementString(
"CreationDate", sop.CreationDate.ToString());
1441 writer.WriteElementString(
"Category", sop.Category.ToString());
1442 writer.WriteElementString(
"SalePrice", sop.SalePrice.ToString());
1443 writer.WriteElementString(
"ObjectSaleType", sop.ObjectSaleType.ToString());
1444 writer.WriteElementString(
"OwnershipCost", sop.OwnershipCost.ToString());
1446 UUID groupID = options.ContainsKey(
"wipe-owners") ?
UUID.Zero : sop.
GroupID;
1447 WriteUUID(writer,
"GroupID", groupID, options);
1449 UUID ownerID = options.ContainsKey(
"wipe-owners") ?
UUID.Zero : sop.
OwnerID;
1450 WriteUUID(writer,
"OwnerID", ownerID, options);
1453 WriteUUID(writer,
"LastOwnerID", lastOwnerID, options);
1455 writer.WriteElementString(
"BaseMask", sop.BaseMask.ToString());
1456 writer.WriteElementString(
"OwnerMask", sop.OwnerMask.ToString());
1457 writer.WriteElementString(
"GroupMask", sop.GroupMask.ToString());
1458 writer.WriteElementString(
"EveryoneMask", sop.EveryoneMask.ToString());
1459 writer.WriteElementString(
"NextOwnerMask", sop.NextOwnerMask.ToString());
1460 WriteFlags(writer,
"Flags", sop.
Flags.ToString(),
options);
1461 WriteUUID(writer,
"CollisionSound", sop.
CollisionSound, options);
1462 writer.WriteElementString(
"CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
1464 writer.WriteElementString(
"MediaUrl", sop.MediaUrl.ToString());
1465 WriteVector(writer,
"AttachedPos", sop.
AttachedPos);
1469 writer.WriteStartElement(
"DynAttrs");
1470 sop.DynAttrs.WriteXml(writer);
1471 writer.WriteEndElement();
1476 writer.WriteElementString(
"PayPrice0", sop.PayPrice[0].ToString());
1477 writer.WriteElementString(
"PayPrice1", sop.PayPrice[1].ToString());
1478 writer.WriteElementString(
"PayPrice2", sop.PayPrice[2].ToString());
1479 writer.WriteElementString(
"PayPrice3", sop.PayPrice[3].ToString());
1480 writer.WriteElementString(
"PayPrice4", sop.PayPrice[4].ToString());
1482 writer.WriteElementString(
"Buoyancy", sop.Buoyancy.ToString());
1484 WriteVector(writer,
"Force", sop.
Force);
1485 WriteVector(writer,
"Torque", sop.
Torque);
1487 writer.WriteElementString(
"VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
1490 sop.VehicleParams.ToXml2(writer);
1493 writer.WriteElementString(
"RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower());
1494 writer.WriteElementString(
"PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
1496 writer.WriteElementString(
"Density", sop.Density.ToString().ToLower());
1498 writer.WriteElementString(
"Friction", sop.Friction.ToString().ToLower());
1500 writer.WriteElementString(
"Bounce", sop.Restitution.ToString().ToLower());
1502 writer.WriteElementString(
"GravityModifier", sop.GravityModifier.ToString().ToLower());
1508 WriteUUID(writer,
"SoundID", sop.
Sound, options);
1509 writer.WriteElementString(
"SoundGain", sop.SoundGain.ToString().ToLower());
1510 writer.WriteElementString(
"SoundFlags", sop.SoundFlags.ToString().ToLower());
1511 writer.WriteElementString(
"SoundRadius", sop.SoundRadius.ToString().ToLower());
1513 writer.WriteElementString(
"SoundQueueing", sop.SoundQueueing.ToString().ToLower());
1515 writer.WriteEndElement();
1518 static void WriteUUID(XmlTextWriter writer,
string name, UUID
id, Dictionary<string, object>
options)
1520 writer.WriteStartElement(name);
1521 if (options.ContainsKey(
"old-guids"))
1522 writer.WriteElementString(
"Guid",
id.ToString());
1524 writer.WriteElementString(
"UUID", id.ToString());
1525 writer.WriteEndElement();
1528 static void WriteVector(XmlTextWriter writer,
string name, Vector3 vec)
1530 writer.WriteStartElement(name);
1531 writer.WriteElementString(
"X", vec.X.ToString(Utils.EnUsCulture));
1532 writer.WriteElementString(
"Y", vec.Y.ToString(Utils.EnUsCulture));
1533 writer.WriteElementString(
"Z", vec.Z.ToString(Utils.EnUsCulture));
1534 writer.WriteEndElement();
1537 static void WriteQuaternion(XmlTextWriter writer,
string name, Quaternion quat)
1539 writer.WriteStartElement(name);
1540 writer.WriteElementString(
"X", quat.X.ToString(Utils.EnUsCulture));
1541 writer.WriteElementString(
"Y", quat.Y.ToString(Utils.EnUsCulture));
1542 writer.WriteElementString(
"Z", quat.Z.ToString(Utils.EnUsCulture));
1543 writer.WriteElementString(
"W", quat.W.ToString(Utils.EnUsCulture));
1544 writer.WriteEndElement();
1547 static void WriteBytes(XmlTextWriter writer,
string name, byte[] data)
1549 writer.WriteStartElement(name);
1554 d = Utils.EmptyBytes;
1555 writer.WriteBase64(d, 0, d.Length);
1556 writer.WriteEndElement();
1560 static void WriteFlags(XmlTextWriter writer,
string name,
string flagsStr, Dictionary<string, object>
options)
1563 writer.WriteElementString(name, flagsStr.Replace(
",",
""));
1570 writer.WriteStartElement(
"TaskInventory");
1574 writer.WriteStartElement(
"TaskInventoryItem");
1576 WriteUUID(writer,
"AssetID", item.
AssetID, options);
1577 writer.WriteElementString(
"BasePermissions", item.BasePermissions.ToString());
1578 writer.WriteElementString(
"CreationDate", item.CreationDate.ToString());
1580 WriteUUID(writer,
"CreatorID", item.
CreatorID, options);
1583 writer.WriteElementString(
"CreatorData", item.CreatorData);
1584 else if (options.ContainsKey(
"home"))
1586 if (m_UserManagement == null)
1588 string name = m_UserManagement.GetUserName(item.CreatorID);
1589 writer.WriteElementString(
"CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options[
"home"], name));
1592 writer.WriteElementString(
"Description", item.Description);
1593 writer.WriteElementString(
"EveryonePermissions", item.EveryonePermissions.ToString());
1594 writer.WriteElementString(
"Flags", item.Flags.ToString());
1596 UUID groupID = options.ContainsKey(
"wipe-owners") ?
UUID.Zero : item.
GroupID;
1597 WriteUUID(writer,
"GroupID", groupID, options);
1599 writer.WriteElementString(
"GroupPermissions", item.GroupPermissions.ToString());
1600 writer.WriteElementString(
"InvType", item.InvType.ToString());
1601 WriteUUID(writer,
"ItemID", item.
ItemID, options);
1602 WriteUUID(writer,
"OldItemID", item.
OldItemID, options);
1605 WriteUUID(writer,
"LastOwnerID", lastOwnerID, options);
1607 writer.WriteElementString(
"Name", item.Name);
1608 writer.WriteElementString(
"NextPermissions", item.NextPermissions.ToString());
1610 UUID ownerID = options.ContainsKey(
"wipe-owners") ?
UUID.Zero : item.
OwnerID;
1611 WriteUUID(writer,
"OwnerID", ownerID, options);
1613 writer.WriteElementString(
"CurrentPermissions", item.CurrentPermissions.ToString());
1614 WriteUUID(writer,
"ParentID", item.
ParentID, options);
1615 WriteUUID(writer,
"ParentPartID", item.
ParentPartID, options);
1616 WriteUUID(writer,
"PermsGranter", item.
PermsGranter, options);
1617 writer.WriteElementString(
"PermsMask", item.PermsMask.ToString());
1618 writer.WriteElementString(
"Type", item.Type.ToString());
1620 bool ownerChanged = options.ContainsKey(
"wipe-owners") ?
false : item.
OwnerChanged;
1621 writer.WriteElementString(
"OwnerChanged", ownerChanged.ToString().ToLower());
1623 writer.WriteEndElement();
1626 writer.WriteEndElement();
1634 writer.WriteStartElement(
"Shape");
1636 writer.WriteElementString(
"ProfileCurve", shp.ProfileCurve.ToString());
1638 writer.WriteStartElement(
"TextureEntry");
1641 te = shp.TextureEntry;
1643 te = Utils.EmptyBytes;
1644 writer.WriteBase64(te, 0, te.Length);
1645 writer.WriteEndElement();
1647 writer.WriteStartElement(
"ExtraParams");
1650 ep = shp.ExtraParams;
1652 ep = Utils.EmptyBytes;
1653 writer.WriteBase64(ep, 0, ep.Length);
1654 writer.WriteEndElement();
1656 writer.WriteElementString(
"PathBegin", shp.PathBegin.ToString());
1657 writer.WriteElementString(
"PathCurve", shp.PathCurve.ToString());
1658 writer.WriteElementString(
"PathEnd", shp.PathEnd.ToString());
1659 writer.WriteElementString(
"PathRadiusOffset", shp.PathRadiusOffset.ToString());
1660 writer.WriteElementString(
"PathRevolutions", shp.PathRevolutions.ToString());
1661 writer.WriteElementString(
"PathScaleX", shp.PathScaleX.ToString());
1662 writer.WriteElementString(
"PathScaleY", shp.PathScaleY.ToString());
1663 writer.WriteElementString(
"PathShearX", shp.PathShearX.ToString());
1664 writer.WriteElementString(
"PathShearY", shp.PathShearY.ToString());
1665 writer.WriteElementString(
"PathSkew", shp.PathSkew.ToString());
1666 writer.WriteElementString(
"PathTaperX", shp.PathTaperX.ToString());
1667 writer.WriteElementString(
"PathTaperY", shp.PathTaperY.ToString());
1668 writer.WriteElementString(
"PathTwist", shp.PathTwist.ToString());
1669 writer.WriteElementString(
"PathTwistBegin", shp.PathTwistBegin.ToString());
1670 writer.WriteElementString(
"PCode", shp.PCode.ToString());
1671 writer.WriteElementString(
"ProfileBegin", shp.ProfileBegin.ToString());
1672 writer.WriteElementString(
"ProfileEnd", shp.ProfileEnd.ToString());
1673 writer.WriteElementString(
"ProfileHollow", shp.ProfileHollow.ToString());
1674 writer.WriteElementString(
"State", shp.State.ToString());
1675 writer.WriteElementString(
"LastAttachPoint", shp.LastAttachPoint.ToString());
1680 WriteUUID(writer,
"SculptTexture", shp.
SculptTexture, options);
1681 writer.WriteElementString(
"SculptType", shp.SculptType.ToString());
1684 writer.WriteElementString(
"FlexiSoftness", shp.FlexiSoftness.ToString());
1685 writer.WriteElementString(
"FlexiTension", shp.FlexiTension.ToString());
1686 writer.WriteElementString(
"FlexiDrag", shp.FlexiDrag.ToString());
1687 writer.WriteElementString(
"FlexiGravity", shp.FlexiGravity.ToString());
1688 writer.WriteElementString(
"FlexiWind", shp.FlexiWind.ToString());
1689 writer.WriteElementString(
"FlexiForceX", shp.FlexiForceX.ToString());
1690 writer.WriteElementString(
"FlexiForceY", shp.FlexiForceY.ToString());
1691 writer.WriteElementString(
"FlexiForceZ", shp.FlexiForceZ.ToString());
1693 writer.WriteElementString(
"LightColorR", shp.LightColorR.ToString());
1694 writer.WriteElementString(
"LightColorG", shp.LightColorG.ToString());
1695 writer.WriteElementString(
"LightColorB", shp.LightColorB.ToString());
1696 writer.WriteElementString(
"LightColorA", shp.LightColorA.ToString());
1697 writer.WriteElementString(
"LightRadius", shp.LightRadius.ToString());
1698 writer.WriteElementString(
"LightCutoff", shp.LightCutoff.ToString());
1699 writer.WriteElementString(
"LightFalloff", shp.LightFalloff.ToString());
1700 writer.WriteElementString(
"LightIntensity", shp.LightIntensity.ToString());
1702 writer.WriteElementString(
"FlexiEntry", shp.FlexiEntry.ToString().ToLower());
1703 writer.WriteElementString(
"LightEntry", shp.LightEntry.ToString().ToLower());
1704 writer.WriteElementString(
"SculptEntry", shp.SculptEntry.ToString().ToLower());
1706 if (shp.
Media != null)
1707 writer.WriteElementString(
"Media", shp.Media.ToXml());
1709 writer.WriteEndElement();
1717 reader.ReadStartElement(
"SceneObjectPart");
1719 bool errors = ExternalRepresentationUtils.ExecuteReadProcessors(
1723 (o, nodeName, e) => {
1724 m_log.Debug(string.Format(
"[SceneObjectSerializer]: Error while parsing element {0} in object {1} {2} ",
1729 throw new XmlException(
string.Format(
"Error parsing object {0} {1}", obj.Name, obj.UUID));
1731 reader.ReadEndElement();
1741 reader.ReadStartElement(name, String.Empty);
1743 while (reader.Name ==
"TaskInventoryItem")
1745 reader.ReadStartElement(
"TaskInventoryItem", String.Empty);
1749 ExternalRepresentationUtils.ExecuteReadProcessors(
1751 m_TaskInventoryXmlProcessors,
1754 reader.ReadEndElement();
1755 tinv.Add(item.ItemID, item);
1759 if (reader.NodeType == XmlNodeType.EndElement)
1760 reader.ReadEndElement();
1774 List<string> internalErrorNodeNames = null;
1778 if (reader.IsEmptyElement)
1781 errorNodeNames = null;
1785 reader.ReadStartElement(name, String.Empty);
1787 ExternalRepresentationUtils.ExecuteReadProcessors(
1789 m_ShapeXmlProcessors,
1791 (o, nodeName, e) => {
1792 m_log.Debug(string.Format(
"[SceneObjectSerializer]: Error while parsing element {0} in Shape property of object {1} {2} ",
1793 nodeName, obj.Name, obj.UUID), e);
1795 if (internalErrorNodeNames == null)
1796 internalErrorNodeNames =
new List<string>();
1797 internalErrorNodeNames.Add(nodeName);
1800 reader.ReadEndElement();
1802 errorNodeNames = internalErrorNodeNames;
static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, string scriptedState)
static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates)
Serialize a scene object to the original xml format
Vector3 GroupPosition
The position of the entire group that this prim belongs to.
static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary< string, object > options)
static bool TryFromXml(string xml, out CoalescedSceneObjects coa)
Scene Scene
The scene to which this entity belongs
static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary< string, object >options)
Vector3 SitTargetPosition
Quaternion SitTargetOrientation
static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
Vector3 GetCameraAtOffset()
A dictionary containing task inventory items. Indexed by item UUID.
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
PrimFlags Flags
Property flags. See OpenMetaverse.PrimFlags
MediaList Media
Entries to store media textures on each face
int CountNamespaces
Get the number of namespaces
Represents an item in a task inventory
Serialize and deserialize scene objects.
Quaternion SitTargetOrientationLL
string MediaUrl
Used for media on a prim.
static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
Serialize a scene object to the original xml format
UUID FolderID
A relic from when we we thought that prims contained folder objects. In reality, prim == folder Expos...
Vector3 Scale
Change the scale of this part.
static SceneObjectPart Xml2ToSOP(XmlReader reader)
string CreatorData
Data about the creator in the form home_url;name
TaskInventoryDictionary TaskInventory
static SceneObjectPart FromXml(XmlReader xmlReader)
Restore this part from the serialized xml representation.
static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement)
Serialize a scene object to the original xml format
ProfileShape ProfileShape
Vector3 GetCameraEyeOffset()
static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary< string, object > options)
static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
Deserialize a scene object from the original xml format
static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary< string, object > options, Scene scene)
Vector3 AngularVelocity
Get or set angular velocity. Does not schedule update.
static SceneObjectGroup FromXml2Format(string xmlData)
Vector3 SitTargetPositionLL
static TaskInventoryDictionary ReadTaskInventory(XmlReader reader, string name)
static PrimitiveBaseShape ReadShape(XmlReader reader, string name, out List< string > errorNodeNames, SceneObjectPart obj)
Read a shape from xml input
SceneObjectGroup ParentGroup
Serialize and deserialize coalesced scene objects.
static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader)
Deserialize a scene object from the original xml format
DAMap DynAttrs
Dynamic attributes can be created and deleted as required.
KeyframeMotion KeyframeMotion
static byte[] ModifySerializedObject(UUID assetId, byte[] data, SceneObjectModifier modifier)
Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializi...
static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates)
Serialize a scene object to the original xml format
This maintains the relationship between a UUID and a user name.
Represents a coalescene of scene objects. A coalescence occurs when objects that are not in the same ...
static string ToXml2Format(SceneObjectGroup sceneObject)
Serialize a scene object to the 'xml2' format.
Quaternion RotationOffset