Some more refactoring
parent
1467720f60
commit
d56ed8fe9c
|
@ -34,5 +34,6 @@ namespace OpenSim.Framework.Communications
|
|||
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
|
||||
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
|
||||
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId);
|
||||
void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID);
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ namespace OpenSim.Framework
|
|||
void RemoveClient(LLUUID agentID);
|
||||
|
||||
RegionInfo RegionInfo { get; }
|
||||
object SyncRoot { get; }
|
||||
uint NextLocalId { get; }
|
||||
|
||||
ClientManager ClientManager { get; }
|
||||
|
|
|
@ -178,6 +178,14 @@ namespace OpenSim.Region.Communications.Local
|
|||
return false;
|
||||
}
|
||||
|
||||
public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID)
|
||||
{
|
||||
if (m_regionListeners.ContainsKey(regionHandle))
|
||||
{
|
||||
// m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId)
|
||||
{
|
||||
if (m_regionListeners.ContainsKey(regionHandle))
|
||||
|
|
|
@ -472,6 +472,11 @@ namespace OpenSim.Region.Communications.OGS1
|
|||
}
|
||||
}
|
||||
|
||||
public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId)
|
||||
{
|
||||
return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
@ -12,6 +12,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
public class InnerScene
|
||||
{
|
||||
#region Fields
|
||||
public Dictionary<LLUUID, ScenePresence> ScenePresences;
|
||||
public Dictionary<LLUUID, SceneObjectGroup> SceneObjects;
|
||||
public Dictionary<LLUUID, EntityBase> Entities;
|
||||
|
@ -19,11 +20,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
public BasicQuadTreeNode QuadTree;
|
||||
|
||||
protected RegionInfo m_regInfo;
|
||||
|
||||
protected Scene m_parentScene;
|
||||
public PhysicsScene PhyScene;
|
||||
protected PermissionManager PermissionsMngr;
|
||||
|
||||
private PermissionManager PermissionsMngr;
|
||||
internal object m_syncRoot = new object();
|
||||
|
||||
public PhysicsScene PhyScene;
|
||||
#endregion
|
||||
|
||||
public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr)
|
||||
{
|
||||
|
@ -42,6 +45,51 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
Entities.Clear();
|
||||
}
|
||||
|
||||
#region Update Methods
|
||||
internal void UpdatePreparePhysics()
|
||||
{
|
||||
// If we are using a threaded physics engine
|
||||
// grab the latest scene from the engine before
|
||||
// trying to process it.
|
||||
|
||||
// PhysX does this (runs in the background).
|
||||
|
||||
if (PhyScene.IsThreaded)
|
||||
{
|
||||
PhyScene.GetResults();
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateEntities()
|
||||
{
|
||||
List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values);
|
||||
|
||||
foreach (EntityBase entity in updateEntities)
|
||||
{
|
||||
entity.Update();
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdatePhysics(double elapsed)
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
{
|
||||
PhyScene.Simulate((float)elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateEntityMovement()
|
||||
{
|
||||
List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
|
||||
|
||||
foreach (EntityBase entity in moveEntities)
|
||||
{
|
||||
entity.UpdateMovement();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Entity Methods
|
||||
public void AddEntityFromStorage(SceneObjectGroup sceneObject)
|
||||
{
|
||||
sceneObject.RegionHandle = m_regInfo.RegionHandle;
|
||||
|
@ -122,6 +170,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
return newAvatar;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Get Methods
|
||||
|
||||
/// <summary>
|
||||
/// Request a List of all m_scenePresences in this World
|
||||
|
@ -175,35 +226,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public LLUUID ConvertLocalIDToFullID(uint localID)
|
||||
{
|
||||
bool hasPrim = false;
|
||||
foreach (EntityBase ent in Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
|
||||
if (hasPrim != false)
|
||||
{
|
||||
return ((SceneObjectGroup)ent).GetPartsFullID(localID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
public void SendAllSceneObjectsToClient(ScenePresence presence)
|
||||
{
|
||||
foreach (EntityBase ent in Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SceneObjectPart GetSceneObjectPart(uint localID)
|
||||
{
|
||||
bool hasPrim = false;
|
||||
|
@ -274,6 +296,37 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Other Methods
|
||||
|
||||
public LLUUID ConvertLocalIDToFullID(uint localID)
|
||||
{
|
||||
bool hasPrim = false;
|
||||
foreach (EntityBase ent in Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
|
||||
if (hasPrim != false)
|
||||
{
|
||||
return ((SceneObjectGroup)ent).GetPartsFullID(localID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
public void SendAllSceneObjectsToClient(ScenePresence presence)
|
||||
{
|
||||
foreach (EntityBase ent in Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ForEachClient(Action<IClientAPI> action)
|
||||
{
|
||||
|
@ -282,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
action(presence.ControllingClient);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Client Event handlers
|
||||
/// <summary>
|
||||
|
@ -307,7 +361,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -395,7 +448,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -653,3 +705,4 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
public CommunicationsManager CommsManager;
|
||||
// protected XferManager xferManager;
|
||||
protected SceneCommunicationService m_sceneGridService;
|
||||
protected SceneXmlLoader m_sceneXmlLoader;
|
||||
|
||||
protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
|
||||
protected BaseHttpServer httpListener;
|
||||
|
@ -140,6 +141,11 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
get { return (m_innerScene.PhyScene); }
|
||||
}
|
||||
|
||||
public object SyncRoot
|
||||
{
|
||||
get { return m_innerScene.m_syncRoot; }
|
||||
}
|
||||
|
||||
public EstateManager EstateManager
|
||||
{
|
||||
get { return m_estateManager; }
|
||||
|
@ -207,7 +213,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
m_eventManager = new EventManager();
|
||||
m_permissionManager = new PermissionManager(this);
|
||||
|
||||
m_innerScene = new InnerScene(this, regInfo, m_permissionManager);
|
||||
m_innerScene = new InnerScene(this, m_regInfo, m_permissionManager);
|
||||
m_sceneXmlLoader = new SceneXmlLoader(this, m_innerScene, m_regInfo);
|
||||
|
||||
m_eventManager.OnParcelPrimCountAdd +=
|
||||
m_LandManager.addPrimToLandPrimCounts;
|
||||
|
@ -292,18 +299,18 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
m_frame = 0;
|
||||
|
||||
if (m_frame%m_update_physics == 0)
|
||||
UpdatePreparePhysics();
|
||||
m_innerScene.UpdatePreparePhysics();
|
||||
|
||||
if (m_frame%m_update_entitymovement == 0)
|
||||
UpdateEntityMovement();
|
||||
m_innerScene.UpdateEntityMovement();
|
||||
|
||||
if (m_frame%m_update_physics == 0)
|
||||
UpdatePhysics(
|
||||
m_innerScene.UpdatePhysics(
|
||||
Math.Max(SinceLastFrame.TotalSeconds, m_timespan)
|
||||
);
|
||||
|
||||
if (m_frame%m_update_entities == 0)
|
||||
UpdateEntities();
|
||||
m_innerScene.UpdateEntities();
|
||||
|
||||
if (m_frame%m_update_events == 0)
|
||||
UpdateEvents();
|
||||
|
@ -337,20 +344,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdatePreparePhysics()
|
||||
{
|
||||
// If we are using a threaded physics engine
|
||||
// grab the latest scene from the engine before
|
||||
// trying to process it.
|
||||
|
||||
// PhysX does this (runs in the background).
|
||||
|
||||
if (phyScene.IsThreaded)
|
||||
{
|
||||
phyScene.GetResults();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateInWorldTime()
|
||||
{
|
||||
m_timeUpdateCount++;
|
||||
|
@ -388,7 +381,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
lock (Terrain.heightmap)
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
lock (SyncRoot)
|
||||
{
|
||||
phyScene.SetTerrain(Terrain.GetHeights1D());
|
||||
}
|
||||
|
@ -427,34 +420,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
m_eventManager.TriggerOnFrame();
|
||||
}
|
||||
|
||||
private void UpdateEntities()
|
||||
{
|
||||
List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values);
|
||||
|
||||
foreach (EntityBase entity in updateEntities)
|
||||
{
|
||||
entity.Update();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePhysics(double elapsed)
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
{
|
||||
phyScene.Simulate((float) elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEntityMovement()
|
||||
{
|
||||
List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
|
||||
|
||||
foreach (EntityBase entity in moveEntities)
|
||||
{
|
||||
entity.UpdateMovement();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform delegate action on all clients subscribing to updates from this region.
|
||||
/// </summary>
|
||||
|
@ -655,120 +620,22 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public void LoadPrimsFromXml(string fileName)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
int primCount = 0;
|
||||
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)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(this,
|
||||
m_regionHandle, aPrimNode.OuterXml);
|
||||
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
|
||||
//obj.RegenerateFullIDs();
|
||||
AddEntity(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0);
|
||||
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), UsePhysics);
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
m_sceneXmlLoader.LoadPrimsFromXml(fileName);
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(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).ToXmlString());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
m_sceneXmlLoader.SavePrimsToXml(fileName);
|
||||
}
|
||||
|
||||
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);
|
||||
bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0);
|
||||
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), UsePhysics);
|
||||
m_sceneXmlLoader.LoadPrimsFromXml2(fileName);
|
||||
}
|
||||
|
||||
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();
|
||||
m_sceneXmlLoader.SavePrimsToXml2(fileName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
get { return m_clientManager; }
|
||||
}
|
||||
|
||||
// public Dictionary<LLUUID, EntityBase> Entities;
|
||||
protected ulong m_regionHandle;
|
||||
protected string m_regionName;
|
||||
protected RegionInfo m_regInfo;
|
||||
|
@ -66,7 +65,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
protected string m_datastore;
|
||||
|
||||
protected object m_syncRoot = new object();
|
||||
private uint m_nextLocalId = 8880000;
|
||||
private AssetCache m_assetCache;
|
||||
|
||||
|
@ -132,11 +130,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
get { return m_regInfo; }
|
||||
}
|
||||
|
||||
public object SyncRoot
|
||||
{
|
||||
get { return m_syncRoot; }
|
||||
}
|
||||
|
||||
public uint NextLocalId
|
||||
{
|
||||
get { return m_nextLocalId++; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
@ -204,9 +204,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying);
|
||||
}
|
||||
|
||||
public void CloseAgentConnection(ScenePresence presence)
|
||||
public void CloseChildAgentConnections(ScenePresence presence)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using libsecondlife;
|
||||
using Axiom.Math;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
public class SceneXmlLoader //Most likely can move to a module
|
||||
{
|
||||
protected InnerScene m_innerScene;
|
||||
protected RegionInfo m_regInfo;
|
||||
protected Scene m_parentScene;
|
||||
|
||||
public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
|
||||
{
|
||||
m_parentScene = parentScene;
|
||||
m_innerScene = innerScene;
|
||||
m_regInfo = regionInfo;
|
||||
}
|
||||
|
||||
public void LoadPrimsFromXml(string fileName)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootNode;
|
||||
int primCount = 0;
|
||||
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)
|
||||
{
|
||||
SceneObjectGroup obj = new SceneObjectGroup(m_parentScene,
|
||||
m_regInfo.RegionHandle, aPrimNode.OuterXml);
|
||||
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
|
||||
//obj.RegenerateFullIDs();
|
||||
m_innerScene.AddEntity(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0);
|
||||
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||
rootPart.PhysActor = m_innerScene.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), UsePhysics);
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not open file " + fileName + " for reading");
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePrimsToXml(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 m_innerScene.Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup)ent).ToXmlString());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.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);
|
||||
m_innerScene.AddEntityFromStorage(obj);
|
||||
|
||||
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
|
||||
bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0);
|
||||
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
|
||||
rootPart.PhysActor = m_innerScene.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), UsePhysics);
|
||||
}
|
||||
|
||||
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 m_innerScene.Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2());
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Close();
|
||||
file.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue