diff options
author | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
---|---|---|
committer | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
commit | 4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65 (patch) | |
tree | 79142f2364b658f52b63e3ae688a5521290e2a4f /OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |
parent | * more url / hg cleanup (diff) | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-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/Serialization/SceneObjectSerializer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 1262 |
1 files changed, 1223 insertions, 39 deletions
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Drawing; | ||
29 | using System.IO; | 31 | using System.IO; |
30 | using System.Reflection; | 32 | using System.Reflection; |
31 | using System.Xml; | 33 | using 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 | } |