diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 1353 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | 35 |
2 files changed, 1381 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index f5f6b90..2c6d999 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; |
@@ -294,5 +296,1356 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
294 | 296 | ||
295 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); | 297 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); |
296 | } | 298 | } |
299 | |||
300 | #region manual serialization | ||
301 | |||
302 | private delegate void SOPXmlProcessor(SceneObjectPart sop, XmlTextReader reader); | ||
303 | private static Dictionary<string, SOPXmlProcessor> m_SOPXmlProcessors = new Dictionary<string, SOPXmlProcessor>(); | ||
304 | |||
305 | private delegate void TaskInventoryXmlProcessor(TaskInventoryItem item, XmlTextReader reader); | ||
306 | private static Dictionary<string, TaskInventoryXmlProcessor> m_TaskInventoryXmlProcessors = new Dictionary<string, TaskInventoryXmlProcessor>(); | ||
307 | |||
308 | private delegate void ShapeXmlProcessor(PrimitiveBaseShape shape, XmlTextReader reader); | ||
309 | private static Dictionary<string, ShapeXmlProcessor> m_ShapeXmlProcessors = new Dictionary<string, ShapeXmlProcessor>(); | ||
310 | |||
311 | static SceneObjectSerializer() | ||
312 | { | ||
313 | #region SOPXmlProcessors initialization | ||
314 | m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop); | ||
315 | m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID); | ||
316 | m_SOPXmlProcessors.Add("FolderID", ProcessFolderID); | ||
317 | m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial); | ||
318 | m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory); | ||
319 | m_SOPXmlProcessors.Add("ObjectFlags", ProcessObjectFlags); | ||
320 | m_SOPXmlProcessors.Add("UUID", ProcessUUID); | ||
321 | m_SOPXmlProcessors.Add("LocalId", ProcessLocalId); | ||
322 | m_SOPXmlProcessors.Add("Name", ProcessName); | ||
323 | m_SOPXmlProcessors.Add("Material", ProcessMaterial); | ||
324 | m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches); | ||
325 | m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle); | ||
326 | m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin); | ||
327 | m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition); | ||
328 | m_SOPXmlProcessors.Add("OffsetPosition", ProcessOffsetPosition); | ||
329 | m_SOPXmlProcessors.Add("RotationOffset", ProcessRotationOffset); | ||
330 | m_SOPXmlProcessors.Add("Velocity", ProcessVelocity); | ||
331 | m_SOPXmlProcessors.Add("AngularVelocity", ProcessAngularVelocity); | ||
332 | m_SOPXmlProcessors.Add("Acceleration", ProcessAcceleration); | ||
333 | m_SOPXmlProcessors.Add("Description", ProcessDescription); | ||
334 | m_SOPXmlProcessors.Add("Color", ProcessColor); | ||
335 | m_SOPXmlProcessors.Add("Text", ProcessText); | ||
336 | m_SOPXmlProcessors.Add("SitName", ProcessSitName); | ||
337 | m_SOPXmlProcessors.Add("TouchName", ProcessTouchName); | ||
338 | m_SOPXmlProcessors.Add("LinkNum", ProcessLinkNum); | ||
339 | m_SOPXmlProcessors.Add("ClickAction", ProcessClickAction); | ||
340 | m_SOPXmlProcessors.Add("Shape", ProcessShape); | ||
341 | m_SOPXmlProcessors.Add("Scale", ProcessScale); | ||
342 | m_SOPXmlProcessors.Add("UpdateFlag", ProcessUpdateFlag); | ||
343 | m_SOPXmlProcessors.Add("SitTargetOrientation", ProcessSitTargetOrientation); | ||
344 | m_SOPXmlProcessors.Add("SitTargetPosition", ProcessSitTargetPosition); | ||
345 | m_SOPXmlProcessors.Add("SitTargetPositionLL", ProcessSitTargetPositionLL); | ||
346 | m_SOPXmlProcessors.Add("SitTargetOrientationLL", ProcessSitTargetOrientationLL); | ||
347 | m_SOPXmlProcessors.Add("ParentID", ProcessParentID); | ||
348 | m_SOPXmlProcessors.Add("CreationDate", ProcessCreationDate); | ||
349 | m_SOPXmlProcessors.Add("Category", ProcessCategory); | ||
350 | m_SOPXmlProcessors.Add("SalePrice", ProcessSalePrice); | ||
351 | m_SOPXmlProcessors.Add("ObjectSaleType", ProcessObjectSaleType); | ||
352 | m_SOPXmlProcessors.Add("OwnershipCost", ProcessOwnershipCost); | ||
353 | m_SOPXmlProcessors.Add("GroupID", ProcessGroupID); | ||
354 | m_SOPXmlProcessors.Add("OwnerID", ProcessOwnerID); | ||
355 | m_SOPXmlProcessors.Add("LastOwnerID", ProcessLastOwnerID); | ||
356 | m_SOPXmlProcessors.Add("BaseMask", ProcessBaseMask); | ||
357 | m_SOPXmlProcessors.Add("OwnerMask", ProcessOwnerMask); | ||
358 | m_SOPXmlProcessors.Add("GroupMask", ProcessGroupMask); | ||
359 | m_SOPXmlProcessors.Add("EveryoneMask", ProcessEveryoneMask); | ||
360 | m_SOPXmlProcessors.Add("NextOwnerMask", ProcessNextOwnerMask); | ||
361 | m_SOPXmlProcessors.Add("Flags", ProcessFlags); | ||
362 | m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); | ||
363 | m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); | ||
364 | #endregion | ||
365 | |||
366 | #region TaskInventoryXmlProcessors initialization | ||
367 | m_TaskInventoryXmlProcessors.Add("AssetID", ProcessTIAssetID); | ||
368 | m_TaskInventoryXmlProcessors.Add("BasePermissions", ProcessTIBasePermissions); | ||
369 | m_TaskInventoryXmlProcessors.Add("CreationDate", ProcessTICreationDate); | ||
370 | m_TaskInventoryXmlProcessors.Add("CreatorID", ProcessTICreatorID); | ||
371 | m_TaskInventoryXmlProcessors.Add("Description", ProcessTIDescription); | ||
372 | m_TaskInventoryXmlProcessors.Add("EveryonePermissions", ProcessTIEveryonePermissions); | ||
373 | m_TaskInventoryXmlProcessors.Add("Flags", ProcessTIFlags); | ||
374 | m_TaskInventoryXmlProcessors.Add("GroupID", ProcessTIGroupID); | ||
375 | m_TaskInventoryXmlProcessors.Add("GroupPermissions", ProcessTIGroupPermissions); | ||
376 | m_TaskInventoryXmlProcessors.Add("InvType", ProcessTIInvType); | ||
377 | m_TaskInventoryXmlProcessors.Add("ItemID", ProcessTIItemID); | ||
378 | m_TaskInventoryXmlProcessors.Add("OldItemID", ProcessTIOldItemID); | ||
379 | m_TaskInventoryXmlProcessors.Add("LastOwnerID", ProcessTILastOwnerID); | ||
380 | m_TaskInventoryXmlProcessors.Add("Name", ProcessTIName); | ||
381 | m_TaskInventoryXmlProcessors.Add("NextPermissions", ProcessTINextPermissions); | ||
382 | m_TaskInventoryXmlProcessors.Add("OwnerID", ProcessTIOwnerID); | ||
383 | m_TaskInventoryXmlProcessors.Add("CurrentPermissions", ProcessTICurrentPermissions); | ||
384 | m_TaskInventoryXmlProcessors.Add("ParentID", ProcessTIParentID); | ||
385 | m_TaskInventoryXmlProcessors.Add("ParentPartID", ProcessTIParentPartID); | ||
386 | m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); | ||
387 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | ||
388 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | ||
389 | #endregion | ||
390 | |||
391 | #region ShapeXmlProcessors initialization | ||
392 | m_ShapeXmlProcessors.Add("ProfileCurve", ProcessShpProfileCurve); | ||
393 | m_ShapeXmlProcessors.Add("TextureEntry", ProcessShpTextureEntry); | ||
394 | m_ShapeXmlProcessors.Add("ExtraParams", ProcessShpExtraParams); | ||
395 | m_ShapeXmlProcessors.Add("PathBegin", ProcessShpPathBegin); | ||
396 | m_ShapeXmlProcessors.Add("PathCurve", ProcessShpPathCurve); | ||
397 | m_ShapeXmlProcessors.Add("PathEnd", ProcessShpPathEnd); | ||
398 | m_ShapeXmlProcessors.Add("PathRadiusOffset", ProcessShpPathRadiusOffset); | ||
399 | m_ShapeXmlProcessors.Add("PathRevolutions", ProcessShpPathRevolutions); | ||
400 | m_ShapeXmlProcessors.Add("PathScaleX", ProcessShpPathScaleX); | ||
401 | m_ShapeXmlProcessors.Add("PathScaleY", ProcessShpPathScaleY); | ||
402 | m_ShapeXmlProcessors.Add("PathShearX", ProcessShpPathShearX); | ||
403 | m_ShapeXmlProcessors.Add("PathShearY", ProcessShpPathShearY); | ||
404 | m_ShapeXmlProcessors.Add("PathSkew", ProcessShpPathSkew); | ||
405 | m_ShapeXmlProcessors.Add("PathTaperX", ProcessShpPathTaperX); | ||
406 | m_ShapeXmlProcessors.Add("PathTaperY", ProcessShpPathTaperY); | ||
407 | m_ShapeXmlProcessors.Add("PathTwist", ProcessShpPathTwist); | ||
408 | m_ShapeXmlProcessors.Add("PathTwistBegin", ProcessShpPathTwistBegin); | ||
409 | m_ShapeXmlProcessors.Add("PCode", ProcessShpPCode); | ||
410 | m_ShapeXmlProcessors.Add("ProfileBegin", ProcessShpProfileBegin); | ||
411 | m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd); | ||
412 | m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow); | ||
413 | m_ShapeXmlProcessors.Add("Scale", ProcessShpScale); | ||
414 | m_ShapeXmlProcessors.Add("State", ProcessShpState); | ||
415 | m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape); | ||
416 | m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape); | ||
417 | m_ShapeXmlProcessors.Add("SculptTexture", ProcessShpSculptTexture); | ||
418 | m_ShapeXmlProcessors.Add("SculptType", ProcessShpSculptType); | ||
419 | m_ShapeXmlProcessors.Add("SculptData", ProcessShpSculptData); | ||
420 | m_ShapeXmlProcessors.Add("FlexiSoftness", ProcessShpFlexiSoftness); | ||
421 | m_ShapeXmlProcessors.Add("FlexiTension", ProcessShpFlexiTension); | ||
422 | m_ShapeXmlProcessors.Add("FlexiDrag", ProcessShpFlexiDrag); | ||
423 | m_ShapeXmlProcessors.Add("FlexiGravity", ProcessShpFlexiGravity); | ||
424 | m_ShapeXmlProcessors.Add("FlexiWind", ProcessShpFlexiWind); | ||
425 | m_ShapeXmlProcessors.Add("FlexiForceX", ProcessShpFlexiForceX); | ||
426 | m_ShapeXmlProcessors.Add("FlexiForceY", ProcessShpFlexiForceY); | ||
427 | m_ShapeXmlProcessors.Add("FlexiForceZ", ProcessShpFlexiForceZ); | ||
428 | m_ShapeXmlProcessors.Add("LightColorR", ProcessShpLightColorR); | ||
429 | m_ShapeXmlProcessors.Add("LightColorG", ProcessShpLightColorG); | ||
430 | m_ShapeXmlProcessors.Add("LightColorB", ProcessShpLightColorB); | ||
431 | m_ShapeXmlProcessors.Add("LightColorA", ProcessShpLightColorA); | ||
432 | m_ShapeXmlProcessors.Add("LightRadius", ProcessShpLightRadius); | ||
433 | m_ShapeXmlProcessors.Add("LightCutoff", ProcessShpLightCutoff); | ||
434 | m_ShapeXmlProcessors.Add("LightFalloff", ProcessShpLightFalloff); | ||
435 | m_ShapeXmlProcessors.Add("LightIntensity", ProcessShpLightIntensity); | ||
436 | m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry); | ||
437 | m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry); | ||
438 | m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry); | ||
439 | #endregion | ||
440 | } | ||
441 | |||
442 | #region SOPXmlProcessors | ||
443 | private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader) | ||
444 | { | ||
445 | obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); | ||
446 | } | ||
447 | |||
448 | private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) | ||
449 | { | ||
450 | obj.CreatorID = ReadUUID(reader, "CreatorID"); | ||
451 | } | ||
452 | |||
453 | private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) | ||
454 | { | ||
455 | obj.FolderID = ReadUUID(reader, "FolderID"); | ||
456 | } | ||
457 | |||
458 | private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) | ||
459 | { | ||
460 | obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty); | ||
461 | } | ||
462 | |||
463 | private static void ProcessTaskInventory(SceneObjectPart obj, XmlTextReader reader) | ||
464 | { | ||
465 | obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory"); | ||
466 | } | ||
467 | |||
468 | private static void ProcessObjectFlags(SceneObjectPart obj, XmlTextReader reader) | ||
469 | { | ||
470 | obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); | ||
471 | } | ||
472 | |||
473 | private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) | ||
474 | { | ||
475 | obj.UUID = ReadUUID(reader, "UUID"); | ||
476 | } | ||
477 | |||
478 | private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader) | ||
479 | { | ||
480 | obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty); | ||
481 | } | ||
482 | |||
483 | private static void ProcessName(SceneObjectPart obj, XmlTextReader reader) | ||
484 | { | ||
485 | obj.Name = reader.ReadElementString("Name"); | ||
486 | } | ||
487 | |||
488 | private static void ProcessMaterial(SceneObjectPart obj, XmlTextReader reader) | ||
489 | { | ||
490 | obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty); | ||
491 | } | ||
492 | |||
493 | private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader) | ||
494 | { | ||
495 | obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); | ||
496 | } | ||
497 | |||
498 | private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader) | ||
499 | { | ||
500 | obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); | ||
501 | } | ||
502 | |||
503 | private static void ProcessScriptAccessPin(SceneObjectPart obj, XmlTextReader reader) | ||
504 | { | ||
505 | obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty); | ||
506 | } | ||
507 | |||
508 | private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) | ||
509 | { | ||
510 | obj.GroupPosition = ReadVector(reader, "GroupPosition"); | ||
511 | } | ||
512 | |||
513 | private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) | ||
514 | { | ||
515 | obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ; | ||
516 | } | ||
517 | |||
518 | private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) | ||
519 | { | ||
520 | obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); | ||
521 | } | ||
522 | |||
523 | private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) | ||
524 | { | ||
525 | obj.Velocity = ReadVector(reader, "Velocity"); | ||
526 | } | ||
527 | |||
528 | private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) | ||
529 | { | ||
530 | obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); | ||
531 | } | ||
532 | |||
533 | private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) | ||
534 | { | ||
535 | obj.Acceleration = ReadVector(reader, "Acceleration"); | ||
536 | } | ||
537 | |||
538 | private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) | ||
539 | { | ||
540 | obj.Description = reader.ReadElementString("Description"); | ||
541 | } | ||
542 | |||
543 | private static void ProcessColor(SceneObjectPart obj, XmlTextReader reader) | ||
544 | { | ||
545 | reader.ReadStartElement("Color"); | ||
546 | if (reader.Name == "R") | ||
547 | { | ||
548 | float r = reader.ReadElementContentAsFloat("R", String.Empty); | ||
549 | float g = reader.ReadElementContentAsFloat("G", String.Empty); | ||
550 | float b = reader.ReadElementContentAsFloat("B", String.Empty); | ||
551 | float a = reader.ReadElementContentAsFloat("A", String.Empty); | ||
552 | obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b); | ||
553 | reader.ReadEndElement(); | ||
554 | } | ||
555 | } | ||
556 | |||
557 | private static void ProcessText(SceneObjectPart obj, XmlTextReader reader) | ||
558 | { | ||
559 | obj.Text = reader.ReadElementString("Text", String.Empty); | ||
560 | } | ||
561 | |||
562 | private static void ProcessSitName(SceneObjectPart obj, XmlTextReader reader) | ||
563 | { | ||
564 | obj.SitName = reader.ReadElementString("SitName", String.Empty); | ||
565 | } | ||
566 | |||
567 | private static void ProcessTouchName(SceneObjectPart obj, XmlTextReader reader) | ||
568 | { | ||
569 | obj.TouchName = reader.ReadElementString("TouchName", String.Empty); | ||
570 | } | ||
571 | |||
572 | private static void ProcessLinkNum(SceneObjectPart obj, XmlTextReader reader) | ||
573 | { | ||
574 | obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty); | ||
575 | } | ||
576 | |||
577 | private static void ProcessClickAction(SceneObjectPart obj, XmlTextReader reader) | ||
578 | { | ||
579 | obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); | ||
580 | } | ||
581 | |||
582 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | ||
583 | { | ||
584 | obj.Shape = ReadShape(reader, "Shape"); | ||
585 | } | ||
586 | |||
587 | private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) | ||
588 | { | ||
589 | obj.Scale = ReadVector(reader, "Scale"); | ||
590 | } | ||
591 | |||
592 | private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) | ||
593 | { | ||
594 | obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); | ||
595 | } | ||
596 | |||
597 | private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) | ||
598 | { | ||
599 | obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); | ||
600 | } | ||
601 | |||
602 | private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) | ||
603 | { | ||
604 | obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); | ||
605 | } | ||
606 | |||
607 | private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) | ||
608 | { | ||
609 | obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); | ||
610 | } | ||
611 | |||
612 | private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) | ||
613 | { | ||
614 | obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); | ||
615 | } | ||
616 | |||
617 | private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) | ||
618 | { | ||
619 | string str = reader.ReadElementContentAsString("ParentID", String.Empty); | ||
620 | obj.ParentID = Convert.ToUInt32(str); | ||
621 | } | ||
622 | |||
623 | private static void ProcessCreationDate(SceneObjectPart obj, XmlTextReader reader) | ||
624 | { | ||
625 | obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); | ||
626 | } | ||
627 | |||
628 | private static void ProcessCategory(SceneObjectPart obj, XmlTextReader reader) | ||
629 | { | ||
630 | obj.Category = (uint)reader.ReadElementContentAsInt("Category", String.Empty); | ||
631 | } | ||
632 | |||
633 | private static void ProcessSalePrice(SceneObjectPart obj, XmlTextReader reader) | ||
634 | { | ||
635 | obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); | ||
636 | } | ||
637 | |||
638 | private static void ProcessObjectSaleType(SceneObjectPart obj, XmlTextReader reader) | ||
639 | { | ||
640 | obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty); | ||
641 | } | ||
642 | |||
643 | private static void ProcessOwnershipCost(SceneObjectPart obj, XmlTextReader reader) | ||
644 | { | ||
645 | obj.OwnershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty); | ||
646 | } | ||
647 | |||
648 | private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) | ||
649 | { | ||
650 | obj.GroupID = ReadUUID(reader, "GroupID"); | ||
651 | } | ||
652 | |||
653 | private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) | ||
654 | { | ||
655 | obj.OwnerID = ReadUUID(reader, "OwnerID"); | ||
656 | } | ||
657 | |||
658 | private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) | ||
659 | { | ||
660 | obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | ||
661 | } | ||
662 | |||
663 | private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) | ||
664 | { | ||
665 | obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty); | ||
666 | } | ||
667 | |||
668 | private static void ProcessOwnerMask(SceneObjectPart obj, XmlTextReader reader) | ||
669 | { | ||
670 | obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty); | ||
671 | } | ||
672 | |||
673 | private static void ProcessGroupMask(SceneObjectPart obj, XmlTextReader reader) | ||
674 | { | ||
675 | obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty); | ||
676 | } | ||
677 | |||
678 | private static void ProcessEveryoneMask(SceneObjectPart obj, XmlTextReader reader) | ||
679 | { | ||
680 | obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty); | ||
681 | } | ||
682 | |||
683 | private static void ProcessNextOwnerMask(SceneObjectPart obj, XmlTextReader reader) | ||
684 | { | ||
685 | obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty); | ||
686 | } | ||
687 | |||
688 | private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader) | ||
689 | { | ||
690 | string value = reader.ReadElementContentAsString("Flags", String.Empty); | ||
691 | // !!!!! to deal with flags without commas | ||
692 | if (value.Contains(" ") && !value.Contains(",")) | ||
693 | value = value.Replace(" ", ", "); | ||
694 | obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value); | ||
695 | } | ||
696 | |||
697 | private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader) | ||
698 | { | ||
699 | obj.CollisionSound = ReadUUID(reader, "CollisionSound"); | ||
700 | } | ||
701 | |||
702 | private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) | ||
703 | { | ||
704 | obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); | ||
705 | } | ||
706 | #endregion | ||
707 | |||
708 | #region TaskInventoryXmlProcessors | ||
709 | private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) | ||
710 | { | ||
711 | item.AssetID = ReadUUID(reader, "AssetID"); | ||
712 | } | ||
713 | |||
714 | private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) | ||
715 | { | ||
716 | item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); | ||
717 | } | ||
718 | |||
719 | private static void ProcessTICreationDate(TaskInventoryItem item, XmlTextReader reader) | ||
720 | { | ||
721 | item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty); | ||
722 | } | ||
723 | |||
724 | private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) | ||
725 | { | ||
726 | item.CreatorID = ReadUUID(reader, "CreatorID"); | ||
727 | } | ||
728 | |||
729 | private static void ProcessTIDescription(TaskInventoryItem item, XmlTextReader reader) | ||
730 | { | ||
731 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); | ||
732 | } | ||
733 | |||
734 | private static void ProcessTIEveryonePermissions(TaskInventoryItem item, XmlTextReader reader) | ||
735 | { | ||
736 | item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty); | ||
737 | } | ||
738 | |||
739 | private static void ProcessTIFlags(TaskInventoryItem item, XmlTextReader reader) | ||
740 | { | ||
741 | item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); | ||
742 | } | ||
743 | |||
744 | private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) | ||
745 | { | ||
746 | item.GroupID = ReadUUID(reader, "GroupID"); | ||
747 | } | ||
748 | |||
749 | private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) | ||
750 | { | ||
751 | item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty); | ||
752 | } | ||
753 | |||
754 | private static void ProcessTIInvType(TaskInventoryItem item, XmlTextReader reader) | ||
755 | { | ||
756 | item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); | ||
757 | } | ||
758 | |||
759 | private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) | ||
760 | { | ||
761 | item.ItemID = ReadUUID(reader, "ItemID"); | ||
762 | } | ||
763 | |||
764 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) | ||
765 | { | ||
766 | item.OldItemID = ReadUUID(reader, "OldItemID"); | ||
767 | } | ||
768 | |||
769 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) | ||
770 | { | ||
771 | item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | ||
772 | } | ||
773 | |||
774 | private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) | ||
775 | { | ||
776 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); | ||
777 | } | ||
778 | |||
779 | private static void ProcessTINextPermissions(TaskInventoryItem item, XmlTextReader reader) | ||
780 | { | ||
781 | item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); | ||
782 | } | ||
783 | |||
784 | private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) | ||
785 | { | ||
786 | item.OwnerID = ReadUUID(reader, "OwnerID"); | ||
787 | } | ||
788 | |||
789 | private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) | ||
790 | { | ||
791 | item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); | ||
792 | } | ||
793 | |||
794 | private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) | ||
795 | { | ||
796 | item.ParentID = ReadUUID(reader, "ParentID"); | ||
797 | } | ||
798 | |||
799 | private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) | ||
800 | { | ||
801 | item.ParentPartID = ReadUUID(reader, "ParentPartID"); | ||
802 | } | ||
803 | |||
804 | private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) | ||
805 | { | ||
806 | item.PermsGranter = ReadUUID(reader, "PermsGranter"); | ||
807 | } | ||
808 | |||
809 | private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) | ||
810 | { | ||
811 | item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); | ||
812 | } | ||
813 | |||
814 | private static void ProcessTIType(TaskInventoryItem item, XmlTextReader reader) | ||
815 | { | ||
816 | item.Type = reader.ReadElementContentAsInt("Type", String.Empty); | ||
817 | } | ||
818 | |||
819 | #endregion | ||
820 | |||
821 | #region ShapeXmlProcessors | ||
822 | private static void ProcessShpProfileCurve(PrimitiveBaseShape shp, XmlTextReader reader) | ||
823 | { | ||
824 | shp.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); | ||
825 | } | ||
826 | |||
827 | private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlTextReader reader) | ||
828 | { | ||
829 | byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry")); | ||
830 | shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); | ||
831 | } | ||
832 | |||
833 | private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlTextReader reader) | ||
834 | { | ||
835 | shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString("ExtraParams")); | ||
836 | } | ||
837 | |||
838 | private static void ProcessShpPathBegin(PrimitiveBaseShape shp, XmlTextReader reader) | ||
839 | { | ||
840 | shp.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty); | ||
841 | } | ||
842 | |||
843 | private static void ProcessShpPathCurve(PrimitiveBaseShape shp, XmlTextReader reader) | ||
844 | { | ||
845 | shp.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty); | ||
846 | } | ||
847 | |||
848 | private static void ProcessShpPathEnd(PrimitiveBaseShape shp, XmlTextReader reader) | ||
849 | { | ||
850 | shp.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty); | ||
851 | } | ||
852 | |||
853 | private static void ProcessShpPathRadiusOffset(PrimitiveBaseShape shp, XmlTextReader reader) | ||
854 | { | ||
855 | shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty); | ||
856 | } | ||
857 | |||
858 | private static void ProcessShpPathRevolutions(PrimitiveBaseShape shp, XmlTextReader reader) | ||
859 | { | ||
860 | shp.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty); | ||
861 | } | ||
862 | |||
863 | private static void ProcessShpPathScaleX(PrimitiveBaseShape shp, XmlTextReader reader) | ||
864 | { | ||
865 | shp.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty); | ||
866 | } | ||
867 | |||
868 | private static void ProcessShpPathScaleY(PrimitiveBaseShape shp, XmlTextReader reader) | ||
869 | { | ||
870 | shp.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty); | ||
871 | } | ||
872 | |||
873 | private static void ProcessShpPathShearX(PrimitiveBaseShape shp, XmlTextReader reader) | ||
874 | { | ||
875 | shp.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty); | ||
876 | } | ||
877 | |||
878 | private static void ProcessShpPathShearY(PrimitiveBaseShape shp, XmlTextReader reader) | ||
879 | { | ||
880 | shp.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty); | ||
881 | } | ||
882 | |||
883 | private static void ProcessShpPathSkew(PrimitiveBaseShape shp, XmlTextReader reader) | ||
884 | { | ||
885 | shp.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty); | ||
886 | } | ||
887 | |||
888 | private static void ProcessShpPathTaperX(PrimitiveBaseShape shp, XmlTextReader reader) | ||
889 | { | ||
890 | shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty); | ||
891 | } | ||
892 | |||
893 | private static void ProcessShpPathTaperY(PrimitiveBaseShape shp, XmlTextReader reader) | ||
894 | { | ||
895 | shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty); | ||
896 | } | ||
897 | |||
898 | private static void ProcessShpPathTwist(PrimitiveBaseShape shp, XmlTextReader reader) | ||
899 | { | ||
900 | shp.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty); | ||
901 | } | ||
902 | |||
903 | private static void ProcessShpPathTwistBegin(PrimitiveBaseShape shp, XmlTextReader reader) | ||
904 | { | ||
905 | shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty); | ||
906 | } | ||
907 | |||
908 | private static void ProcessShpPCode(PrimitiveBaseShape shp, XmlTextReader reader) | ||
909 | { | ||
910 | shp.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty); | ||
911 | } | ||
912 | |||
913 | private static void ProcessShpProfileBegin(PrimitiveBaseShape shp, XmlTextReader reader) | ||
914 | { | ||
915 | shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty); | ||
916 | } | ||
917 | |||
918 | private static void ProcessShpProfileEnd(PrimitiveBaseShape shp, XmlTextReader reader) | ||
919 | { | ||
920 | shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty); | ||
921 | } | ||
922 | |||
923 | private static void ProcessShpProfileHollow(PrimitiveBaseShape shp, XmlTextReader reader) | ||
924 | { | ||
925 | shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty); | ||
926 | } | ||
927 | |||
928 | private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) | ||
929 | { | ||
930 | shp.Scale = ReadVector(reader, "Scale"); | ||
931 | } | ||
932 | |||
933 | private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) | ||
934 | { | ||
935 | shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); | ||
936 | } | ||
937 | |||
938 | private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader) | ||
939 | { | ||
940 | string value = reader.ReadElementContentAsString("ProfileShape", String.Empty); | ||
941 | // !!!!! to deal with flags without commas | ||
942 | if (value.Contains(" ") && !value.Contains(",")) | ||
943 | value = value.Replace(" ", ", "); | ||
944 | shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value); | ||
945 | } | ||
946 | |||
947 | private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader) | ||
948 | { | ||
949 | string value = reader.ReadElementContentAsString("HollowShape", String.Empty); | ||
950 | // !!!!! to deal with flags without commas | ||
951 | if (value.Contains(" ") && !value.Contains(",")) | ||
952 | value = value.Replace(" ", ", "); | ||
953 | shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value); | ||
954 | } | ||
955 | |||
956 | private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader) | ||
957 | { | ||
958 | shp.SculptTexture = ReadUUID(reader, "SculptTexture"); | ||
959 | } | ||
960 | |||
961 | private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader) | ||
962 | { | ||
963 | shp.SculptType = (byte)reader.ReadElementContentAsInt("SculptType", String.Empty); | ||
964 | } | ||
965 | |||
966 | private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader) | ||
967 | { | ||
968 | shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData")); | ||
969 | } | ||
970 | |||
971 | private static void ProcessShpFlexiSoftness(PrimitiveBaseShape shp, XmlTextReader reader) | ||
972 | { | ||
973 | shp.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty); | ||
974 | } | ||
975 | |||
976 | private static void ProcessShpFlexiTension(PrimitiveBaseShape shp, XmlTextReader reader) | ||
977 | { | ||
978 | shp.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty); | ||
979 | } | ||
980 | |||
981 | private static void ProcessShpFlexiDrag(PrimitiveBaseShape shp, XmlTextReader reader) | ||
982 | { | ||
983 | shp.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty); | ||
984 | } | ||
985 | |||
986 | private static void ProcessShpFlexiGravity(PrimitiveBaseShape shp, XmlTextReader reader) | ||
987 | { | ||
988 | shp.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty); | ||
989 | } | ||
990 | |||
991 | private static void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlTextReader reader) | ||
992 | { | ||
993 | shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty); | ||
994 | } | ||
995 | |||
996 | private static void ProcessShpFlexiForceX(PrimitiveBaseShape shp, XmlTextReader reader) | ||
997 | { | ||
998 | shp.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty); | ||
999 | } | ||
1000 | |||
1001 | private static void ProcessShpFlexiForceY(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1002 | { | ||
1003 | shp.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty); | ||
1004 | } | ||
1005 | |||
1006 | private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1007 | { | ||
1008 | shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty); | ||
1009 | } | ||
1010 | |||
1011 | private static void ProcessShpLightColorR(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1012 | { | ||
1013 | shp.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty); | ||
1014 | } | ||
1015 | |||
1016 | private static void ProcessShpLightColorG(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1017 | { | ||
1018 | shp.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty); | ||
1019 | } | ||
1020 | |||
1021 | private static void ProcessShpLightColorB(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1022 | { | ||
1023 | shp.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty); | ||
1024 | } | ||
1025 | |||
1026 | private static void ProcessShpLightColorA(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1027 | { | ||
1028 | shp.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty); | ||
1029 | } | ||
1030 | |||
1031 | private static void ProcessShpLightRadius(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1032 | { | ||
1033 | shp.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty); | ||
1034 | } | ||
1035 | |||
1036 | private static void ProcessShpLightCutoff(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1037 | { | ||
1038 | shp.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty); | ||
1039 | } | ||
1040 | |||
1041 | private static void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1042 | { | ||
1043 | shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty); | ||
1044 | } | ||
1045 | |||
1046 | private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1047 | { | ||
1048 | shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty); | ||
1049 | } | ||
1050 | |||
1051 | private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1052 | { | ||
1053 | shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); | ||
1054 | } | ||
1055 | |||
1056 | private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1057 | { | ||
1058 | shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); | ||
1059 | } | ||
1060 | |||
1061 | private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader) | ||
1062 | { | ||
1063 | shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); | ||
1064 | } | ||
1065 | |||
1066 | #endregion | ||
1067 | |||
1068 | ////////// Write ///////// | ||
1069 | |||
1070 | public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog) | ||
1071 | { | ||
1072 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
1073 | SOPToXml2(writer, sog.RootPart, null); | ||
1074 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
1075 | |||
1076 | sog.ForEachPart(delegate(SceneObjectPart sop) | ||
1077 | { | ||
1078 | SOPToXml2(writer, sop, sog.RootPart); | ||
1079 | }); | ||
1080 | |||
1081 | writer.WriteEndElement(); | ||
1082 | writer.WriteEndElement(); | ||
1083 | } | ||
1084 | |||
1085 | static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent) | ||
1086 | { | ||
1087 | writer.WriteStartElement("SceneObjectPart"); | ||
1088 | writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); | ||
1089 | writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); | ||
1090 | |||
1091 | WriteUUID(writer, "CreatorID", sop.CreatorID); | ||
1092 | WriteUUID(writer, "FolderID", sop.FolderID); | ||
1093 | writer.WriteElementString("InventorySerial", (sop.Inventory != null) ? sop.InventorySerial.ToString() : "0"); | ||
1094 | |||
1095 | // FIXME: Task inventory | ||
1096 | writer.WriteStartElement("TaskInventory"); writer.WriteEndElement(); | ||
1097 | |||
1098 | writer.WriteElementString("ObjectFlags", ((int)sop.Flags).ToString()); | ||
1099 | |||
1100 | WriteUUID(writer, "UUID", sop.UUID); | ||
1101 | writer.WriteElementString("LocalId", sop.LocalId.ToString()); | ||
1102 | writer.WriteElementString("Name", sop.Name); | ||
1103 | writer.WriteElementString("Material", ((int)sop.Material).ToString()); | ||
1104 | writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString()); | ||
1105 | writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString()); | ||
1106 | |||
1107 | WriteVector(writer, "GroupPosition", sop.GroupPosition); | ||
1108 | WriteVector(writer, "OffsetPosition", sop.OffsetPosition); | ||
1109 | |||
1110 | WriteQuaternion(writer, "RotationOffset", sop.RotationOffset); | ||
1111 | WriteVector(writer, "Velocity", sop.Velocity); | ||
1112 | WriteVector(writer, "RotationalVelocity", Vector3.Zero); | ||
1113 | WriteVector(writer, "AngularVelocity", sop.AngularVelocity); | ||
1114 | WriteVector(writer, "Acceleration", sop.Acceleration); | ||
1115 | writer.WriteElementString("Description", sop.Description); | ||
1116 | writer.WriteStartElement("Color"); | ||
1117 | writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); | ||
1118 | writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); | ||
1119 | writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); | ||
1120 | writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); | ||
1121 | writer.WriteEndElement(); | ||
1122 | writer.WriteElementString("Text", sop.Text); | ||
1123 | writer.WriteElementString("SitName", sop.SitName); | ||
1124 | writer.WriteElementString("TouchName", sop.TouchName); | ||
1125 | |||
1126 | writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); | ||
1127 | writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); | ||
1128 | writer.WriteStartElement("Shape"); | ||
1129 | |||
1130 | writer.WriteElementString("ProfileCurve", sop.Shape.ProfileCurve.ToString()); | ||
1131 | |||
1132 | writer.WriteStartElement("TextureEntry"); | ||
1133 | byte[] te; | ||
1134 | if (sop.Shape.TextureEntry != null) | ||
1135 | te = sop.Shape.TextureEntry; | ||
1136 | else | ||
1137 | te = Utils.EmptyBytes; | ||
1138 | writer.WriteBase64(te, 0, te.Length); | ||
1139 | writer.WriteEndElement(); // TextureEntry | ||
1140 | |||
1141 | writer.WriteStartElement("ExtraParams"); | ||
1142 | byte[] ep; | ||
1143 | if (sop.Shape.ExtraParams != null) | ||
1144 | ep = sop.Shape.ExtraParams; | ||
1145 | else | ||
1146 | ep = Utils.EmptyBytes; | ||
1147 | writer.WriteBase64(ep, 0, ep.Length); | ||
1148 | writer.WriteEndElement(); // ExtraParams | ||
1149 | |||
1150 | writer.WriteElementString("PathBegin", Primitive.PackBeginCut(sop.Shape.PathBegin).ToString()); | ||
1151 | writer.WriteElementString("PathCurve", sop.Shape.PathCurve.ToString()); | ||
1152 | writer.WriteElementString("PathEnd", Primitive.PackEndCut(sop.Shape.PathEnd).ToString()); | ||
1153 | writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(sop.Shape.PathRadiusOffset).ToString()); | ||
1154 | writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(sop.Shape.PathRevolutions).ToString()); | ||
1155 | writer.WriteElementString("PathScaleX", Primitive.PackPathScale(sop.Shape.PathScaleX).ToString()); | ||
1156 | writer.WriteElementString("PathScaleY", Primitive.PackPathScale(sop.Shape.PathScaleY).ToString()); | ||
1157 | writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(sop.Shape.PathShearX)).ToString()); | ||
1158 | writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(sop.Shape.PathShearY)).ToString()); | ||
1159 | writer.WriteElementString("PathSkew", Primitive.PackPathTwist(sop.Shape.PathSkew).ToString()); | ||
1160 | writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(sop.Shape.PathTaperX).ToString()); | ||
1161 | writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(sop.Shape.PathTaperY).ToString()); | ||
1162 | writer.WriteElementString("PathTwist", Primitive.PackPathTwist(sop.Shape.PathTwist).ToString()); | ||
1163 | writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(sop.Shape.PathTwistBegin).ToString()); | ||
1164 | writer.WriteElementString("PCode", sop.Shape.PCode.ToString()); | ||
1165 | writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(sop.Shape.ProfileBegin).ToString()); | ||
1166 | writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(sop.Shape.ProfileEnd).ToString()); | ||
1167 | writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(sop.Shape.ProfileHollow).ToString()); | ||
1168 | WriteVector(writer, "Scale", sop.Scale); | ||
1169 | writer.WriteElementString("State", sop.Shape.State.ToString()); | ||
1170 | |||
1171 | writer.WriteElementString("ProfileShape", sop.Shape.ProfileShape.ToString()); | ||
1172 | writer.WriteElementString("HollowShape", sop.Shape.HollowShape.ToString()); | ||
1173 | |||
1174 | writer.WriteElementString("SculptTexture", sop.Shape.SculptTexture.ToString()); | ||
1175 | writer.WriteElementString("SculptType", sop.Shape.SculptType.ToString()); | ||
1176 | writer.WriteStartElement("SculptData"); | ||
1177 | byte[] sd; | ||
1178 | if (sop.Shape.SculptData != null) | ||
1179 | sd = sop.Shape.ExtraParams; | ||
1180 | else | ||
1181 | sd = Utils.EmptyBytes; | ||
1182 | writer.WriteBase64(sd, 0, sd.Length); | ||
1183 | writer.WriteEndElement(); // SculptData | ||
1184 | |||
1185 | writer.WriteElementString("FlexiSoftness", sop.Shape.FlexiSoftness.ToString()); | ||
1186 | writer.WriteElementString("FlexiTension", sop.Shape.FlexiTension.ToString()); | ||
1187 | writer.WriteElementString("FlexiDrag", sop.Shape.FlexiDrag.ToString()); | ||
1188 | writer.WriteElementString("FlexiGravity", sop.Shape.FlexiGravity.ToString()); | ||
1189 | writer.WriteElementString("FlexiWind", sop.Shape.FlexiWind.ToString()); | ||
1190 | writer.WriteElementString("FlexiForceX", sop.Shape.FlexiForceX.ToString()); | ||
1191 | writer.WriteElementString("FlexiForceY", sop.Shape.FlexiForceY.ToString()); | ||
1192 | writer.WriteElementString("FlexiForceZ", sop.Shape.FlexiForceZ.ToString()); | ||
1193 | |||
1194 | writer.WriteElementString("LightColorR", sop.Shape.LightColorR.ToString()); | ||
1195 | writer.WriteElementString("LightColorG", sop.Shape.LightColorG.ToString()); | ||
1196 | writer.WriteElementString("LightColorB", sop.Shape.LightColorB.ToString()); | ||
1197 | writer.WriteElementString("LightColorA", sop.Shape.LightColorA.ToString()); | ||
1198 | writer.WriteElementString("LightRadius", sop.Shape.LightRadius.ToString()); | ||
1199 | writer.WriteElementString("LightCutoff", sop.Shape.LightCutoff.ToString()); | ||
1200 | writer.WriteElementString("LightFalloff", sop.Shape.LightFalloff.ToString()); | ||
1201 | writer.WriteElementString("LightIntensity", sop.Shape.LightIntensity.ToString()); | ||
1202 | |||
1203 | writer.WriteElementString("FlexyEntry", sop.Shape.FlexiEntry.ToString()); | ||
1204 | writer.WriteElementString("LightEntry", sop.Shape.LightEntry.ToString()); | ||
1205 | writer.WriteElementString("SculptEntry", sop.Shape.SculptEntry.ToString()); | ||
1206 | |||
1207 | writer.WriteEndElement(); // Shape | ||
1208 | |||
1209 | WriteVector(writer, "Scale", sop.Scale); | ||
1210 | writer.WriteElementString("UpdateFlag", "0"); | ||
1211 | WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation); | ||
1212 | WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition); | ||
1213 | WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL); | ||
1214 | WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL); | ||
1215 | writer.WriteElementString("ParentID", sop.ParentID.ToString()); | ||
1216 | writer.WriteElementString("CreationDate", sop.CreationDate.ToString()); | ||
1217 | writer.WriteElementString("Category", "0"); | ||
1218 | writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); | ||
1219 | writer.WriteElementString("ObjectSaleType", ((int)sop.ObjectSaleType).ToString()); | ||
1220 | writer.WriteElementString("OwnershipCost", "0"); | ||
1221 | WriteUUID(writer, "GroupID", sop.GroupID); | ||
1222 | WriteUUID(writer, "OwnerID", sop.OwnerID); | ||
1223 | WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); | ||
1224 | writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); | ||
1225 | writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); | ||
1226 | writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); | ||
1227 | writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); | ||
1228 | writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); | ||
1229 | writer.WriteElementString("Flags", sop.Flags.ToString()); | ||
1230 | WriteUUID(writer, "CollisionSound", sop.CollisionSound); | ||
1231 | writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); | ||
1232 | |||
1233 | writer.WriteEndElement(); | ||
1234 | } | ||
1235 | |||
1236 | static void WriteUUID(XmlTextWriter writer, string name, UUID id) | ||
1237 | { | ||
1238 | writer.WriteStartElement(name); | ||
1239 | writer.WriteElementString("UUID", id.ToString()); | ||
1240 | writer.WriteEndElement(); | ||
1241 | } | ||
1242 | |||
1243 | static void WriteVector(XmlTextWriter writer, string name, Vector3 vec) | ||
1244 | { | ||
1245 | writer.WriteStartElement(name); | ||
1246 | writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); | ||
1247 | writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); | ||
1248 | writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); | ||
1249 | writer.WriteEndElement(); | ||
1250 | } | ||
1251 | |||
1252 | static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat) | ||
1253 | { | ||
1254 | writer.WriteStartElement(name); | ||
1255 | writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); | ||
1256 | writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); | ||
1257 | writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); | ||
1258 | writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); | ||
1259 | writer.WriteEndElement(); | ||
1260 | } | ||
1261 | |||
1262 | |||
1263 | //////// Read ///////// | ||
1264 | public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) | ||
1265 | { | ||
1266 | reader.Read(); | ||
1267 | reader.ReadStartElement("SceneObjectGroup"); | ||
1268 | SceneObjectPart root = Xml2ToSOP(reader); | ||
1269 | if (root != null) | ||
1270 | sog.SetRootPart(root); | ||
1271 | else | ||
1272 | { | ||
1273 | return false; | ||
1274 | } | ||
1275 | |||
1276 | if (sog.UUID == UUID.Zero) | ||
1277 | sog.UUID = sog.RootPart.UUID; | ||
1278 | |||
1279 | reader.Read(); // OtherParts | ||
1280 | |||
1281 | while (!reader.EOF) | ||
1282 | { | ||
1283 | switch (reader.NodeType) | ||
1284 | { | ||
1285 | case XmlNodeType.Element: | ||
1286 | if (reader.Name == "SceneObjectPart") | ||
1287 | { | ||
1288 | SceneObjectPart child = Xml2ToSOP(reader); | ||
1289 | if (child != null) | ||
1290 | sog.AddPart(child); | ||
1291 | } | ||
1292 | else | ||
1293 | { | ||
1294 | //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug); | ||
1295 | reader.Read(); | ||
1296 | } | ||
1297 | break; | ||
1298 | case XmlNodeType.EndElement: | ||
1299 | default: | ||
1300 | reader.Read(); | ||
1301 | break; | ||
1302 | } | ||
1303 | |||
1304 | } | ||
1305 | return true; | ||
1306 | } | ||
1307 | |||
1308 | public static SceneObjectPart Xml2ToSOPPull(XmlTextReader reader) | ||
1309 | { | ||
1310 | SceneObjectPart obj = new SceneObjectPart(); | ||
1311 | |||
1312 | reader.ReadStartElement("SceneObjectPart"); | ||
1313 | |||
1314 | if (reader.Name == "AllowedDrop") | ||
1315 | obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); | ||
1316 | else | ||
1317 | obj.AllowedDrop = true; | ||
1318 | |||
1319 | obj.CreatorID = ReadUUID(reader, "CreatorID"); | ||
1320 | obj.FolderID = ReadUUID(reader, "FolderID"); | ||
1321 | obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty); | ||
1322 | |||
1323 | #region Task Inventory | ||
1324 | |||
1325 | obj.TaskInventory = new TaskInventoryDictionary(); | ||
1326 | //List<PrimObject.InventoryBlock.ItemBlock> invItems = new List<PrimObject.InventoryBlock.ItemBlock>(); | ||
1327 | |||
1328 | reader.ReadStartElement("TaskInventory", String.Empty); | ||
1329 | while (reader.Name == "TaskInventoryItem") | ||
1330 | { | ||
1331 | TaskInventoryItem item = new TaskInventoryItem(); | ||
1332 | reader.ReadStartElement("TaskInventoryItem", String.Empty); | ||
1333 | |||
1334 | item.AssetID = ReadUUID(reader, "AssetID"); | ||
1335 | item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); | ||
1336 | item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty); | ||
1337 | item.CreatorID = ReadUUID(reader, "CreatorID"); | ||
1338 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); | ||
1339 | item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty); | ||
1340 | item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); | ||
1341 | item.GroupID = ReadUUID(reader, "GroupID"); | ||
1342 | item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty); | ||
1343 | item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); | ||
1344 | item.ItemID = ReadUUID(reader, "ItemID"); | ||
1345 | UUID oldItemID = ReadUUID(reader, "OldItemID"); // TODO: Is this useful? | ||
1346 | item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | ||
1347 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); | ||
1348 | item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); | ||
1349 | item.OwnerID = ReadUUID(reader, "OwnerID"); | ||
1350 | item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); | ||
1351 | UUID parentID = ReadUUID(reader, "ParentID"); | ||
1352 | UUID parentPartID = ReadUUID(reader, "ParentPartID"); | ||
1353 | item.PermsGranter = ReadUUID(reader, "PermsGranter"); | ||
1354 | item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); | ||
1355 | item.Type = reader.ReadElementContentAsInt("Type", String.Empty); | ||
1356 | |||
1357 | reader.ReadEndElement(); | ||
1358 | obj.TaskInventory.Add(item.ItemID, item); | ||
1359 | } | ||
1360 | if (reader.NodeType == XmlNodeType.EndElement) | ||
1361 | reader.ReadEndElement(); | ||
1362 | |||
1363 | #endregion Task Inventory | ||
1364 | |||
1365 | obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty); | ||
1366 | |||
1367 | obj.UUID = ReadUUID(reader, "UUID"); | ||
1368 | obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty); | ||
1369 | obj.Name = reader.ReadElementString("Name"); | ||
1370 | obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty); | ||
1371 | |||
1372 | if (reader.Name == "PassTouches") | ||
1373 | obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); | ||
1374 | else | ||
1375 | obj.PassTouches = false; | ||
1376 | |||
1377 | obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty); | ||
1378 | obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty); | ||
1379 | |||
1380 | if (reader.Name == "PlaySoundSlavePrims") | ||
1381 | reader.ReadInnerXml(); | ||
1382 | if (reader.Name == "LoopSoundSlavePrims") | ||
1383 | reader.ReadInnerXml(); | ||
1384 | |||
1385 | Vector3 groupPosition = ReadVector(reader, "GroupPosition"); | ||
1386 | Vector3 offsetPosition = ReadVector(reader, "OffsetPosition"); | ||
1387 | obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); | ||
1388 | obj.Velocity = ReadVector(reader, "Velocity"); | ||
1389 | if (reader.Name == "RotationalVelocity") | ||
1390 | ReadVector(reader, "RotationalVelocity"); | ||
1391 | obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); | ||
1392 | obj.Acceleration = ReadVector(reader, "Acceleration"); | ||
1393 | obj.Description = reader.ReadElementString("Description"); | ||
1394 | reader.ReadStartElement("Color"); | ||
1395 | if (reader.Name == "R") | ||
1396 | { | ||
1397 | obj.Color = Color.FromArgb((int)reader.ReadElementContentAsFloat("A", String.Empty), | ||
1398 | (int)reader.ReadElementContentAsFloat("R", String.Empty), | ||
1399 | (int)reader.ReadElementContentAsFloat("G", String.Empty), | ||
1400 | (int)reader.ReadElementContentAsFloat("B", String.Empty)); | ||
1401 | reader.ReadEndElement(); | ||
1402 | } | ||
1403 | obj.Text = reader.ReadElementString("Text", String.Empty); | ||
1404 | obj.SitName = reader.ReadElementString("SitName", String.Empty); | ||
1405 | obj.TouchName = reader.ReadElementString("TouchName", String.Empty); | ||
1406 | |||
1407 | obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty); | ||
1408 | obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); | ||
1409 | |||
1410 | reader.ReadStartElement("Shape"); | ||
1411 | obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); | ||
1412 | |||
1413 | byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry")); | ||
1414 | obj.Shape.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); | ||
1415 | |||
1416 | reader.ReadInnerXml(); // ExtraParams | ||
1417 | |||
1418 | obj.Shape.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty); | ||
1419 | obj.Shape.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty); | ||
1420 | obj.Shape.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty); | ||
1421 | obj.Shape.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty); | ||
1422 | obj.Shape.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty); | ||
1423 | obj.Shape.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty); | ||
1424 | obj.Shape.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty); | ||
1425 | obj.Shape.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty); | ||
1426 | obj.Shape.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty); | ||
1427 | obj.Shape.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty); | ||
1428 | obj.Shape.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty); | ||
1429 | obj.Shape.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty); | ||
1430 | obj.Shape.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty); | ||
1431 | obj.Shape.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty); | ||
1432 | obj.Shape.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty); | ||
1433 | obj.Shape.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty); | ||
1434 | obj.Shape.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty); | ||
1435 | obj.Shape.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty); | ||
1436 | obj.Scale = ReadVector(reader, "Scale"); | ||
1437 | obj.Shape.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); | ||
1438 | |||
1439 | obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty); | ||
1440 | obj.Shape.ProfileShape = (ProfileShape)reader.ReadElementContentAsInt("ProfileShape", String.Empty); | ||
1441 | obj.Shape.HollowShape = (HollowShape)reader.ReadElementContentAsInt("HollowShape", String.Empty); | ||
1442 | |||
1443 | UUID sculptTexture = ReadUUID(reader, "SculptTexture"); | ||
1444 | SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty); | ||
1445 | if (sculptTexture != UUID.Zero) | ||
1446 | { | ||
1447 | obj.Shape.SculptTexture = sculptTexture; | ||
1448 | obj.Shape.SculptType = (byte)sculptType; | ||
1449 | } | ||
1450 | |||
1451 | reader.ReadInnerXml(); // SculptData | ||
1452 | |||
1453 | obj.Shape.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty); | ||
1454 | obj.Shape.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty); | ||
1455 | obj.Shape.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty); | ||
1456 | obj.Shape.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty); | ||
1457 | obj.Shape.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty); | ||
1458 | obj.Shape.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty); | ||
1459 | obj.Shape.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty); | ||
1460 | obj.Shape.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty); | ||
1461 | |||
1462 | obj.Shape.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty); | ||
1463 | obj.Shape.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty); | ||
1464 | obj.Shape.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty); | ||
1465 | obj.Shape.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty); | ||
1466 | obj.Shape.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty); | ||
1467 | obj.Shape.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty); | ||
1468 | obj.Shape.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty); | ||
1469 | obj.Shape.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty); | ||
1470 | |||
1471 | bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); | ||
1472 | bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); | ||
1473 | reader.ReadInnerXml(); // SculptEntry | ||
1474 | |||
1475 | reader.ReadEndElement(); | ||
1476 | |||
1477 | obj.Scale = ReadVector(reader, "Scale"); // Yes, again | ||
1478 | obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); // UpdateFlag | ||
1479 | |||
1480 | obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); | ||
1481 | obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); | ||
1482 | obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); | ||
1483 | obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); | ||
1484 | obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty); | ||
1485 | obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); | ||
1486 | int category = reader.ReadElementContentAsInt("Category", String.Empty); | ||
1487 | obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); | ||
1488 | obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty); | ||
1489 | int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty); | ||
1490 | obj.GroupID = ReadUUID(reader, "GroupID"); | ||
1491 | obj.OwnerID = ReadUUID(reader, "OwnerID"); | ||
1492 | obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | ||
1493 | obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty); | ||
1494 | obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty); | ||
1495 | obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty); | ||
1496 | obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty); | ||
1497 | obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty); | ||
1498 | |||
1499 | obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("Flags", String.Empty); | ||
1500 | |||
1501 | obj.CollisionSound = ReadUUID(reader, "CollisionSound"); | ||
1502 | obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); | ||
1503 | |||
1504 | reader.ReadEndElement(); | ||
1505 | |||
1506 | obj.GroupPosition = groupPosition; | ||
1507 | obj.OffsetPosition = offsetPosition; | ||
1508 | |||
1509 | return obj; | ||
1510 | } | ||
1511 | |||
1512 | public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) | ||
1513 | { | ||
1514 | SceneObjectPart obj = new SceneObjectPart(); | ||
1515 | |||
1516 | reader.ReadStartElement("SceneObjectPart"); | ||
1517 | |||
1518 | string nodeName = string.Empty; | ||
1519 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1520 | { | ||
1521 | nodeName = reader.Name; | ||
1522 | SOPXmlProcessor p = null; | ||
1523 | if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p)) | ||
1524 | { | ||
1525 | try | ||
1526 | { | ||
1527 | p(obj, reader); | ||
1528 | } | ||
1529 | catch (Exception e) | ||
1530 | { | ||
1531 | m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0} in {1}-{2}: {3}", nodeName, obj.Name, obj.UUID, e); | ||
1532 | } | ||
1533 | } | ||
1534 | else | ||
1535 | { | ||
1536 | m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); | ||
1537 | reader.ReadOuterXml(); // ignore | ||
1538 | } | ||
1539 | |||
1540 | } | ||
1541 | |||
1542 | reader.ReadEndElement(); // SceneObjectPart | ||
1543 | |||
1544 | //m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID); | ||
1545 | return obj; | ||
1546 | } | ||
1547 | |||
1548 | static UUID ReadUUID(XmlTextReader reader, string name) | ||
1549 | { | ||
1550 | UUID id; | ||
1551 | string idStr; | ||
1552 | |||
1553 | reader.ReadStartElement(name); | ||
1554 | |||
1555 | if (reader.Name == "Guid") | ||
1556 | idStr = reader.ReadElementString("Guid"); | ||
1557 | else // UUID | ||
1558 | idStr = reader.ReadElementString("UUID"); | ||
1559 | |||
1560 | UUID.TryParse(idStr, out id); | ||
1561 | reader.ReadEndElement(); | ||
1562 | |||
1563 | return id; | ||
1564 | } | ||
1565 | |||
1566 | static Vector3 ReadVector(XmlTextReader reader, string name) | ||
1567 | { | ||
1568 | Vector3 vec; | ||
1569 | |||
1570 | reader.ReadStartElement(name); | ||
1571 | vec.X = reader.ReadElementContentAsFloat("X", String.Empty); | ||
1572 | vec.Y = reader.ReadElementContentAsFloat("Y", String.Empty); | ||
1573 | vec.Z = reader.ReadElementContentAsFloat("Z", String.Empty); | ||
1574 | reader.ReadEndElement(); | ||
1575 | |||
1576 | return vec; | ||
1577 | } | ||
1578 | |||
1579 | static Quaternion ReadQuaternion(XmlTextReader reader, string name) | ||
1580 | { | ||
1581 | Quaternion quat; | ||
1582 | |||
1583 | reader.ReadStartElement(name); | ||
1584 | quat.X = reader.ReadElementContentAsFloat("X", String.Empty); | ||
1585 | quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty); | ||
1586 | quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty); | ||
1587 | quat.W = reader.ReadElementContentAsFloat("W", String.Empty); | ||
1588 | reader.ReadEndElement(); | ||
1589 | |||
1590 | return quat; | ||
1591 | } | ||
1592 | |||
1593 | static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) | ||
1594 | { | ||
1595 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | ||
1596 | |||
1597 | reader.ReadStartElement(name, String.Empty); | ||
1598 | |||
1599 | while (reader.Name == "TaskInventoryItem") | ||
1600 | { | ||
1601 | reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory | ||
1602 | |||
1603 | TaskInventoryItem item = new TaskInventoryItem(); | ||
1604 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1605 | { | ||
1606 | TaskInventoryXmlProcessor p = null; | ||
1607 | if (m_TaskInventoryXmlProcessors.TryGetValue(reader.Name, out p)) | ||
1608 | p(item, reader); | ||
1609 | else | ||
1610 | { | ||
1611 | m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value); | ||
1612 | reader.ReadOuterXml(); | ||
1613 | } | ||
1614 | } | ||
1615 | reader.ReadEndElement(); // TaskInventoryItem | ||
1616 | tinv.Add(item.ItemID, item); | ||
1617 | |||
1618 | } | ||
1619 | |||
1620 | if (reader.NodeType == XmlNodeType.EndElement) | ||
1621 | reader.ReadEndElement(); // TaskInventory | ||
1622 | |||
1623 | return tinv; | ||
1624 | } | ||
1625 | |||
1626 | static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name) | ||
1627 | { | ||
1628 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
1629 | |||
1630 | reader.ReadStartElement(name, String.Empty); // Shape | ||
1631 | |||
1632 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1633 | { | ||
1634 | ShapeXmlProcessor p = null; | ||
1635 | if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p)) | ||
1636 | p(shape, reader); | ||
1637 | else | ||
1638 | { | ||
1639 | m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name); | ||
1640 | reader.ReadOuterXml(); | ||
1641 | } | ||
1642 | } | ||
1643 | |||
1644 | reader.ReadEndElement(); // Shape | ||
1645 | |||
1646 | return shape; | ||
1647 | } | ||
1648 | |||
1649 | #endregion | ||
297 | } | 1650 | } |
298 | } | 1651 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index 5494549..bb67ca0 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -124,14 +124,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
124 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 124 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
125 | { | 125 | { |
126 | // There is only ever one prim. This oddity should be removeable post 0.5.9 | 126 | // There is only ever one prim. This oddity should be removeable post 0.5.9 |
127 | return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); | 127 | //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); |
128 | using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml))) | ||
129 | { | ||
130 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
131 | if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) | ||
132 | return obj; | ||
133 | |||
134 | return null; | ||
135 | } | ||
128 | } | 136 | } |
129 | 137 | ||
130 | return null; | 138 | return null; |
131 | } | 139 | } |
132 | else | 140 | else |
133 | { | 141 | { |
134 | return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); | 142 | //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); |
143 | using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml))) | ||
144 | { | ||
145 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
146 | if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) | ||
147 | return obj; | ||
148 | |||
149 | return null; | ||
150 | } | ||
135 | } | 151 | } |
136 | } | 152 | } |
137 | 153 | ||
@@ -193,12 +209,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
193 | /// <returns>The scene object created. null if the scene object already existed</returns> | 209 | /// <returns>The scene object created. null if the scene object already existed</returns> |
194 | protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) | 210 | protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) |
195 | { | 211 | { |
196 | SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); | 212 | //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); |
213 | using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData))) | ||
214 | { | ||
215 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
216 | SceneObjectSerializer.Xml2ToSOG(reader, obj); | ||
197 | 217 | ||
198 | if (scene.AddRestoredSceneObject(obj, true, false)) | 218 | if (scene.AddRestoredSceneObject(obj, true, false)) |
199 | return obj; | 219 | return obj; |
200 | else | 220 | else |
201 | return null; | 221 | return null; |
222 | } | ||
202 | } | 223 | } |
203 | 224 | ||
204 | public static void SavePrimsToXml2(Scene scene, string fileName) | 225 | public static void SavePrimsToXml2(Scene scene, string fileName) |