diff options
Made some changes to the load/save xml format, So that the old format can still be used, I have added new console commands of "load-xml2" and "save-xml2", if the old versions worked for you then please continue using them (at least for now). The new versions haven't been tested that much, so their format could be subject to change.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f7e3543..553e55f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -709,6 +709,64 @@ namespace OpenSim.Region.Environment.Scenes | |||
709 | file.Close(); | 709 | file.Close(); |
710 | } | 710 | } |
711 | 711 | ||
712 | public void LoadPrimsFromXml2(string fileName) | ||
713 | { | ||
714 | XmlDocument doc = new XmlDocument(); | ||
715 | XmlNode rootNode; | ||
716 | if ((fileName.StartsWith("http:")) | (File.Exists(fileName))) | ||
717 | { | ||
718 | XmlTextReader reader = new XmlTextReader(fileName); | ||
719 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
720 | doc.Load(reader); | ||
721 | reader.Close(); | ||
722 | rootNode = doc.FirstChild; | ||
723 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
724 | { | ||
725 | CreatePrimFromXml(aPrimNode.OuterXml); | ||
726 | } | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
731 | } | ||
732 | } | ||
733 | |||
734 | public void CreatePrimFromXml(string xmlData) | ||
735 | { | ||
736 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | ||
737 | AddEntityFromStorage(obj); | ||
738 | |||
739 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
740 | if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) | ||
741 | rootPart.PhysActor = phyScene.AddPrimShape( | ||
742 | rootPart.Name, | ||
743 | rootPart.Shape, | ||
744 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
745 | rootPart.AbsolutePosition.Z), | ||
746 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
747 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
748 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); | ||
749 | } | ||
750 | |||
751 | public void SavePrimsToXml2(string fileName) | ||
752 | { | ||
753 | FileStream file = new FileStream(fileName, FileMode.Create); | ||
754 | StreamWriter stream = new StreamWriter(file); | ||
755 | int primCount = 0; | ||
756 | stream.WriteLine("<scene>\n"); | ||
757 | foreach (EntityBase ent in Entities.Values) | ||
758 | { | ||
759 | if (ent is SceneObjectGroup) | ||
760 | { | ||
761 | stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); | ||
762 | primCount++; | ||
763 | } | ||
764 | } | ||
765 | stream.WriteLine("</scene>\n"); | ||
766 | stream.Close(); | ||
767 | file.Close(); | ||
768 | } | ||
769 | |||
712 | #endregion | 770 | #endregion |
713 | 771 | ||
714 | #region Add/Remove Avatar Methods | 772 | #region Add/Remove Avatar Methods |