aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorJonathan Freedman2010-10-17 18:45:25 -0400
committerJonathan Freedman2010-10-17 18:45:25 -0400
commit4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65 (patch)
tree79142f2364b658f52b63e3ae688a5521290e2a4f /OpenSim/Region/Framework/Scenes
parent* more url / hg cleanup (diff)
parentMerge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.zip
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.gz
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.bz2
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs125
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs1262
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs237
3 files changed, 1431 insertions, 193 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 39b109b..7a6449d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -39,6 +39,7 @@ using OpenMetaverse.Packets;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Scripting; 41using OpenSim.Region.Framework.Scenes.Scripting;
42using OpenSim.Region.Framework.Scenes.Serialization;
42using OpenSim.Region.Physics.Manager; 43using OpenSim.Region.Physics.Manager;
43 44
44namespace OpenSim.Region.Framework.Scenes 45namespace OpenSim.Region.Framework.Scenes
@@ -118,40 +119,36 @@ namespace OpenSim.Region.Framework.Scenes
118 /// <value> 119 /// <value>
119 /// Is this sop a root part? 120 /// Is this sop a root part?
120 /// </value> 121 /// </value>
121 [XmlIgnore] 122
122 public bool IsRoot 123 public bool IsRoot
123 { 124 {
124 get { return ParentGroup.RootPart == this; } 125 get { return ParentGroup.RootPart == this; }
125 } 126 }
126 127
127 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
128 // use a new instance every time)
129 private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
130
131 #region Fields 128 #region Fields
132 129
133 public bool AllowedDrop; 130 public bool AllowedDrop;
134 131
135 [XmlIgnore] 132
136 public bool DIE_AT_EDGE; 133 public bool DIE_AT_EDGE;
137 134
138 [XmlIgnore] 135
139 public bool RETURN_AT_EDGE; 136 public bool RETURN_AT_EDGE;
140 137
141 [XmlIgnore] 138
142 public bool BlockGrab; 139 public bool BlockGrab;
143 140
144 [XmlIgnore] 141
145 public bool StatusSandbox; 142 public bool StatusSandbox;
146 143
147 [XmlIgnore] 144
148 public Vector3 StatusSandboxPos; 145 public Vector3 StatusSandboxPos;
149 146
150 // TODO: This needs to be persisted in next XML version update! 147 // TODO: This needs to be persisted in next XML version update!
151 [XmlIgnore] 148
152 public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; 149 public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
153 150
154 [XmlIgnore] 151
155 public PhysicsActor PhysActor 152 public PhysicsActor PhysActor
156 { 153 {
157 get { return m_physActor; } 154 get { return m_physActor; }
@@ -166,43 +163,43 @@ namespace OpenSim.Region.Framework.Scenes
166 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. 163 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
167 // Not a big problem as long as the script that sets it remains in the prim on startup. 164 // Not a big problem as long as the script that sets it remains in the prim on startup.
168 // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script) 165 // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script)
169 [XmlIgnore] 166
170 public UUID Sound; 167 public UUID Sound;
171 168
172 [XmlIgnore] 169
173 public byte SoundFlags; 170 public byte SoundFlags;
174 171
175 [XmlIgnore] 172
176 public double SoundGain; 173 public double SoundGain;
177 174
178 [XmlIgnore] 175
179 public double SoundRadius; 176 public double SoundRadius;
180 177
181 [XmlIgnore] 178
182 public uint TimeStampFull; 179 public uint TimeStampFull;
183 180
184 [XmlIgnore] 181
185 public uint TimeStampLastActivity; // Will be used for AutoReturn 182 public uint TimeStampLastActivity; // Will be used for AutoReturn
186 183
187 [XmlIgnore] 184
188 public uint TimeStampTerse; 185 public uint TimeStampTerse;
189 186
190 [XmlIgnore] 187
191 public UUID FromItemID; 188 public UUID FromItemID;
192 189
193 [XmlIgnore] 190
194 public UUID FromFolderID; 191 public UUID FromFolderID;
195 192
196 [XmlIgnore] 193
197 public int STATUS_ROTATE_X; 194 public int STATUS_ROTATE_X;
198 195
199 [XmlIgnore] 196
200 public int STATUS_ROTATE_Y; 197 public int STATUS_ROTATE_Y;
201 198
202 [XmlIgnore] 199
203 public int STATUS_ROTATE_Z; 200 public int STATUS_ROTATE_Z;
204 201
205 [XmlIgnore] 202
206 private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>(); 203 private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>();
207 204
208 /// <value> 205 /// <value>
@@ -211,68 +208,68 @@ namespace OpenSim.Region.Framework.Scenes
211 /// </value> 208 /// </value>
212 private UUID m_fromUserInventoryItemID; 209 private UUID m_fromUserInventoryItemID;
213 210
214 [XmlIgnore] 211
215 public UUID FromUserInventoryItemID 212 public UUID FromUserInventoryItemID
216 { 213 {
217 get { return m_fromUserInventoryItemID; } 214 get { return m_fromUserInventoryItemID; }
218 } 215 }
219 216
220 [XmlIgnore] 217
221 public bool IsAttachment; 218 public bool IsAttachment;
222 219
223 [XmlIgnore] 220
224 public scriptEvents AggregateScriptEvents; 221 public scriptEvents AggregateScriptEvents;
225 222
226 [XmlIgnore] 223
227 public UUID AttachedAvatar; 224 public UUID AttachedAvatar;
228 225
229 [XmlIgnore] 226
230 public Vector3 AttachedPos; 227 public Vector3 AttachedPos;
231 228
232 [XmlIgnore] 229
233 public uint AttachmentPoint; 230 public uint AttachmentPoint;
234 231
235 [XmlIgnore] 232
236 public Vector3 RotationAxis = Vector3.One; 233 public Vector3 RotationAxis = Vector3.One;
237 234
238 [XmlIgnore] 235
239 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 236 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
240 // Certainly this must be a persistant setting finally 237 // Certainly this must be a persistant setting finally
241 238
242 [XmlIgnore] 239
243 public bool IsWaitingForFirstSpinUpdatePacket; 240 public bool IsWaitingForFirstSpinUpdatePacket;
244 241
245 [XmlIgnore] 242
246 public Quaternion SpinOldOrientation = Quaternion.Identity; 243 public Quaternion SpinOldOrientation = Quaternion.Identity;
247 244
248 [XmlIgnore] 245
249 public Quaternion m_APIDTarget = Quaternion.Identity; 246 public Quaternion m_APIDTarget = Quaternion.Identity;
250 247
251 [XmlIgnore] 248
252 public float m_APIDDamp = 0; 249 public float m_APIDDamp = 0;
253 250
254 [XmlIgnore] 251
255 public float m_APIDStrength = 0; 252 public float m_APIDStrength = 0;
256 253
257 /// <summary> 254 /// <summary>
258 /// This part's inventory 255 /// This part's inventory
259 /// </summary> 256 /// </summary>
260 [XmlIgnore] 257
261 public IEntityInventory Inventory 258 public IEntityInventory Inventory
262 { 259 {
263 get { return m_inventory; } 260 get { return m_inventory; }
264 } 261 }
265 protected SceneObjectPartInventory m_inventory; 262 protected SceneObjectPartInventory m_inventory;
266 263
267 [XmlIgnore] 264
268 public bool Undoing; 265 public bool Undoing;
269 266
270 [XmlIgnore] 267
271 public bool IgnoreUndoUpdate = false; 268 public bool IgnoreUndoUpdate = false;
272 269
273 [XmlIgnore] 270
274 private PrimFlags LocalFlags; 271 private PrimFlags LocalFlags;
275 [XmlIgnore] 272
276 private float m_damage = -1.0f; 273 private float m_damage = -1.0f;
277 private byte[] m_TextureAnimation; 274 private byte[] m_TextureAnimation;
278 private byte m_clickAction; 275 private byte m_clickAction;
@@ -280,9 +277,9 @@ namespace OpenSim.Region.Framework.Scenes
280 private string m_description = String.Empty; 277 private string m_description = String.Empty;
281 private readonly List<uint> m_lastColliders = new List<uint>(); 278 private readonly List<uint> m_lastColliders = new List<uint>();
282 private int m_linkNum; 279 private int m_linkNum;
283 [XmlIgnore] 280
284 private int m_scriptAccessPin; 281 private int m_scriptAccessPin;
285 [XmlIgnore] 282
286 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); 283 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
287 private string m_sitName = String.Empty; 284 private string m_sitName = String.Empty;
288 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 285 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
@@ -548,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
548 } 545 }
549 546
550 547
551 [XmlIgnore] 548
552 public Dictionary<int, string> CollisionFilter 549 public Dictionary<int, string> CollisionFilter
553 { 550 {
554 get { return m_CollisionFilter; } 551 get { return m_CollisionFilter; }
@@ -558,21 +555,21 @@ namespace OpenSim.Region.Framework.Scenes
558 } 555 }
559 } 556 }
560 557
561 [XmlIgnore] 558
562 public Quaternion APIDTarget 559 public Quaternion APIDTarget
563 { 560 {
564 get { return m_APIDTarget; } 561 get { return m_APIDTarget; }
565 set { m_APIDTarget = value; } 562 set { m_APIDTarget = value; }
566 } 563 }
567 564
568 [XmlIgnore] 565
569 public float APIDDamp 566 public float APIDDamp
570 { 567 {
571 get { return m_APIDDamp; } 568 get { return m_APIDDamp; }
572 set { m_APIDDamp = value; } 569 set { m_APIDDamp = value; }
573 } 570 }
574 571
575 [XmlIgnore] 572
576 public float APIDStrength 573 public float APIDStrength
577 { 574 {
578 get { return m_APIDStrength; } 575 get { return m_APIDStrength; }
@@ -618,35 +615,35 @@ namespace OpenSim.Region.Framework.Scenes
618 set { m_LoopSoundSlavePrims = value; } 615 set { m_LoopSoundSlavePrims = value; }
619 } 616 }
620 617
621 [XmlIgnore] 618
622 public Byte[] TextureAnimation 619 public Byte[] TextureAnimation
623 { 620 {
624 get { return m_TextureAnimation; } 621 get { return m_TextureAnimation; }
625 set { m_TextureAnimation = value; } 622 set { m_TextureAnimation = value; }
626 } 623 }
627 624
628 [XmlIgnore] 625
629 public Byte[] ParticleSystem 626 public Byte[] ParticleSystem
630 { 627 {
631 get { return m_particleSystem; } 628 get { return m_particleSystem; }
632 set { m_particleSystem = value; } 629 set { m_particleSystem = value; }
633 } 630 }
634 631
635 [XmlIgnore] 632
636 public DateTime Expires 633 public DateTime Expires
637 { 634 {
638 get { return m_expires; } 635 get { return m_expires; }
639 set { m_expires = value; } 636 set { m_expires = value; }
640 } 637 }
641 638
642 [XmlIgnore] 639
643 public DateTime Rezzed 640 public DateTime Rezzed
644 { 641 {
645 get { return m_rezzed; } 642 get { return m_rezzed; }
646 set { m_rezzed = value; } 643 set { m_rezzed = value; }
647 } 644 }
648 645
649 [XmlIgnore] 646
650 public float Damage 647 public float Damage
651 { 648 {
652 get { return m_damage; } 649 get { return m_damage; }
@@ -1019,7 +1016,7 @@ namespace OpenSim.Region.Framework.Scenes
1019 } 1016 }
1020 } 1017 }
1021 1018
1022 [XmlIgnore] 1019
1023 public bool CreateSelected 1020 public bool CreateSelected
1024 { 1021 {
1025 get { return m_createSelected; } 1022 get { return m_createSelected; }
@@ -1201,14 +1198,14 @@ namespace OpenSim.Region.Framework.Scenes
1201 } 1198 }
1202 } 1199 }
1203 1200
1204 [XmlIgnore] 1201
1205 public UUID SitTargetAvatar 1202 public UUID SitTargetAvatar
1206 { 1203 {
1207 get { return m_sitTargetAvatar; } 1204 get { return m_sitTargetAvatar; }
1208 set { m_sitTargetAvatar = value; } 1205 set { m_sitTargetAvatar = value; }
1209 } 1206 }
1210 1207
1211 [XmlIgnore] 1208
1212 public virtual UUID RegionID 1209 public virtual UUID RegionID
1213 { 1210 {
1214 get 1211 get
@@ -1222,7 +1219,7 @@ namespace OpenSim.Region.Framework.Scenes
1222 } 1219 }
1223 1220
1224 private UUID _parentUUID = UUID.Zero; 1221 private UUID _parentUUID = UUID.Zero;
1225 [XmlIgnore] 1222
1226 public UUID ParentUUID 1223 public UUID ParentUUID
1227 { 1224 {
1228 get 1225 get
@@ -1236,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes
1236 set { _parentUUID = value; } 1233 set { _parentUUID = value; }
1237 } 1234 }
1238 1235
1239 [XmlIgnore] 1236
1240 public string SitAnimation 1237 public string SitAnimation
1241 { 1238 {
1242 get { return m_sitAnimation; } 1239 get { return m_sitAnimation; }
@@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes
1850 /// </summary> 1847 /// </summary>
1851 /// <param name="xmlReader"></param> 1848 /// <param name="xmlReader"></param>
1852 /// <returns></returns> 1849 /// <returns></returns>
1853 public static SceneObjectPart FromXml(XmlReader xmlReader) 1850 public static SceneObjectPart FromXml(XmlTextReader xmlReader)
1854 { 1851 {
1855 return FromXml(UUID.Zero, xmlReader); 1852 return FromXml(UUID.Zero, xmlReader);
1856 } 1853 }
@@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes
1861 /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param> 1858 /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param>
1862 /// <param name="xmlReader"></param> 1859 /// <param name="xmlReader"></param>
1863 /// <returns></returns> 1860 /// <returns></returns>
1864 public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) 1861 public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader)
1865 { 1862 {
1866 SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); 1863 SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader);
1867 part.m_fromUserInventoryItemID = fromUserInventoryItemId; 1864 part.m_fromUserInventoryItemID = fromUserInventoryItemId;
1868 1865
1869 // for tempOnRez objects, we have to fix the Expire date. 1866 // for tempOnRez objects, we have to fix the Expire date.
@@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes
4058 /// Serialize this part to xml. 4055 /// Serialize this part to xml.
4059 /// </summary> 4056 /// </summary>
4060 /// <param name="xmlWriter"></param> 4057 /// <param name="xmlWriter"></param>
4061 public void ToXml(XmlWriter xmlWriter) 4058 public void ToXml(XmlTextWriter xmlWriter)
4062 { 4059 {
4063 serializer.Serialize(xmlWriter, this); 4060 SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary<string, object>());
4064 } 4061 }
4065 4062
4066 public void TriggerScriptChangedEvent(Changed val) 4063 public void TriggerScriptChangedEvent(Changed val)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index f5f6b90..252304b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -26,6 +26,8 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Drawing;
29using System.IO; 31using System.IO;
30using System.Reflection; 32using System.Reflection;
31using System.Xml; 33using System.Xml;
@@ -65,14 +67,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 67 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
66 //int time = System.Environment.TickCount; 68 //int time = System.Environment.TickCount;
67 69
68 // libomv.types changes UUID to Guid
69 xmlData = xmlData.Replace("<UUID>", "<Guid>");
70 xmlData = xmlData.Replace("</UUID>", "</Guid>");
71
72 // Handle Nested <UUID><UUID> property
73 xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
74 xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
75
76 try 70 try
77 { 71 {
78 StringReader sr; 72 StringReader sr;
@@ -124,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
124 } 118 }
125 } 119 }
126 120
121
127 /// <summary> 122 /// <summary>
128 /// Serialize a scene object to the original xml format 123 /// Serialize a scene object to the original xml format
129 /// </summary> 124 /// </summary>
@@ -154,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
154 149
155 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 150 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
156 writer.WriteStartElement(String.Empty, "RootPart", String.Empty); 151 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
157 ToOriginalXmlFormat(sceneObject.RootPart, writer); 152 ToXmlFormat(sceneObject.RootPart, writer);
158 writer.WriteEndElement(); 153 writer.WriteEndElement();
159 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); 154 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
160 155
@@ -165,7 +160,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
165 if (part.UUID != sceneObject.RootPart.UUID) 160 if (part.UUID != sceneObject.RootPart.UUID)
166 { 161 {
167 writer.WriteStartElement(String.Empty, "Part", String.Empty); 162 writer.WriteStartElement(String.Empty, "Part", String.Empty);
168 ToOriginalXmlFormat(part, writer); 163 ToXmlFormat(part, writer);
169 writer.WriteEndElement(); 164 writer.WriteEndElement();
170 } 165 }
171 } 166 }
@@ -177,9 +172,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
177 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 172 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
178 } 173 }
179 174
180 protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) 175 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
181 { 176 {
182 part.ToXml(writer); 177 SOPToXml2(writer, part, new Dictionary<string, object>());
183 } 178 }
184 179
185 public static SceneObjectGroup FromXml2Format(string xmlData) 180 public static SceneObjectGroup FromXml2Format(string xmlData)
@@ -187,14 +182,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
187 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 182 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
188 //int time = System.Environment.TickCount; 183 //int time = System.Environment.TickCount;
189 184
190 // libomv.types changes UUID to Guid
191 xmlData = xmlData.Replace("<UUID>", "<Guid>");
192 xmlData = xmlData.Replace("</UUID>", "</Guid>");
193
194 // Handle Nested <UUID><UUID> property
195 xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
196 xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
197
198 try 185 try
199 { 186 {
200 XmlDocument doc = new XmlDocument(); 187 XmlDocument doc = new XmlDocument();
@@ -259,40 +246,1237 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
259 { 246 {
260 using (XmlTextWriter writer = new XmlTextWriter(sw)) 247 using (XmlTextWriter writer = new XmlTextWriter(sw))
261 { 248 {
262 ToXml2Format(sceneObject, writer); 249 SOGToXml2(writer, sceneObject, new Dictionary<string,object>());
263 } 250 }
264 251
265 return sw.ToString(); 252 return sw.ToString();
266 } 253 }
267 } 254 }
268 255
269 /// <summary> 256
270 /// Serialize a scene object to the 'xml2' format. 257 #region manual serialization
271 /// </summary> 258
272 /// <param name="sceneObject"></param> 259 private delegate void SOPXmlProcessor(SceneObjectPart sop, XmlTextReader reader);
273 /// <returns></returns> 260 private static Dictionary<string, SOPXmlProcessor> m_SOPXmlProcessors = new Dictionary<string, SOPXmlProcessor>();
274 public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) 261
262 private delegate void TaskInventoryXmlProcessor(TaskInventoryItem item, XmlTextReader reader);
263 private static Dictionary<string, TaskInventoryXmlProcessor> m_TaskInventoryXmlProcessors = new Dictionary<string, TaskInventoryXmlProcessor>();
264
265 private delegate void ShapeXmlProcessor(PrimitiveBaseShape shape, XmlTextReader reader);
266 private static Dictionary<string, ShapeXmlProcessor> m_ShapeXmlProcessors = new Dictionary<string, ShapeXmlProcessor>();
267
268 static SceneObjectSerializer()
275 { 269 {
276 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); 270 #region SOPXmlProcessors initialization
277 //int time = System.Environment.TickCount; 271 m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop);
272 m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID);
273 m_SOPXmlProcessors.Add("FolderID", ProcessFolderID);
274 m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial);
275 m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory);
276 m_SOPXmlProcessors.Add("UUID", ProcessUUID);
277 m_SOPXmlProcessors.Add("LocalId", ProcessLocalId);
278 m_SOPXmlProcessors.Add("Name", ProcessName);
279 m_SOPXmlProcessors.Add("Material", ProcessMaterial);
280 m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches);
281 m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle);
282 m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin);
283 m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition);
284 m_SOPXmlProcessors.Add("OffsetPosition", ProcessOffsetPosition);
285 m_SOPXmlProcessors.Add("RotationOffset", ProcessRotationOffset);
286 m_SOPXmlProcessors.Add("Velocity", ProcessVelocity);
287 m_SOPXmlProcessors.Add("AngularVelocity", ProcessAngularVelocity);
288 m_SOPXmlProcessors.Add("Acceleration", ProcessAcceleration);
289 m_SOPXmlProcessors.Add("Description", ProcessDescription);
290 m_SOPXmlProcessors.Add("Color", ProcessColor);
291 m_SOPXmlProcessors.Add("Text", ProcessText);
292 m_SOPXmlProcessors.Add("SitName", ProcessSitName);
293 m_SOPXmlProcessors.Add("TouchName", ProcessTouchName);
294 m_SOPXmlProcessors.Add("LinkNum", ProcessLinkNum);
295 m_SOPXmlProcessors.Add("ClickAction", ProcessClickAction);
296 m_SOPXmlProcessors.Add("Shape", ProcessShape);
297 m_SOPXmlProcessors.Add("Scale", ProcessScale);
298 m_SOPXmlProcessors.Add("UpdateFlag", ProcessUpdateFlag);
299 m_SOPXmlProcessors.Add("SitTargetOrientation", ProcessSitTargetOrientation);
300 m_SOPXmlProcessors.Add("SitTargetPosition", ProcessSitTargetPosition);
301 m_SOPXmlProcessors.Add("SitTargetPositionLL", ProcessSitTargetPositionLL);
302 m_SOPXmlProcessors.Add("SitTargetOrientationLL", ProcessSitTargetOrientationLL);
303 m_SOPXmlProcessors.Add("ParentID", ProcessParentID);
304 m_SOPXmlProcessors.Add("CreationDate", ProcessCreationDate);
305 m_SOPXmlProcessors.Add("Category", ProcessCategory);
306 m_SOPXmlProcessors.Add("SalePrice", ProcessSalePrice);
307 m_SOPXmlProcessors.Add("ObjectSaleType", ProcessObjectSaleType);
308 m_SOPXmlProcessors.Add("OwnershipCost", ProcessOwnershipCost);
309 m_SOPXmlProcessors.Add("GroupID", ProcessGroupID);
310 m_SOPXmlProcessors.Add("OwnerID", ProcessOwnerID);
311 m_SOPXmlProcessors.Add("LastOwnerID", ProcessLastOwnerID);
312 m_SOPXmlProcessors.Add("BaseMask", ProcessBaseMask);
313 m_SOPXmlProcessors.Add("OwnerMask", ProcessOwnerMask);
314 m_SOPXmlProcessors.Add("GroupMask", ProcessGroupMask);
315 m_SOPXmlProcessors.Add("EveryoneMask", ProcessEveryoneMask);
316 m_SOPXmlProcessors.Add("NextOwnerMask", ProcessNextOwnerMask);
317 m_SOPXmlProcessors.Add("Flags", ProcessFlags);
318 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound);
319 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume);
320 m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl);
321 #endregion
322
323 #region TaskInventoryXmlProcessors initialization
324 m_TaskInventoryXmlProcessors.Add("AssetID", ProcessTIAssetID);
325 m_TaskInventoryXmlProcessors.Add("BasePermissions", ProcessTIBasePermissions);
326 m_TaskInventoryXmlProcessors.Add("CreationDate", ProcessTICreationDate);
327 m_TaskInventoryXmlProcessors.Add("CreatorID", ProcessTICreatorID);
328 m_TaskInventoryXmlProcessors.Add("Description", ProcessTIDescription);
329 m_TaskInventoryXmlProcessors.Add("EveryonePermissions", ProcessTIEveryonePermissions);
330 m_TaskInventoryXmlProcessors.Add("Flags", ProcessTIFlags);
331 m_TaskInventoryXmlProcessors.Add("GroupID", ProcessTIGroupID);
332 m_TaskInventoryXmlProcessors.Add("GroupPermissions", ProcessTIGroupPermissions);
333 m_TaskInventoryXmlProcessors.Add("InvType", ProcessTIInvType);
334 m_TaskInventoryXmlProcessors.Add("ItemID", ProcessTIItemID);
335 m_TaskInventoryXmlProcessors.Add("OldItemID", ProcessTIOldItemID);
336 m_TaskInventoryXmlProcessors.Add("LastOwnerID", ProcessTILastOwnerID);
337 m_TaskInventoryXmlProcessors.Add("Name", ProcessTIName);
338 m_TaskInventoryXmlProcessors.Add("NextPermissions", ProcessTINextPermissions);
339 m_TaskInventoryXmlProcessors.Add("OwnerID", ProcessTIOwnerID);
340 m_TaskInventoryXmlProcessors.Add("CurrentPermissions", ProcessTICurrentPermissions);
341 m_TaskInventoryXmlProcessors.Add("ParentID", ProcessTIParentID);
342 m_TaskInventoryXmlProcessors.Add("ParentPartID", ProcessTIParentPartID);
343 m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter);
344 m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask);
345 m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType);
346 m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged);
347
348 #endregion
349
350 #region ShapeXmlProcessors initialization
351 m_ShapeXmlProcessors.Add("ProfileCurve", ProcessShpProfileCurve);
352 m_ShapeXmlProcessors.Add("TextureEntry", ProcessShpTextureEntry);
353 m_ShapeXmlProcessors.Add("ExtraParams", ProcessShpExtraParams);
354 m_ShapeXmlProcessors.Add("PathBegin", ProcessShpPathBegin);
355 m_ShapeXmlProcessors.Add("PathCurve", ProcessShpPathCurve);
356 m_ShapeXmlProcessors.Add("PathEnd", ProcessShpPathEnd);
357 m_ShapeXmlProcessors.Add("PathRadiusOffset", ProcessShpPathRadiusOffset);
358 m_ShapeXmlProcessors.Add("PathRevolutions", ProcessShpPathRevolutions);
359 m_ShapeXmlProcessors.Add("PathScaleX", ProcessShpPathScaleX);
360 m_ShapeXmlProcessors.Add("PathScaleY", ProcessShpPathScaleY);
361 m_ShapeXmlProcessors.Add("PathShearX", ProcessShpPathShearX);
362 m_ShapeXmlProcessors.Add("PathShearY", ProcessShpPathShearY);
363 m_ShapeXmlProcessors.Add("PathSkew", ProcessShpPathSkew);
364 m_ShapeXmlProcessors.Add("PathTaperX", ProcessShpPathTaperX);
365 m_ShapeXmlProcessors.Add("PathTaperY", ProcessShpPathTaperY);
366 m_ShapeXmlProcessors.Add("PathTwist", ProcessShpPathTwist);
367 m_ShapeXmlProcessors.Add("PathTwistBegin", ProcessShpPathTwistBegin);
368 m_ShapeXmlProcessors.Add("PCode", ProcessShpPCode);
369 m_ShapeXmlProcessors.Add("ProfileBegin", ProcessShpProfileBegin);
370 m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd);
371 m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow);
372 m_ShapeXmlProcessors.Add("Scale", ProcessShpScale);
373 m_ShapeXmlProcessors.Add("State", ProcessShpState);
374 m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape);
375 m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape);
376 m_ShapeXmlProcessors.Add("SculptTexture", ProcessShpSculptTexture);
377 m_ShapeXmlProcessors.Add("SculptType", ProcessShpSculptType);
378 m_ShapeXmlProcessors.Add("SculptData", ProcessShpSculptData);
379 m_ShapeXmlProcessors.Add("FlexiSoftness", ProcessShpFlexiSoftness);
380 m_ShapeXmlProcessors.Add("FlexiTension", ProcessShpFlexiTension);
381 m_ShapeXmlProcessors.Add("FlexiDrag", ProcessShpFlexiDrag);
382 m_ShapeXmlProcessors.Add("FlexiGravity", ProcessShpFlexiGravity);
383 m_ShapeXmlProcessors.Add("FlexiWind", ProcessShpFlexiWind);
384 m_ShapeXmlProcessors.Add("FlexiForceX", ProcessShpFlexiForceX);
385 m_ShapeXmlProcessors.Add("FlexiForceY", ProcessShpFlexiForceY);
386 m_ShapeXmlProcessors.Add("FlexiForceZ", ProcessShpFlexiForceZ);
387 m_ShapeXmlProcessors.Add("LightColorR", ProcessShpLightColorR);
388 m_ShapeXmlProcessors.Add("LightColorG", ProcessShpLightColorG);
389 m_ShapeXmlProcessors.Add("LightColorB", ProcessShpLightColorB);
390 m_ShapeXmlProcessors.Add("LightColorA", ProcessShpLightColorA);
391 m_ShapeXmlProcessors.Add("LightRadius", ProcessShpLightRadius);
392 m_ShapeXmlProcessors.Add("LightCutoff", ProcessShpLightCutoff);
393 m_ShapeXmlProcessors.Add("LightFalloff", ProcessShpLightFalloff);
394 m_ShapeXmlProcessors.Add("LightIntensity", ProcessShpLightIntensity);
395 m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry);
396 m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry);
397 m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry);
398 m_ShapeXmlProcessors.Add("Media", ProcessShpMedia);
399 #endregion
400 }
401
402 #region SOPXmlProcessors
403 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader)
404 {
405 obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty);
406 }
407
408 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
409 {
410 obj.CreatorID = ReadUUID(reader, "CreatorID");
411 }
412
413 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader)
414 {
415 obj.FolderID = ReadUUID(reader, "FolderID");
416 }
417
418 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader)
419 {
420 obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty);
421 }
422
423 private static void ProcessTaskInventory(SceneObjectPart obj, XmlTextReader reader)
424 {
425 obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory");
426 }
427
428 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader)
429 {
430 obj.UUID = ReadUUID(reader, "UUID");
431 }
432
433 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader)
434 {
435 obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
436 }
437
438 private static void ProcessName(SceneObjectPart obj, XmlTextReader reader)
439 {
440 obj.Name = reader.ReadElementString("Name");
441 }
442
443 private static void ProcessMaterial(SceneObjectPart obj, XmlTextReader reader)
444 {
445 obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty);
446 }
447
448 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
449 {
450 obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
451 }
452
453 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader)
454 {
455 obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty);
456 }
457
458 private static void ProcessScriptAccessPin(SceneObjectPart obj, XmlTextReader reader)
459 {
460 obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);
461 }
462
463 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader)
464 {
465 obj.GroupPosition = ReadVector(reader, "GroupPosition");
466 }
467
468 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader)
469 {
470 obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ;
471 }
472
473 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader)
474 {
475 obj.RotationOffset = ReadQuaternion(reader, "RotationOffset");
476 }
477
478 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader)
479 {
480 obj.Velocity = ReadVector(reader, "Velocity");
481 }
482
483 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader)
484 {
485 obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
486 }
487
488 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader)
489 {
490 obj.Acceleration = ReadVector(reader, "Acceleration");
491 }
492
493 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader)
494 {
495 obj.Description = reader.ReadElementString("Description");
496 }
497
498 private static void ProcessColor(SceneObjectPart obj, XmlTextReader reader)
499 {
500 reader.ReadStartElement("Color");
501 if (reader.Name == "R")
502 {
503 float r = reader.ReadElementContentAsFloat("R", String.Empty);
504 float g = reader.ReadElementContentAsFloat("G", String.Empty);
505 float b = reader.ReadElementContentAsFloat("B", String.Empty);
506 float a = reader.ReadElementContentAsFloat("A", String.Empty);
507 obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b);
508 reader.ReadEndElement();
509 }
510 }
511
512 private static void ProcessText(SceneObjectPart obj, XmlTextReader reader)
513 {
514 obj.Text = reader.ReadElementString("Text", String.Empty);
515 }
516
517 private static void ProcessSitName(SceneObjectPart obj, XmlTextReader reader)
518 {
519 obj.SitName = reader.ReadElementString("SitName", String.Empty);
520 }
521
522 private static void ProcessTouchName(SceneObjectPart obj, XmlTextReader reader)
523 {
524 obj.TouchName = reader.ReadElementString("TouchName", String.Empty);
525 }
526
527 private static void ProcessLinkNum(SceneObjectPart obj, XmlTextReader reader)
528 {
529 obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty);
530 }
531
532 private static void ProcessClickAction(SceneObjectPart obj, XmlTextReader reader)
533 {
534 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
535 }
536
537 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
538 {
539 obj.Shape = ReadShape(reader, "Shape");
540 }
541
542 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
543 {
544 obj.Scale = ReadVector(reader, "Scale");
545 }
546
547 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader)
548 {
549 obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty);
550 }
551
552 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader)
553 {
554 obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation");
555 }
556
557 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader)
558 {
559 obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition");
560 }
561
562 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader)
563 {
564 obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL");
565 }
566
567 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader)
568 {
569 obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL");
570 }
571
572 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader)
573 {
574 string str = reader.ReadElementContentAsString("ParentID", String.Empty);
575 obj.ParentID = Convert.ToUInt32(str);
576 }
577
578 private static void ProcessCreationDate(SceneObjectPart obj, XmlTextReader reader)
579 {
580 obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
581 }
582
583 private static void ProcessCategory(SceneObjectPart obj, XmlTextReader reader)
584 {
585 obj.Category = (uint)reader.ReadElementContentAsInt("Category", String.Empty);
586 }
587
588 private static void ProcessSalePrice(SceneObjectPart obj, XmlTextReader reader)
589 {
590 obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
591 }
592
593 private static void ProcessObjectSaleType(SceneObjectPart obj, XmlTextReader reader)
594 {
595 obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
596 }
597
598 private static void ProcessOwnershipCost(SceneObjectPart obj, XmlTextReader reader)
599 {
600 obj.OwnershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
601 }
602
603 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader)
604 {
605 obj.GroupID = ReadUUID(reader, "GroupID");
606 }
607
608 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader)
609 {
610 obj.OwnerID = ReadUUID(reader, "OwnerID");
611 }
612
613 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader)
614 {
615 obj.LastOwnerID = ReadUUID(reader, "LastOwnerID");
616 }
617
618 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader)
619 {
620 obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
621 }
622
623 private static void ProcessOwnerMask(SceneObjectPart obj, XmlTextReader reader)
624 {
625 obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
626 }
627
628 private static void ProcessGroupMask(SceneObjectPart obj, XmlTextReader reader)
629 {
630 obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
631 }
632
633 private static void ProcessEveryoneMask(SceneObjectPart obj, XmlTextReader reader)
634 {
635 obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
636 }
637
638 private static void ProcessNextOwnerMask(SceneObjectPart obj, XmlTextReader reader)
639 {
640 obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);
641 }
642
643 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader)
644 {
645 string value = reader.ReadElementContentAsString("Flags", String.Empty);
646 // !!!!! to deal with flags without commas
647 if (value.Contains(" ") && !value.Contains(","))
648 value = value.Replace(" ", ", ");
649 obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value);
650 }
651
652 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
653 {
654 obj.CollisionSound = ReadUUID(reader, "CollisionSound");
655 }
656
657 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
658 {
659 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
660 }
661
662 private static void ProcessMediaUrl(SceneObjectPart obj, XmlTextReader reader)
663 {
664 obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty);
665 }
666 #endregion
667
668 #region TaskInventoryXmlProcessors
669 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader)
670 {
671 item.AssetID = ReadUUID(reader, "AssetID");
672 }
673
674 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader)
675 {
676 item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
677 }
678
679 private static void ProcessTICreationDate(TaskInventoryItem item, XmlTextReader reader)
680 {
681 item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty);
682 }
683
684 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader)
685 {
686 item.CreatorID = ReadUUID(reader, "CreatorID");
687 }
688
689 private static void ProcessTIDescription(TaskInventoryItem item, XmlTextReader reader)
690 {
691 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
692 }
693
694 private static void ProcessTIEveryonePermissions(TaskInventoryItem item, XmlTextReader reader)
695 {
696 item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty);
697 }
698
699 private static void ProcessTIFlags(TaskInventoryItem item, XmlTextReader reader)
700 {
701 item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
702 }
703
704 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader)
705 {
706 item.GroupID = ReadUUID(reader, "GroupID");
707 }
708
709 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader)
710 {
711 item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty);
712 }
713
714 private static void ProcessTIInvType(TaskInventoryItem item, XmlTextReader reader)
715 {
716 item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
717 }
718
719 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader)
720 {
721 item.ItemID = ReadUUID(reader, "ItemID");
722 }
723
724 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
725 {
726 item.OldItemID = ReadUUID(reader, "OldItemID");
727 }
728
729 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
730 {
731 item.LastOwnerID = ReadUUID(reader, "LastOwnerID");
732 }
733
734 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader)
735 {
736 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
737 }
738
739 private static void ProcessTINextPermissions(TaskInventoryItem item, XmlTextReader reader)
740 {
741 item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
742 }
743
744 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader)
745 {
746 item.OwnerID = ReadUUID(reader, "OwnerID");
747 }
748
749 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader)
750 {
751 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
752 }
753
754 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader)
755 {
756 item.ParentID = ReadUUID(reader, "ParentID");
757 }
758
759 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader)
760 {
761 item.ParentPartID = ReadUUID(reader, "ParentPartID");
762 }
763
764 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader)
765 {
766 item.PermsGranter = ReadUUID(reader, "PermsGranter");
767 }
768
769 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader)
770 {
771 item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty);
772 }
773
774 private static void ProcessTIType(TaskInventoryItem item, XmlTextReader reader)
775 {
776 item.Type = reader.ReadElementContentAsInt("Type", String.Empty);
777 }
778
779 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader)
780 {
781 item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty);
782 }
783
784 #endregion
785
786 #region ShapeXmlProcessors
787 private static void ProcessShpProfileCurve(PrimitiveBaseShape shp, XmlTextReader reader)
788 {
789 shp.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
790 }
791
792 private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlTextReader reader)
793 {
794 byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
795 shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
796 }
797
798 private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlTextReader reader)
799 {
800 shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString("ExtraParams"));
801 }
802
803 private static void ProcessShpPathBegin(PrimitiveBaseShape shp, XmlTextReader reader)
804 {
805 shp.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty);
806 }
807
808 private static void ProcessShpPathCurve(PrimitiveBaseShape shp, XmlTextReader reader)
809 {
810 shp.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty);
811 }
812
813 private static void ProcessShpPathEnd(PrimitiveBaseShape shp, XmlTextReader reader)
814 {
815 shp.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty);
816 }
278 817
818 private static void ProcessShpPathRadiusOffset(PrimitiveBaseShape shp, XmlTextReader reader)
819 {
820 shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty);
821 }
822
823 private static void ProcessShpPathRevolutions(PrimitiveBaseShape shp, XmlTextReader reader)
824 {
825 shp.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty);
826 }
827
828 private static void ProcessShpPathScaleX(PrimitiveBaseShape shp, XmlTextReader reader)
829 {
830 shp.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty);
831 }
832
833 private static void ProcessShpPathScaleY(PrimitiveBaseShape shp, XmlTextReader reader)
834 {
835 shp.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty);
836 }
837
838 private static void ProcessShpPathShearX(PrimitiveBaseShape shp, XmlTextReader reader)
839 {
840 shp.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty);
841 }
842
843 private static void ProcessShpPathShearY(PrimitiveBaseShape shp, XmlTextReader reader)
844 {
845 shp.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty);
846 }
847
848 private static void ProcessShpPathSkew(PrimitiveBaseShape shp, XmlTextReader reader)
849 {
850 shp.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty);
851 }
852
853 private static void ProcessShpPathTaperX(PrimitiveBaseShape shp, XmlTextReader reader)
854 {
855 shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty);
856 }
857
858 private static void ProcessShpPathTaperY(PrimitiveBaseShape shp, XmlTextReader reader)
859 {
860 shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty);
861 }
862
863 private static void ProcessShpPathTwist(PrimitiveBaseShape shp, XmlTextReader reader)
864 {
865 shp.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty);
866 }
867
868 private static void ProcessShpPathTwistBegin(PrimitiveBaseShape shp, XmlTextReader reader)
869 {
870 shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty);
871 }
872
873 private static void ProcessShpPCode(PrimitiveBaseShape shp, XmlTextReader reader)
874 {
875 shp.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty);
876 }
877
878 private static void ProcessShpProfileBegin(PrimitiveBaseShape shp, XmlTextReader reader)
879 {
880 shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty);
881 }
882
883 private static void ProcessShpProfileEnd(PrimitiveBaseShape shp, XmlTextReader reader)
884 {
885 shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty);
886 }
887
888 private static void ProcessShpProfileHollow(PrimitiveBaseShape shp, XmlTextReader reader)
889 {
890 shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty);
891 }
892
893 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader)
894 {
895 shp.Scale = ReadVector(reader, "Scale");
896 }
897
898 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader)
899 {
900 shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);
901 }
902
903 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader)
904 {
905 string value = reader.ReadElementContentAsString("ProfileShape", String.Empty);
906 // !!!!! to deal with flags without commas
907 if (value.Contains(" ") && !value.Contains(","))
908 value = value.Replace(" ", ", ");
909 shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value);
910 }
911
912 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader)
913 {
914 string value = reader.ReadElementContentAsString("HollowShape", String.Empty);
915 // !!!!! to deal with flags without commas
916 if (value.Contains(" ") && !value.Contains(","))
917 value = value.Replace(" ", ", ");
918 shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value);
919 }
920
921 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
922 {
923 shp.SculptTexture = ReadUUID(reader, "SculptTexture");
924 }
925
926 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader)
927 {
928 shp.SculptType = (byte)reader.ReadElementContentAsInt("SculptType", String.Empty);
929 }
930
931 private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader)
932 {
933 shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData"));
934 }
935
936 private static void ProcessShpFlexiSoftness(PrimitiveBaseShape shp, XmlTextReader reader)
937 {
938 shp.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
939 }
940
941 private static void ProcessShpFlexiTension(PrimitiveBaseShape shp, XmlTextReader reader)
942 {
943 shp.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
944 }
945
946 private static void ProcessShpFlexiDrag(PrimitiveBaseShape shp, XmlTextReader reader)
947 {
948 shp.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
949 }
950
951 private static void ProcessShpFlexiGravity(PrimitiveBaseShape shp, XmlTextReader reader)
952 {
953 shp.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
954 }
955
956 private static void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlTextReader reader)
957 {
958 shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
959 }
960
961 private static void ProcessShpFlexiForceX(PrimitiveBaseShape shp, XmlTextReader reader)
962 {
963 shp.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
964 }
965
966 private static void ProcessShpFlexiForceY(PrimitiveBaseShape shp, XmlTextReader reader)
967 {
968 shp.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
969 }
970
971 private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlTextReader reader)
972 {
973 shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);
974 }
975
976 private static void ProcessShpLightColorR(PrimitiveBaseShape shp, XmlTextReader reader)
977 {
978 shp.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
979 }
980
981 private static void ProcessShpLightColorG(PrimitiveBaseShape shp, XmlTextReader reader)
982 {
983 shp.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
984 }
985
986 private static void ProcessShpLightColorB(PrimitiveBaseShape shp, XmlTextReader reader)
987 {
988 shp.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
989 }
990
991 private static void ProcessShpLightColorA(PrimitiveBaseShape shp, XmlTextReader reader)
992 {
993 shp.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
994 }
995
996 private static void ProcessShpLightRadius(PrimitiveBaseShape shp, XmlTextReader reader)
997 {
998 shp.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
999 }
1000
1001 private static void ProcessShpLightCutoff(PrimitiveBaseShape shp, XmlTextReader reader)
1002 {
1003 shp.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
1004 }
1005
1006 private static void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader)
1007 {
1008 shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
1009 }
1010
1011 private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader)
1012 {
1013 shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
1014 }
1015
1016 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1017 {
1018 shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
1019 }
1020
1021 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1022 {
1023 shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
1024 }
1025
1026 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1027 {
1028 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
1029 }
1030
1031 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
1032 {
1033 string value = reader.ReadElementContentAsString("Media", String.Empty);
1034 shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
1035 }
1036
1037
1038 #endregion
1039
1040 ////////// Write /////////
1041
1042 public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options)
1043 {
279 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 1044 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
280 sceneObject.RootPart.ToXml(writer); 1045 SOPToXml2(writer, sog.RootPart, options);
281 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); 1046 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
282 1047
283 SceneObjectPart[] parts = sceneObject.Parts; 1048 sog.ForEachPart(delegate(SceneObjectPart sop)
284 for (int i = 0; i < parts.Length; i++)
285 { 1049 {
286 SceneObjectPart part = parts[i]; 1050 if (sop.UUID != sog.RootPart.UUID)
287 if (part.UUID != sceneObject.RootPart.UUID) 1051 SOPToXml2(writer, sop, options);
288 part.ToXml(writer); 1052 });
1053
1054 writer.WriteEndElement();
1055 writer.WriteEndElement();
1056 }
1057
1058 public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary<string, object> options)
1059 {
1060 writer.WriteStartElement("SceneObjectPart");
1061 writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1062 writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
1063
1064 writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower());
1065 WriteUUID(writer, "CreatorID", sop.CreatorID, options);
1066 WriteUUID(writer, "FolderID", sop.FolderID, options);
1067 writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString());
1068
1069 WriteTaskInventory(writer, sop.TaskInventory, options);
1070
1071 WriteUUID(writer, "UUID", sop.UUID, options);
1072 writer.WriteElementString("LocalId", sop.LocalId.ToString());
1073 writer.WriteElementString("Name", sop.Name);
1074 writer.WriteElementString("Material", sop.Material.ToString());
1075 writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower());
1076 writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString());
1077 writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString());
1078
1079 WriteVector(writer, "GroupPosition", sop.GroupPosition);
1080 WriteVector(writer, "OffsetPosition", sop.OffsetPosition);
1081
1082 WriteQuaternion(writer, "RotationOffset", sop.RotationOffset);
1083 WriteVector(writer, "Velocity", sop.Velocity);
1084 WriteVector(writer, "AngularVelocity", sop.AngularVelocity);
1085 WriteVector(writer, "Acceleration", sop.Acceleration);
1086 writer.WriteElementString("Description", sop.Description);
1087 if (sop.Color != null)
1088 {
1089 writer.WriteStartElement("Color");
1090 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture));
1091 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture));
1092 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture));
1093 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture));
1094 writer.WriteEndElement();
289 } 1095 }
290 1096
291 writer.WriteEndElement(); // End of OtherParts 1097 writer.WriteElementString("Text", sop.Text);
292 sceneObject.SaveScriptedState(writer); 1098 writer.WriteElementString("SitName", sop.SitName);
293 writer.WriteEndElement(); // End of SceneObjectGroup 1099 writer.WriteElementString("TouchName", sop.TouchName);
294 1100
295 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); 1101 writer.WriteElementString("LinkNum", sop.LinkNum.ToString());
1102 writer.WriteElementString("ClickAction", sop.ClickAction.ToString());
1103
1104 WriteShape(writer, sop.Shape, options);
1105
1106 WriteVector(writer, "Scale", sop.Scale);
1107 writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString());
1108 WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation);
1109 WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition);
1110 WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL);
1111 WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL);
1112 writer.WriteElementString("ParentID", sop.ParentID.ToString());
1113 writer.WriteElementString("CreationDate", sop.CreationDate.ToString());
1114 writer.WriteElementString("Category", sop.Category.ToString());
1115 writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
1116 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1117 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1118 WriteUUID(writer, "GroupID", sop.GroupID, options);
1119 WriteUUID(writer, "OwnerID", sop.OwnerID, options);
1120 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options);
1121 writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
1122 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
1123 writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
1124 writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString());
1125 writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString());
1126 writer.WriteElementString("Flags", sop.Flags.ToString());
1127 WriteUUID(writer, "CollisionSound", sop.CollisionSound, options);
1128 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
1129 if (sop.MediaUrl != null)
1130 writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
1131
1132 writer.WriteEndElement();
1133 }
1134
1135 static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary<string, object> options)
1136 {
1137 writer.WriteStartElement(name);
1138 if (options.ContainsKey("old-guids"))
1139 writer.WriteElementString("Guid", id.ToString());
1140 else
1141 writer.WriteElementString("UUID", id.ToString());
1142 writer.WriteEndElement();
1143 }
1144
1145 static void WriteVector(XmlTextWriter writer, string name, Vector3 vec)
1146 {
1147 writer.WriteStartElement(name);
1148 writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture));
1149 writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture));
1150 writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture));
1151 writer.WriteEndElement();
1152 }
1153
1154 static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat)
1155 {
1156 writer.WriteStartElement(name);
1157 writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture));
1158 writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture));
1159 writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture));
1160 writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture));
1161 writer.WriteEndElement();
296 } 1162 }
1163
1164 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options)
1165 {
1166 if (tinv.Count > 0) // otherwise skip this
1167 {
1168 writer.WriteStartElement("TaskInventory");
1169
1170 foreach (TaskInventoryItem item in tinv.Values)
1171 {
1172 writer.WriteStartElement("TaskInventoryItem");
1173
1174 WriteUUID(writer, "AssetID", item.AssetID, options);
1175 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
1176 writer.WriteElementString("CreationDate", item.CreationDate.ToString());
1177 WriteUUID(writer, "CreatorID", item.CreatorID, options);
1178 writer.WriteElementString("Description", item.Description);
1179 writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
1180 writer.WriteElementString("Flags", item.Flags.ToString());
1181 WriteUUID(writer, "GroupID", item.GroupID, options);
1182 writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
1183 writer.WriteElementString("InvType", item.InvType.ToString());
1184 WriteUUID(writer, "ItemID", item.ItemID, options);
1185 WriteUUID(writer, "OldItemID", item.OldItemID, options);
1186 WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options);
1187 writer.WriteElementString("Name", item.Name);
1188 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
1189 WriteUUID(writer, "OwnerID", item.OwnerID, options);
1190 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
1191 WriteUUID(writer, "ParentID", item.ParentID, options);
1192 WriteUUID(writer, "ParentPartID", item.ParentPartID, options);
1193 WriteUUID(writer, "PermsGranter", item.PermsGranter, options);
1194 writer.WriteElementString("PermsMask", item.PermsMask.ToString());
1195 writer.WriteElementString("Type", item.Type.ToString());
1196 writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower());
1197
1198 writer.WriteEndElement(); // TaskInventoryItem
1199 }
1200
1201 writer.WriteEndElement(); // TaskInventory
1202 }
1203 }
1204
1205 static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
1206 {
1207 if (shp != null)
1208 {
1209 writer.WriteStartElement("Shape");
1210
1211 writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString());
1212
1213 writer.WriteStartElement("TextureEntry");
1214 byte[] te;
1215 if (shp.TextureEntry != null)
1216 te = shp.TextureEntry;
1217 else
1218 te = Utils.EmptyBytes;
1219 writer.WriteBase64(te, 0, te.Length);
1220 writer.WriteEndElement(); // TextureEntry
1221
1222 writer.WriteStartElement("ExtraParams");
1223 byte[] ep;
1224 if (shp.ExtraParams != null)
1225 ep = shp.ExtraParams;
1226 else
1227 ep = Utils.EmptyBytes;
1228 writer.WriteBase64(ep, 0, ep.Length);
1229 writer.WriteEndElement(); // ExtraParams
1230
1231 writer.WriteElementString("PathBegin", shp.PathBegin.ToString());
1232 writer.WriteElementString("PathCurve", shp.PathCurve.ToString());
1233 writer.WriteElementString("PathEnd", shp.PathEnd.ToString());
1234 writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString());
1235 writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString());
1236 writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString());
1237 writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString());
1238 writer.WriteElementString("PathShearX", shp.PathShearX.ToString());
1239 writer.WriteElementString("PathShearY", shp.PathShearY.ToString());
1240 writer.WriteElementString("PathSkew", shp.PathSkew.ToString());
1241 writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString());
1242 writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString());
1243 writer.WriteElementString("PathTwist", shp.PathTwist.ToString());
1244 writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString());
1245 writer.WriteElementString("PCode", shp.PCode.ToString());
1246 writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString());
1247 writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString());
1248 writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString());
1249 writer.WriteElementString("State", shp.State.ToString());
1250
1251 writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString());
1252 writer.WriteElementString("HollowShape", shp.HollowShape.ToString());
1253
1254 WriteUUID(writer, "SculptTexture", shp.SculptTexture, options);
1255 writer.WriteElementString("SculptType", shp.SculptType.ToString());
1256 writer.WriteStartElement("SculptData");
1257 byte[] sd;
1258 if (shp.SculptData != null)
1259 sd = shp.ExtraParams;
1260 else
1261 sd = Utils.EmptyBytes;
1262 writer.WriteBase64(sd, 0, sd.Length);
1263 writer.WriteEndElement(); // SculptData
1264
1265 writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString());
1266 writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString());
1267 writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString());
1268 writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString());
1269 writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString());
1270 writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString());
1271 writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString());
1272 writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString());
1273
1274 writer.WriteElementString("LightColorR", shp.LightColorR.ToString());
1275 writer.WriteElementString("LightColorG", shp.LightColorG.ToString());
1276 writer.WriteElementString("LightColorB", shp.LightColorB.ToString());
1277 writer.WriteElementString("LightColorA", shp.LightColorA.ToString());
1278 writer.WriteElementString("LightRadius", shp.LightRadius.ToString());
1279 writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString());
1280 writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString());
1281 writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString());
1282
1283 writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower());
1284 writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower());
1285 writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower());
1286
1287 if (shp.Media != null)
1288 writer.WriteElementString("Media", shp.Media.ToXml());
1289
1290 writer.WriteEndElement(); // Shape
1291 }
1292 }
1293
1294 //////// Read /////////
1295 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
1296 {
1297 reader.Read();
1298 reader.ReadStartElement("SceneObjectGroup");
1299 SceneObjectPart root = Xml2ToSOP(reader);
1300 if (root != null)
1301 sog.SetRootPart(root);
1302 else
1303 {
1304 return false;
1305 }
1306
1307 if (sog.UUID == UUID.Zero)
1308 sog.UUID = sog.RootPart.UUID;
1309
1310 reader.Read(); // OtherParts
1311
1312 while (!reader.EOF)
1313 {
1314 switch (reader.NodeType)
1315 {
1316 case XmlNodeType.Element:
1317 if (reader.Name == "SceneObjectPart")
1318 {
1319 SceneObjectPart child = Xml2ToSOP(reader);
1320 if (child != null)
1321 sog.AddPart(child);
1322 }
1323 else
1324 {
1325 //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
1326 reader.Read();
1327 }
1328 break;
1329 case XmlNodeType.EndElement:
1330 default:
1331 reader.Read();
1332 break;
1333 }
1334
1335 }
1336 return true;
1337 }
1338
1339 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1340 {
1341 SceneObjectPart obj = new SceneObjectPart();
1342
1343 reader.ReadStartElement("SceneObjectPart");
1344
1345 string nodeName = string.Empty;
1346 while (reader.NodeType != XmlNodeType.EndElement)
1347 {
1348 nodeName = reader.Name;
1349 SOPXmlProcessor p = null;
1350 if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p))
1351 {
1352 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1353 try
1354 {
1355 p(obj, reader);
1356 }
1357 catch (Exception e)
1358 {
1359 m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0}: {1}", nodeName, e);
1360 if (reader.NodeType == XmlNodeType.EndElement)
1361 reader.Read();
1362 }
1363 }
1364 else
1365 {
1366 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName);
1367 reader.ReadOuterXml(); // ignore
1368 }
1369
1370 }
1371
1372 reader.ReadEndElement(); // SceneObjectPart
1373
1374 //m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID);
1375 return obj;
1376 }
1377
1378 static UUID ReadUUID(XmlTextReader reader, string name)
1379 {
1380 UUID id;
1381 string idStr;
1382
1383 reader.ReadStartElement(name);
1384
1385 if (reader.Name == "Guid")
1386 idStr = reader.ReadElementString("Guid");
1387 else // UUID
1388 idStr = reader.ReadElementString("UUID");
1389
1390 UUID.TryParse(idStr, out id);
1391 reader.ReadEndElement();
1392
1393 return id;
1394 }
1395
1396 static Vector3 ReadVector(XmlTextReader reader, string name)
1397 {
1398 Vector3 vec;
1399
1400 reader.ReadStartElement(name);
1401 vec.X = reader.ReadElementContentAsFloat("X", String.Empty);
1402 vec.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
1403 vec.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
1404 reader.ReadEndElement();
1405
1406 return vec;
1407 }
1408
1409 static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1410 {
1411 Quaternion quat;
1412
1413 reader.ReadStartElement(name);
1414 quat.X = reader.ReadElementContentAsFloat("X", String.Empty);
1415 quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
1416 quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
1417 quat.W = reader.ReadElementContentAsFloat("W", String.Empty);
1418 reader.ReadEndElement();
1419
1420 return quat;
1421 }
1422
1423 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
1424 {
1425 TaskInventoryDictionary tinv = new TaskInventoryDictionary();
1426
1427 reader.ReadStartElement(name, String.Empty);
1428
1429 while (reader.Name == "TaskInventoryItem")
1430 {
1431 reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory
1432
1433 TaskInventoryItem item = new TaskInventoryItem();
1434 while (reader.NodeType != XmlNodeType.EndElement)
1435 {
1436 TaskInventoryXmlProcessor p = null;
1437 if (m_TaskInventoryXmlProcessors.TryGetValue(reader.Name, out p))
1438 p(item, reader);
1439 else
1440 {
1441 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value);
1442 reader.ReadOuterXml();
1443 }
1444 }
1445 reader.ReadEndElement(); // TaskInventoryItem
1446 tinv.Add(item.ItemID, item);
1447
1448 }
1449
1450 if (reader.NodeType == XmlNodeType.EndElement)
1451 reader.ReadEndElement(); // TaskInventory
1452
1453 return tinv;
1454 }
1455
1456 static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
1457 {
1458 PrimitiveBaseShape shape = new PrimitiveBaseShape();
1459
1460 reader.ReadStartElement(name, String.Empty); // Shape
1461
1462 while (reader.NodeType != XmlNodeType.EndElement)
1463 {
1464 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1465 ShapeXmlProcessor p = null;
1466 if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p))
1467 p(shape, reader);
1468 else
1469 {
1470 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name);
1471 reader.ReadOuterXml();
1472 }
1473 }
1474
1475 reader.ReadEndElement(); // Shape
1476
1477 return shape;
1478 }
1479
1480 #endregion
297 } 1481 }
298} 1482}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index 5494549..d214eba 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 #region old xml format
48 public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) 49 public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
49 { 50 {
50 XmlDocument doc = new XmlDocument(); 51 XmlDocument doc = new XmlDocument();
@@ -98,11 +99,128 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
98 file.Close(); 99 file.Close();
99 } 100 }
100 101
101 public static string SaveGroupToXml2(SceneObjectGroup grp) 102 #endregion
103
104 #region XML2 serialization
105
106 // Called by archives (save oar)
107 public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
108 {
109 //return SceneObjectSerializer.ToXml2Format(grp);
110 using (MemoryStream mem = new MemoryStream())
111 {
112 using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8))
113 {
114 SceneObjectSerializer.SOGToXml2(writer, grp, options);
115 writer.Flush();
116
117 using (StreamReader reader = new StreamReader(mem))
118 {
119 mem.Seek(0, SeekOrigin.Begin);
120 return reader.ReadToEnd();
121 }
122 }
123 }
124 }
125
126 // Called by scene serializer (save xml2)
127 public static void SavePrimsToXml2(Scene scene, string fileName)
128 {
129 EntityBase[] entityList = scene.GetEntities();
130 SavePrimListToXml2(entityList, fileName);
131 }
132
133 // Called by scene serializer (save xml2)
134 public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
135 {
136 m_log.InfoFormat(
137 "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
138 primName, scene.RegionInfo.RegionName, fileName);
139
140 EntityBase[] entityList = scene.GetEntities();
141 List<EntityBase> primList = new List<EntityBase>();
142
143 foreach (EntityBase ent in entityList)
144 {
145 if (ent is SceneObjectGroup)
146 {
147 if (ent.Name == primName)
148 {
149 primList.Add(ent);
150 }
151 }
152 }
153
154 SavePrimListToXml2(primList.ToArray(), fileName);
155 }
156
157 // Called by REST Application plugin
158 public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
102 { 159 {
103 return SceneObjectSerializer.ToXml2Format(grp); 160 EntityBase[] entityList = scene.GetEntities();
161 SavePrimListToXml2(entityList, stream, min, max);
104 } 162 }
105 163
164 // Called here only. Should be private?
165 public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
166 {
167 FileStream file = new FileStream(fileName, FileMode.Create);
168 try
169 {
170 StreamWriter stream = new StreamWriter(file);
171 try
172 {
173 SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
174 }
175 finally
176 {
177 stream.Close();
178 }
179 }
180 finally
181 {
182 file.Close();
183 }
184 }
185
186 // Called here only. Should be private?
187 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
188 {
189 XmlTextWriter writer = new XmlTextWriter(stream);
190
191 int primCount = 0;
192 stream.WriteLine("<scene>\n");
193
194 foreach (EntityBase ent in entityList)
195 {
196 if (ent is SceneObjectGroup)
197 {
198 SceneObjectGroup g = (SceneObjectGroup)ent;
199 if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
200 {
201 Vector3 pos = g.RootPart.GetWorldPosition();
202 if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
203 continue;
204 if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
205 continue;
206 }
207
208 //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
209 SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary<string,object>());
210 stream.WriteLine();
211
212 primCount++;
213 }
214 }
215
216 stream.WriteLine("</scene>\n");
217 stream.Flush();
218 }
219
220 #endregion
221
222 #region XML2 deserialization
223
106 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) 224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
107 { 225 {
108 XmlDocument doc = new XmlDocument(); 226 XmlDocument doc = new XmlDocument();
@@ -124,14 +242,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
124 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 242 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
125 { 243 {
126 // There is only ever one prim. This oddity should be removeable post 0.5.9 244 // There is only ever one prim. This oddity should be removeable post 0.5.9
127 return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); 245 //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
246 using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
247 {
248 SceneObjectGroup obj = new SceneObjectGroup();
249 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
250 return obj;
251
252 return null;
253 }
128 } 254 }
129 255
130 return null; 256 return null;
131 } 257 }
132 else 258 else
133 { 259 {
134 return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); 260 //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
261 using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
262 {
263 SceneObjectGroup obj = new SceneObjectGroup();
264 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
265 return obj;
266
267 return null;
268 }
135 } 269 }
136 } 270 }
137 271
@@ -193,96 +327,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
193 /// <returns>The scene object created. null if the scene object already existed</returns> 327 /// <returns>The scene object created. null if the scene object already existed</returns>
194 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) 328 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
195 { 329 {
196 SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); 330 //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
197 331 using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
198 if (scene.AddRestoredSceneObject(obj, true, false))
199 return obj;
200 else
201 return null;
202 }
203
204 public static void SavePrimsToXml2(Scene scene, string fileName)
205 {
206 EntityBase[] entityList = scene.GetEntities();
207 SavePrimListToXml2(entityList, fileName);
208 }
209
210 public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
211 {
212 EntityBase[] entityList = scene.GetEntities();
213 SavePrimListToXml2(entityList, stream, min, max);
214 }
215
216 public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
217 {
218 m_log.InfoFormat(
219 "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
220 primName, scene.RegionInfo.RegionName, fileName);
221
222 EntityBase[] entityList = scene.GetEntities();
223 List<EntityBase> primList = new List<EntityBase>();
224
225 foreach (EntityBase ent in entityList)
226 {
227 if (ent is SceneObjectGroup)
228 {
229 if (ent.Name == primName)
230 {
231 primList.Add(ent);
232 }
233 }
234 }
235
236 SavePrimListToXml2(primList.ToArray(), fileName);
237 }
238
239 public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
240 {
241 FileStream file = new FileStream(fileName, FileMode.Create);
242 try
243 { 332 {
244 StreamWriter stream = new StreamWriter(file); 333 SceneObjectGroup obj = new SceneObjectGroup();
245 try 334 SceneObjectSerializer.Xml2ToSOG(reader, obj);
246 {
247 SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
248 }
249 finally
250 {
251 stream.Close();
252 }
253 }
254 finally
255 {
256 file.Close();
257 }
258 }
259 335
260 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) 336 if (scene.AddRestoredSceneObject(obj, true, false))
261 { 337 return obj;
262 int primCount = 0; 338 else
263 stream.WriteLine("<scene>\n"); 339 return null;
264
265 foreach (EntityBase ent in entityList)
266 {
267 if (ent is SceneObjectGroup)
268 {
269 SceneObjectGroup g = (SceneObjectGroup)ent;
270 if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
271 {
272 Vector3 pos = g.RootPart.GetWorldPosition();
273 if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
274 continue;
275 if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
276 continue;
277 }
278
279 stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
280 primCount++;
281 }
282 } 340 }
283 stream.WriteLine("</scene>\n");
284 stream.Flush();
285 } 341 }
286 342
343 #endregion
287 } 344 }
288} 345}