aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-30 17:52:14 +0000
committerJustin Clarke Casey2008-05-30 17:52:14 +0000
commit4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307 (patch)
tree728db0e5d0691b553b8ebe4e5a13560c4657c7e2 /OpenSim/Region/Environment/Scenes
parentMantis#1422. Thank you kindly, Xantor for your llLoopSound() (diff)
downloadopensim-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 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs30
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs238
2 files changed, 19 insertions, 249 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index c1e8602..26f3499 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
42using OpenSim.Region.Environment.Interfaces; 42using OpenSim.Region.Environment.Interfaces;
43using OpenSim.Region.Environment.Modules.World.Archiver; 43using OpenSim.Region.Environment.Modules.World.Archiver;
44using OpenSim.Region.Environment.Modules.World.Serialiser;
44using OpenSim.Region.Environment.Modules.World.Terrain; 45using OpenSim.Region.Environment.Modules.World.Terrain;
45using OpenSim.Region.Environment.Scenes.Scripting; 46using OpenSim.Region.Environment.Scenes.Scripting;
46using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.Physics.Manager;
@@ -94,7 +95,6 @@ namespace OpenSim.Region.Environment.Scenes
94 public CommunicationsManager CommsManager; 95 public CommunicationsManager CommsManager;
95 96
96 protected SceneCommunicationService m_sceneGridService; 97 protected SceneCommunicationService m_sceneGridService;
97 protected SceneXmlLoader m_sceneXmlLoader;
98 98
99 /// <summary> 99 /// <summary>
100 /// Each agent has its own capabilities handler. 100 /// Each agent has its own capabilities handler.
@@ -268,8 +268,6 @@ namespace OpenSim.Region.Environment.Scenes
268 // Operating system has killed the plugin 268 // Operating system has killed the plugin
269 m_innerScene.UnRecoverableError += RestartNow; 269 m_innerScene.UnRecoverableError += RestartNow;
270 270
271 m_sceneXmlLoader = new SceneXmlLoader(this, m_innerScene, m_regInfo);
272
273 RegisterDefaultSceneEvents(); 271 RegisterDefaultSceneEvents();
274 272
275 m_httpListener = httpServer; 273 m_httpListener = httpServer;
@@ -1400,22 +1398,26 @@ namespace OpenSim.Region.Environment.Scenes
1400 1398
1401 public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) 1399 public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset)
1402 { 1400 {
1403 m_sceneXmlLoader.LoadPrimsFromXml(fileName, newIdsFlag, loadOffset); 1401 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1402 loader.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset);
1404 } 1403 }
1405 1404
1406 public void SavePrimsToXml(string fileName) 1405 public void SavePrimsToXml(string fileName)
1407 { 1406 {
1408 m_sceneXmlLoader.SavePrimsToXml(fileName); 1407 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1408 loader.SavePrimsToXml(this, fileName);
1409 } 1409 }
1410 1410
1411 public void LoadPrimsFromXml2(string fileName) 1411 public void LoadPrimsFromXml2(string fileName)
1412 { 1412 {
1413 m_sceneXmlLoader.LoadPrimsFromXml2(fileName); 1413 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1414 loader.LoadPrimsFromXml2(this, fileName);
1414 } 1415 }
1415 1416
1416 public void SavePrimsToXml2(string fileName) 1417 public void SavePrimsToXml2(string fileName)
1417 { 1418 {
1418 m_sceneXmlLoader.SavePrimsToXml2(fileName); 1419 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1420 loader.SavePrimsToXml2(this, fileName);
1419 } 1421 }
1420 1422
1421 /// <summary> 1423 /// <summary>
@@ -1505,15 +1507,20 @@ namespace OpenSim.Region.Environment.Scenes
1505 grp.OffsetForNewRegion(pos); 1507 grp.OffsetForNewRegion(pos);
1506 1508
1507 CrossPrimGroupIntoNewRegion(newRegionHandle, grp); 1509 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1508
1509 } 1510 }
1511
1510 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) 1512 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp)
1511 { 1513 {
1512 int primcrossingXMLmethod = 0; 1514 int primcrossingXMLmethod = 0;
1513 if (newRegionHandle != 0) 1515 if (newRegionHandle != 0)
1514 { 1516 {
1515 bool successYN = false; 1517 bool successYN = false;
1516 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod); 1518
1519 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1520 successYN
1521 = m_sceneGridService.PrimCrossToNeighboringRegion(
1522 newRegionHandle, grp.UUID, loader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod);
1523
1517 if (successYN) 1524 if (successYN)
1518 { 1525 {
1519 // We remove the object here 1526 // We remove the object here
@@ -1545,7 +1552,9 @@ namespace OpenSim.Region.Environment.Scenes
1545 m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); 1552 m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor");
1546 if (XMLMethod == 0) 1553 if (XMLMethod == 0)
1547 { 1554 {
1548 m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); 1555 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1556 loader.LoadGroupFromXml2String(this, objXMLData);
1557
1549 SceneObjectPart RootPrim = GetSceneObjectPart(primID); 1558 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
1550 if (RootPrim != null) 1559 if (RootPrim != null)
1551 { 1560 {
@@ -3025,7 +3034,6 @@ namespace OpenSim.Region.Environment.Scenes
3025 3034
3026 public bool pipeEventsForScript(uint localID) 3035 public bool pipeEventsForScript(uint localID)
3027 { 3036 {
3028
3029 SceneObjectPart part = GetSceneObjectPart(localID); 3037 SceneObjectPart part = GetSceneObjectPart(localID);
3030 if (part != null) 3038 if (part != null)
3031 { 3039 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
deleted file mode 100644
index 742996e..0000000
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ /dev/null
@@ -1,238 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Xml;
32using Axiom.Math;
33using libsecondlife;
34using OpenSim.Framework;
35using OpenSim.Region.Physics.Manager;
36
37namespace OpenSim.Region.Environment.Scenes
38{
39 public class SceneXmlLoader // can move to a module?
40 {
41 protected InnerScene m_innerScene;
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 {
54 XmlDocument doc = new XmlDocument();
55 XmlNode rootNode;
56 int primCount = 0;
57 if (fileName.StartsWith("http:") || File.Exists(fileName))
58 {
59 XmlTextReader reader = new XmlTextReader(fileName);
60 reader.WhitespaceHandling = WhitespaceHandling.None;
61 doc.Load(reader);
62 reader.Close();
63 rootNode = doc.FirstChild;
64 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
65 {
66 SceneObjectGroup obj = new SceneObjectGroup(m_parentScene,
67 m_regInfo.RegionHandle, aPrimNode.OuterXml);
68 if (newIDS)
69 {
70 obj.ResetIDs();
71 }
72 //if we want this to be a import method then we need new uuids for the object to avoid any clashes
73 //obj.RegenerateFullIDs();
74
75 m_innerScene.AddSceneObject(obj);
76
77 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
78 // Apply loadOffsets for load/import and move combinations
79 rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
80 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
81 m_parentScene.m_physicalPrim);
82 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
83 {
84 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
85 rootPart.Name,
86 rootPart.Shape,
87 new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X,
88 rootPart.AbsolutePosition.Y + loadOffset.Y,
89 rootPart.AbsolutePosition.Z + loadOffset.Z),
90 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
91 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
92 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
93
94 // to quote from SceneObjectPart: Basic
95 // Physics returns null.. joy joy joy.
96 if (rootPart.PhysActor != null)
97 {
98 rootPart.PhysActor.LocalID = rootPart.LocalId;
99 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
100 }
101 }
102 primCount++;
103 }
104 }
105 else
106 {
107 throw new Exception("Could not open file " + fileName + " for reading");
108 }
109 }
110
111 public void SavePrimsToXml(string fileName)
112 {
113 FileStream file = new FileStream(fileName, FileMode.Create);
114 StreamWriter stream = new StreamWriter(file);
115 int primCount = 0;
116 stream.WriteLine("<scene>\n");
117
118 List<EntityBase> EntityList = m_innerScene.GetEntities();
119
120 foreach (EntityBase ent in EntityList)
121 {
122 if (ent is SceneObjectGroup)
123 {
124 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
125 primCount++;
126 }
127 }
128 stream.WriteLine("</scene>\n");
129 stream.Close();
130 file.Close();
131 }
132
133 public string SavePrimGroupToXML2String(SceneObjectGroup grp)
134 {
135 string returnstring = "";
136 returnstring += "<scene>\n";
137 returnstring += grp.ToXmlString2();
138 returnstring += "</scene>\n";
139 return returnstring;
140
141 }
142
143 public void LoadGroupFromXml2String(string xmlString)
144 {
145 XmlDocument doc = new XmlDocument();
146 XmlNode rootNode;
147
148 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
149 reader.WhitespaceHandling = WhitespaceHandling.None;
150 doc.Load(reader);
151 reader.Close();
152 rootNode = doc.FirstChild;
153 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
154 {
155 CreatePrimFromXml(aPrimNode.OuterXml);
156 }
157
158 }
159
160 public void LoadPrimsFromXml2(string fileName)
161 {
162 XmlDocument doc = new XmlDocument();
163 XmlNode rootNode;
164 if (fileName.StartsWith("http:") || File.Exists(fileName))
165 {
166 XmlTextReader reader = new XmlTextReader(fileName);
167 reader.WhitespaceHandling = WhitespaceHandling.None;
168 doc.Load(reader);
169 reader.Close();
170 rootNode = doc.FirstChild;
171 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
172 {
173 CreatePrimFromXml(aPrimNode.OuterXml);
174 }
175 }
176 else
177 {
178 throw new Exception("Could not open file " + fileName + " for reading");
179 }
180 }
181
182 public void CreatePrimFromXml(string xmlData)
183 {
184 SceneObjectGroup obj = new SceneObjectGroup(xmlData);
185 LLVector3 receivedVelocity = obj.RootPart.Velocity;
186 //System.Console.WriteLine(obj.RootPart.Velocity.ToString());
187 m_innerScene.AddSceneObjectFromStorage(obj);
188
189 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
190 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
191 m_parentScene.m_physicalPrim);
192 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
193 {
194 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
195 rootPart.Name,
196 rootPart.Shape,
197 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
198 rootPart.AbsolutePosition.Z),
199 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
200 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
201 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
202
203 // to quote from SceneObjectPart: Basic
204 // Physics returns null.. joy joy joy.
205 if (rootPart.PhysActor != null)
206 {
207 rootPart.PhysActor.LocalID = rootPart.LocalId;
208 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
209 }
210 rootPart.Velocity = receivedVelocity;
211 }
212
213 obj.ScheduleGroupForFullUpdate();
214 }
215
216 public void SavePrimsToXml2(string fileName)
217 {
218 FileStream file = new FileStream(fileName, FileMode.Create);
219 StreamWriter stream = new StreamWriter(file);
220 int primCount = 0;
221 stream.WriteLine("<scene>\n");
222
223 List<EntityBase> EntityList = m_innerScene.GetEntities();
224
225 foreach (EntityBase ent in EntityList)
226 {
227 if (ent is SceneObjectGroup)
228 {
229 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2());
230 primCount++;
231 }
232 }
233 stream.WriteLine("</scene>\n");
234 stream.Close();
235 file.Close();
236 }
237 }
238}