29 using System.Collections.Generic;
30 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Region.DataSnapshot.Interfaces;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.Framework.Scenes;
39 namespace OpenSim.
Region.DataSnapshot.Providers
43 private Scene m_scene = null;
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private bool m_stale =
true;
48 private static UUID m_DefaultImage =
new UUID(
"89556747-24cb-43ed-920b-47caed15465f");
49 private static UUID m_BlankImage =
new UUID(
"5748decc-f629-461c-9a36-a35a221fe21f");
58 m_scene.EventManager.OnNewClient += OnNewClient;
59 m_scene.EventManager.OnParcelPrimCountAdd += delegate(
SceneObjectGroup obj) { this.Stale =
true; };
67 client.OnAddPrim += delegate (
UUID ownerID,
UUID groupID, Vector3 RayEnd, Quaternion rot,
69 byte RayEndIsIntersection) { this.Stale =
true; };
70 client.OnLinkObjects += delegate (
IClientAPI remoteClient, uint parent, List<uint> children)
71 { this.Stale =
true; };
72 client.OnDelinkObjects += delegate(List<uint> primIds,
IClientAPI clientApi) { this.Stale =
true; };
73 client.OnGrabUpdate += delegate(
UUID objectID, Vector3 offset, Vector3 grapPos,
74 IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) { this.Stale =
true; };
75 client.OnObjectAttach += delegate(
IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt,
76 bool silent) { this.Stale =
true; };
77 client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags,
UUID AgentID,
78 UUID GroupID) { this.Stale =
true; };
79 client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags,
UUID AgentID,
UUID GroupID,
80 UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart,
bool BypassRaycast,
81 bool RayEndIsIntersection,
bool CopyCenters,
bool CopyRotates) { this.Stale =
true; };
82 client.OnObjectIncludeInSearch += delegate(
IClientAPI remoteClient,
bool IncludeInSearch, uint localID)
83 { this.Stale =
true; };
84 client.OnObjectPermissions += delegate(
IClientAPI controller,
UUID agentID,
UUID sessionID,
85 byte field, uint localId, uint mask, byte set) { this.Stale =
true; };
86 client.OnRezObject += delegate(
IClientAPI remoteClient,
UUID itemID, Vector3 RayEnd,
87 Vector3 RayStart,
UUID RayTargetID, byte BypassRayCast,
bool RayEndIsIntersection,
89 bool RemoveItem,
UUID fromTaskID) { this.Stale =
true; };
92 public Scene GetParentScene
94 get {
return m_scene; }
99 m_log.Debug(
"[DATASNAPSHOT]: Generating object data for scene " + m_scene.RegionInfo.RegionName);
101 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element,
"objectdata",
"");
104 EntityBase[] entities = m_scene.Entities.GetEntities();
110 SceneObjectGroup obj = (SceneObjectGroup)entity;
116 #pragma warning disable 0612
121 ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y);
123 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element,
"object",
"");
124 node = nodeFactory.CreateNode(XmlNodeType.Element,
"uuid",
"");
125 node.InnerText = obj.UUID.ToString();
126 xmlobject.AppendChild(node);
128 node = nodeFactory.CreateNode(XmlNodeType.Element,
"title",
"");
129 node.InnerText = m_rootPart.Name;
130 xmlobject.AppendChild(node);
132 node = nodeFactory.CreateNode(XmlNodeType.Element,
"description",
"");
133 node.InnerText = m_rootPart.Description;
134 xmlobject.AppendChild(node);
136 node = nodeFactory.CreateNode(XmlNodeType.Element,
"flags",
"");
137 node.InnerText = String.Format(
"{0:x}", (uint)m_rootPart.
Flags);
138 xmlobject.AppendChild(node);
140 node = nodeFactory.CreateNode(XmlNodeType.Element,
"regionuuid",
"");
141 node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString();
142 xmlobject.AppendChild(node);
144 if (land != null && land.
LandData != null)
146 node = nodeFactory.CreateNode(XmlNodeType.Element,
"parceluuid",
"");
147 node.InnerText = land.LandData.GlobalID.ToString();
148 xmlobject.AppendChild(node);
153 m_log.WarnFormat(
"[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName);
157 node = nodeFactory.CreateNode(XmlNodeType.Element,
"location",
"");
158 Vector3 loc = obj.AbsolutePosition;
159 node.InnerText = loc.X.ToString() +
"/" + loc.Y.ToString() +
"/" + loc.Z.ToString();
160 xmlobject.AppendChild(node);
162 string bestImage = GuessImage(obj);
163 if (bestImage !=
string.Empty)
165 node = nodeFactory.CreateNode(XmlNodeType.Element,
"image",
"");
166 node.InnerText = bestImage;
167 xmlobject.AppendChild(node);
170 parent.AppendChild(xmlobject);
172 #pragma warning disable 0612
181 get {
return "ObjectSnapshot"; }
211 string bestguess = string.Empty;
212 Dictionary<UUID, int> counts =
new Dictionary<UUID, int>();
215 if (shape != null && shape.ProfileShape ==
ProfileShape.Square)
217 Primitive.TextureEntry textures = shape.Textures;
218 if (textures != null)
220 if (textures.DefaultTexture != null &&
221 textures.DefaultTexture.TextureID !=
UUID.Zero &&
222 textures.DefaultTexture.TextureID != m_DefaultImage &&
223 textures.DefaultTexture.TextureID != m_BlankImage &&
224 textures.DefaultTexture.RGBA.A < 50f)
226 counts[textures.DefaultTexture.TextureID] = 8;
229 if (textures.FaceTextures != null)
231 foreach (
Primitive.TextureEntryFace tentry in textures.FaceTextures)
235 if (tentry.TextureID !=
UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50)
238 counts.TryGetValue(tentry.TextureID, out c);
239 counts[tentry.TextureID] = c + 1;
241 if (counts.ContainsKey(textures.DefaultTexture.TextureID))
242 counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1;
250 foreach (KeyValuePair<UUID, int> kv
in counts)
252 if (kv.Value < min && kv.Value >= 1)
254 bestguess = kv.Key.ToString();
delegate void ProviderStale(IDataSnapshotProvider provider)
void Initialize(Scene scene, DataSnapshotManager parent)
void OnNewClient(IClientAPI client)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
PrimFlags Flags
Property flags. See OpenMetaverse.PrimFlags
XmlNode RequestSnapshotData(XmlDocument nodeFactory)