diff options
author | Justin Clarke Casey | 2008-05-30 17:52:14 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-30 17:52:14 +0000 |
commit | 4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307 (patch) | |
tree | 728db0e5d0691b553b8ebe4e5a13560c4657c7e2 /OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs | |
parent | Mantis#1422. Thank you kindly, Xantor for your llLoopSound() (diff) | |
download | opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.zip opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.gz opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.bz2 opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.xz |
* Crudely migrate SceneXmlLoader into the Serializer module
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs (renamed from OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs) | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 742996e..7f51b58 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs | |||
@@ -36,20 +36,12 @@ using OpenSim.Region.Physics.Manager; | |||
36 | 36 | ||
37 | namespace OpenSim.Region.Environment.Scenes | 37 | namespace OpenSim.Region.Environment.Scenes |
38 | { | 38 | { |
39 | public class SceneXmlLoader // can move to a module? | 39 | /// <summary> |
40 | /// Static methods to serialize and deserialize scene objects to and from XML | ||
41 | /// </summary> | ||
42 | public class SceneXmlLoader | ||
40 | { | 43 | { |
41 | protected InnerScene m_innerScene; | 44 | public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset) |
42 | protected RegionInfo m_regInfo; | ||
43 | protected Scene m_parentScene; | ||
44 | |||
45 | public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo) | ||
46 | { | ||
47 | m_parentScene = parentScene; | ||
48 | m_innerScene = innerScene; | ||
49 | m_regInfo = regionInfo; | ||
50 | } | ||
51 | |||
52 | public void LoadPrimsFromXml(string fileName, bool newIDS, LLVector3 loadOffset) | ||
53 | { | 45 | { |
54 | XmlDocument doc = new XmlDocument(); | 46 | XmlDocument doc = new XmlDocument(); |
55 | XmlNode rootNode; | 47 | XmlNode rootNode; |
@@ -63,8 +55,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
63 | rootNode = doc.FirstChild; | 55 | rootNode = doc.FirstChild; |
64 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 56 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
65 | { | 57 | { |
66 | SceneObjectGroup obj = new SceneObjectGroup(m_parentScene, | 58 | SceneObjectGroup obj = new SceneObjectGroup(scene, scene.RegionInfo.RegionHandle, aPrimNode.OuterXml); |
67 | m_regInfo.RegionHandle, aPrimNode.OuterXml); | 59 | |
68 | if (newIDS) | 60 | if (newIDS) |
69 | { | 61 | { |
70 | obj.ResetIDs(); | 62 | obj.ResetIDs(); |
@@ -72,16 +64,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
72 | //if we want this to be a import method then we need new uuids for the object to avoid any clashes | 64 | //if we want this to be a import method then we need new uuids for the object to avoid any clashes |
73 | //obj.RegenerateFullIDs(); | 65 | //obj.RegenerateFullIDs(); |
74 | 66 | ||
75 | m_innerScene.AddSceneObject(obj); | 67 | scene.AddSceneObject(obj); |
76 | 68 | ||
77 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | 69 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); |
78 | // Apply loadOffsets for load/import and move combinations | 70 | // Apply loadOffsets for load/import and move combinations |
79 | rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; | 71 | rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; |
80 | bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && | 72 | bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && |
81 | m_parentScene.m_physicalPrim); | 73 | scene.m_physicalPrim); |
82 | if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) | 74 | if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) |
83 | { | 75 | { |
84 | rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( | 76 | rootPart.PhysActor = scene.PhysicsScene.AddPrimShape( |
85 | rootPart.Name, | 77 | rootPart.Name, |
86 | rootPart.Shape, | 78 | rootPart.Shape, |
87 | new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X, | 79 | new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X, |
@@ -108,14 +100,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
108 | } | 100 | } |
109 | } | 101 | } |
110 | 102 | ||
111 | public void SavePrimsToXml(string fileName) | 103 | public static void SavePrimsToXml(Scene scene, string fileName) |
112 | { | 104 | { |
113 | FileStream file = new FileStream(fileName, FileMode.Create); | 105 | FileStream file = new FileStream(fileName, FileMode.Create); |
114 | StreamWriter stream = new StreamWriter(file); | 106 | StreamWriter stream = new StreamWriter(file); |
115 | int primCount = 0; | 107 | int primCount = 0; |
116 | stream.WriteLine("<scene>\n"); | 108 | stream.WriteLine("<scene>\n"); |
117 | 109 | ||
118 | List<EntityBase> EntityList = m_innerScene.GetEntities(); | 110 | List<EntityBase> EntityList = scene.GetEntities(); |
119 | 111 | ||
120 | foreach (EntityBase ent in EntityList) | 112 | foreach (EntityBase ent in EntityList) |
121 | { | 113 | { |
@@ -130,17 +122,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
130 | file.Close(); | 122 | file.Close(); |
131 | } | 123 | } |
132 | 124 | ||
133 | public string SavePrimGroupToXML2String(SceneObjectGroup grp) | 125 | public static string SavePrimGroupToXML2String(SceneObjectGroup grp) |
134 | { | 126 | { |
135 | string returnstring = ""; | 127 | string returnstring = ""; |
136 | returnstring += "<scene>\n"; | 128 | returnstring += "<scene>\n"; |
137 | returnstring += grp.ToXmlString2(); | 129 | returnstring += grp.ToXmlString2(); |
138 | returnstring += "</scene>\n"; | 130 | returnstring += "</scene>\n"; |
139 | return returnstring; | 131 | return returnstring; |
140 | |||
141 | } | 132 | } |
142 | 133 | ||
143 | public void LoadGroupFromXml2String(string xmlString) | 134 | public static void LoadGroupFromXml2String(Scene scene, string xmlString) |
144 | { | 135 | { |
145 | XmlDocument doc = new XmlDocument(); | 136 | XmlDocument doc = new XmlDocument(); |
146 | XmlNode rootNode; | 137 | XmlNode rootNode; |
@@ -152,12 +143,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
152 | rootNode = doc.FirstChild; | 143 | rootNode = doc.FirstChild; |
153 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 144 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
154 | { | 145 | { |
155 | CreatePrimFromXml(aPrimNode.OuterXml); | 146 | CreatePrimFromXml(scene, aPrimNode.OuterXml); |
156 | } | 147 | } |
157 | |||
158 | } | 148 | } |
159 | 149 | ||
160 | public void LoadPrimsFromXml2(string fileName) | 150 | public static void LoadPrimsFromXml2(Scene scene, string fileName) |
161 | { | 151 | { |
162 | XmlDocument doc = new XmlDocument(); | 152 | XmlDocument doc = new XmlDocument(); |
163 | XmlNode rootNode; | 153 | XmlNode rootNode; |
@@ -170,7 +160,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
170 | rootNode = doc.FirstChild; | 160 | rootNode = doc.FirstChild; |
171 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 161 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
172 | { | 162 | { |
173 | CreatePrimFromXml(aPrimNode.OuterXml); | 163 | CreatePrimFromXml(scene, aPrimNode.OuterXml); |
174 | } | 164 | } |
175 | } | 165 | } |
176 | else | 166 | else |
@@ -179,19 +169,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
179 | } | 169 | } |
180 | } | 170 | } |
181 | 171 | ||
182 | public void CreatePrimFromXml(string xmlData) | 172 | public static void CreatePrimFromXml(Scene scene, string xmlData) |
183 | { | 173 | { |
184 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | 174 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); |
185 | LLVector3 receivedVelocity = obj.RootPart.Velocity; | 175 | LLVector3 receivedVelocity = obj.RootPart.Velocity; |
186 | //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); | 176 | //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); |
187 | m_innerScene.AddSceneObjectFromStorage(obj); | 177 | scene.AddSceneObjectFromStorage(obj); |
188 | 178 | ||
189 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | 179 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); |
190 | bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && | 180 | bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && |
191 | m_parentScene.m_physicalPrim); | 181 | scene.m_physicalPrim); |
192 | if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) | 182 | if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) |
193 | { | 183 | { |
194 | rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( | 184 | rootPart.PhysActor = scene.PhysicsScene.AddPrimShape( |
195 | rootPart.Name, | 185 | rootPart.Name, |
196 | rootPart.Shape, | 186 | rootPart.Shape, |
197 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | 187 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, |
@@ -213,14 +203,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
213 | obj.ScheduleGroupForFullUpdate(); | 203 | obj.ScheduleGroupForFullUpdate(); |
214 | } | 204 | } |
215 | 205 | ||
216 | public void SavePrimsToXml2(string fileName) | 206 | public static void SavePrimsToXml2(Scene scene, string fileName) |
217 | { | 207 | { |
218 | FileStream file = new FileStream(fileName, FileMode.Create); | 208 | FileStream file = new FileStream(fileName, FileMode.Create); |
219 | StreamWriter stream = new StreamWriter(file); | 209 | StreamWriter stream = new StreamWriter(file); |
220 | int primCount = 0; | 210 | int primCount = 0; |
221 | stream.WriteLine("<scene>\n"); | 211 | stream.WriteLine("<scene>\n"); |
222 | 212 | ||
223 | List<EntityBase> EntityList = m_innerScene.GetEntities(); | 213 | List<EntityBase> EntityList = scene.GetEntities(); |
224 | 214 | ||
225 | foreach (EntityBase ent in EntityList) | 215 | foreach (EntityBase ent in EntityList) |
226 | { | 216 | { |