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.
parent
5bf6b24590
commit
2681de366b
|
@ -146,7 +146,6 @@ namespace OpenSim
|
||||||
m_networkServersInfo.loadFromConfiguration(m_config);
|
m_networkServersInfo.loadFromConfiguration(m_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs initialisation of the scene, such as loading configuration from disk.
|
/// Performs initialisation of the scene, such as loading configuration from disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -485,6 +484,28 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "save-xml2":
|
||||||
|
if (cmdparams.Length > 0)
|
||||||
|
{
|
||||||
|
m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "load-xml2":
|
||||||
|
if (cmdparams.Length > 0)
|
||||||
|
{
|
||||||
|
m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "terrain":
|
case "terrain":
|
||||||
if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
|
if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
|
||||||
{
|
{
|
||||||
|
|
|
@ -709,6 +709,64 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
file.Close();
|
file.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadPrimsFromXml2(string fileName)
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
XmlNode rootNode;
|
||||||
|
if ((fileName.StartsWith("http:")) | (File.Exists(fileName)))
|
||||||
|
{
|
||||||
|
XmlTextReader reader = new XmlTextReader(fileName);
|
||||||
|
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||||
|
doc.Load(reader);
|
||||||
|
reader.Close();
|
||||||
|
rootNode = doc.FirstChild;
|
||||||
|
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||||
|
{
|
||||||
|
CreatePrimFromXml(aPrimNode.OuterXml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Could not open file " + fileName + " for reading");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreatePrimFromXml(string xmlData)
|
||||||
|
{
|
||||||
|
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
||||||
|
AddEntityFromStorage(obj);
|
||||||
|
|
||||||
|
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||||
|
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||||
|
rootPart.PhysActor = phyScene.AddPrimShape(
|
||||||
|
rootPart.Name,
|
||||||
|
rootPart.Shape,
|
||||||
|
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
|
||||||
|
rootPart.AbsolutePosition.Z),
|
||||||
|
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
|
||||||
|
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
|
||||||
|
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SavePrimsToXml2(string fileName)
|
||||||
|
{
|
||||||
|
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||||
|
StreamWriter stream = new StreamWriter(file);
|
||||||
|
int primCount = 0;
|
||||||
|
stream.WriteLine("<scene>\n");
|
||||||
|
foreach (EntityBase ent in Entities.Values)
|
||||||
|
{
|
||||||
|
if (ent is SceneObjectGroup)
|
||||||
|
{
|
||||||
|
stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2());
|
||||||
|
primCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.WriteLine("</scene>\n");
|
||||||
|
stream.Close();
|
||||||
|
file.Close();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Add/Remove Avatar Methods
|
#region Add/Remove Avatar Methods
|
||||||
|
|
|
@ -85,6 +85,16 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public void LoadCurrentSceneFromXml(string filename)
|
public void LoadCurrentSceneFromXml(string filename)
|
||||||
{
|
{
|
||||||
CurrentOrFirstScene.LoadPrimsFromXml(filename);
|
CurrentOrFirstScene.LoadPrimsFromXml(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveCurrentSceneToXml2(string filename)
|
||||||
|
{
|
||||||
|
CurrentOrFirstScene.SavePrimsToXml2(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadCurrentSceneFromXml2(string filename)
|
||||||
|
{
|
||||||
|
CurrentOrFirstScene.LoadPrimsFromXml2(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
|
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
|
||||||
|
|
|
@ -272,7 +272,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
reader.Read();
|
reader.Read();
|
||||||
|
|
||||||
reader.ReadStartElement("SceneObjectGroup");
|
reader.ReadStartElement("SceneObjectGroup");
|
||||||
// reader.ReadStartElement("RootPart");
|
|
||||||
m_rootPart = SceneObjectPart.FromXml(reader);
|
m_rootPart = SceneObjectPart.FromXml(reader);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
|
@ -286,8 +285,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (reader.Name == "SceneObjectPart")
|
if (reader.Name == "SceneObjectPart")
|
||||||
{
|
{
|
||||||
SceneObjectPart Part = SceneObjectPart.FromXml(reader);
|
SceneObjectPart Part = SceneObjectPart.FromXml(reader);
|
||||||
AddPart(Part);
|
AddPart(Part);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XmlNodeType.EndElement:
|
case XmlNodeType.EndElement:
|
||||||
|
@ -375,6 +373,35 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ToXmlString2()
|
||||||
|
{
|
||||||
|
using (StringWriter sw = new StringWriter())
|
||||||
|
{
|
||||||
|
using (XmlTextWriter writer = new XmlTextWriter(sw))
|
||||||
|
{
|
||||||
|
ToXml2(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sw.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToXml2(XmlTextWriter writer)
|
||||||
|
{
|
||||||
|
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
|
||||||
|
m_rootPart.ToXml(writer);
|
||||||
|
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
|
||||||
|
foreach (SceneObjectPart part in m_parts.Values)
|
||||||
|
{
|
||||||
|
if (part.UUID != m_rootPart.UUID)
|
||||||
|
{
|
||||||
|
part.ToXml(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.WriteEndElement();
|
||||||
|
writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
#region Copying
|
#region Copying
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue