diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs | 270 |
1 files changed, 0 insertions, 270 deletions
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs deleted file mode 100644 index c7b1ed7..0000000 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs +++ /dev/null | |||
@@ -1,270 +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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Drawing; | ||
31 | |||
32 | using OpenMetaverse; | ||
33 | |||
34 | using Nini.Config; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
40 | using OpenSim.Region.Physics.Manager; | ||
41 | |||
42 | using log4net; | ||
43 | |||
44 | namespace OpenSim.Region.OptionalModules.ContentManagement | ||
45 | { | ||
46 | public class MetaEntity | ||
47 | { | ||
48 | #region Constants | ||
49 | |||
50 | public const float INVISIBLE = .95f; | ||
51 | |||
52 | // Settings for transparency of metaentity | ||
53 | public const float NONE = 0f; | ||
54 | public const float TRANSLUCENT = .5f; | ||
55 | |||
56 | #endregion Constants | ||
57 | |||
58 | #region Static Fields | ||
59 | |||
60 | //private static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
61 | |||
62 | #endregion Static Fields | ||
63 | |||
64 | #region Fields | ||
65 | |||
66 | protected SceneObjectGroup m_Entity = null; // The scene object group that represents this meta entity. | ||
67 | protected uint m_metaLocalid; | ||
68 | |||
69 | #endregion Fields | ||
70 | |||
71 | #region Constructors | ||
72 | |||
73 | public MetaEntity() | ||
74 | { | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Makes a new meta entity by copying the given scene object group. | ||
79 | /// The physics boolean is just a stub right now. | ||
80 | /// </summary> | ||
81 | public MetaEntity(SceneObjectGroup orig, bool physics) | ||
82 | { | ||
83 | m_Entity = orig.Copy(false); | ||
84 | Initialize(physics); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Takes an XML description of a scene object group and converts it to a meta entity. | ||
89 | /// </summary> | ||
90 | public MetaEntity(string objectXML, Scene scene, bool physics) | ||
91 | { | ||
92 | m_Entity = SceneObjectSerializer.FromXml2Format(objectXML); | ||
93 | m_Entity.SetScene(scene); | ||
94 | Initialize(physics); | ||
95 | } | ||
96 | |||
97 | #endregion Constructors | ||
98 | |||
99 | #region Public Properties | ||
100 | |||
101 | public SceneObjectPart[] Parts | ||
102 | { | ||
103 | get { return m_Entity.Parts; } | ||
104 | } | ||
105 | |||
106 | public uint LocalId | ||
107 | { | ||
108 | get { return m_Entity.LocalId; } | ||
109 | set { m_Entity.LocalId = value; } | ||
110 | } | ||
111 | |||
112 | public SceneObjectGroup ObjectGroup | ||
113 | { | ||
114 | get { return m_Entity; } | ||
115 | } | ||
116 | |||
117 | public int PrimCount | ||
118 | { | ||
119 | get { return m_Entity.PrimCount; } | ||
120 | } | ||
121 | |||
122 | public SceneObjectPart RootPart | ||
123 | { | ||
124 | get { return m_Entity.RootPart; } | ||
125 | } | ||
126 | |||
127 | public Scene Scene | ||
128 | { | ||
129 | get { return m_Entity.Scene; } | ||
130 | } | ||
131 | |||
132 | public UUID UUID | ||
133 | { | ||
134 | get { return m_Entity.UUID; } | ||
135 | set { m_Entity.UUID = value; } | ||
136 | } | ||
137 | |||
138 | #endregion Public Properties | ||
139 | |||
140 | #region Protected Methods | ||
141 | |||
142 | // The metaentity objectgroup must have unique localids as well as unique uuids. | ||
143 | // localids are used by the client to refer to parts. | ||
144 | // uuids are sent to the client and back to the server to identify parts on the server side. | ||
145 | /// <summary> | ||
146 | /// Changes localids and uuids of m_Entity. | ||
147 | /// </summary> | ||
148 | protected void Initialize(bool physics) | ||
149 | { | ||
150 | //make new uuids | ||
151 | Dictionary<UUID, SceneObjectPart> parts = new Dictionary<UUID, SceneObjectPart>(); | ||
152 | |||
153 | foreach (SceneObjectPart part in m_Entity.Parts) | ||
154 | { | ||
155 | part.ResetIDs(part.LinkNum); | ||
156 | parts.Add(part.UUID, part); | ||
157 | } | ||
158 | |||
159 | //finalize | ||
160 | m_Entity.RootPart.PhysActor = null; | ||
161 | foreach (SceneObjectPart part in parts.Values) | ||
162 | m_Entity.AddPart(part); | ||
163 | } | ||
164 | |||
165 | #endregion Protected Methods | ||
166 | |||
167 | #region Public Methods | ||
168 | |||
169 | /// <summary> | ||
170 | /// Hides the metaentity from a single client. | ||
171 | /// </summary> | ||
172 | public virtual void Hide(IClientAPI client) | ||
173 | { | ||
174 | //This deletes the group without removing from any databases. | ||
175 | //This is important because we are not IN any database. | ||
176 | //m_Entity.FakeDeleteGroup(); | ||
177 | foreach (SceneObjectPart part in m_Entity.Parts) | ||
178 | client.SendKillObject(m_Entity.RegionHandle, part.LocalId); | ||
179 | } | ||
180 | |||
181 | /// <summary> | ||
182 | /// Sends a kill object message to all clients, effectively "hiding" the metaentity even though it's still on the server. | ||
183 | /// </summary> | ||
184 | public virtual void HideFromAll() | ||
185 | { | ||
186 | foreach (SceneObjectPart part in m_Entity.Parts) | ||
187 | { | ||
188 | m_Entity.Scene.ForEachClient( | ||
189 | delegate(IClientAPI controller) | ||
190 | { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } | ||
191 | ); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | public void SendFullUpdate(IClientAPI client) | ||
196 | { | ||
197 | // Not sure what clientFlags should be but 0 seems to work | ||
198 | SendFullUpdate(client, 0); | ||
199 | } | ||
200 | |||
201 | public void SendFullUpdate(IClientAPI client, uint clientFlags) | ||
202 | { | ||
203 | m_Entity.SendFullUpdateToClient(client); | ||
204 | } | ||
205 | |||
206 | public void SendFullUpdateToAll() | ||
207 | { | ||
208 | m_Entity.Scene.ForEachClient( | ||
209 | delegate(IClientAPI controller) | ||
210 | { m_Entity.SendFullUpdateToClient(controller); } | ||
211 | ); | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
215 | /// Makes a single SceneObjectPart see through. | ||
216 | /// </summary> | ||
217 | /// <param name="part"> | ||
218 | /// A <see cref="SceneObjectPart"/> | ||
219 | /// The part to make see through | ||
220 | /// </param> | ||
221 | /// <param name="transparencyAmount"> | ||
222 | /// A <see cref="System.Single"/> | ||
223 | /// The degree of transparency to imbue the part with, 0f being solid and .95f being invisible. | ||
224 | /// </param> | ||
225 | public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount) | ||
226 | { | ||
227 | Primitive.TextureEntry tex = null; | ||
228 | Color4 texcolor; | ||
229 | try | ||
230 | { | ||
231 | tex = part.Shape.Textures; | ||
232 | texcolor = new Color4(); | ||
233 | } | ||
234 | catch(Exception) | ||
235 | { | ||
236 | //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing textures of scene object: " + e); | ||
237 | return; | ||
238 | } | ||
239 | |||
240 | for (uint i = 0; i < tex.FaceTextures.Length; i++) | ||
241 | { | ||
242 | try { | ||
243 | if (tex.FaceTextures[i] != null) | ||
244 | { | ||
245 | texcolor = tex.FaceTextures[i].RGBA; | ||
246 | texcolor.A = transparencyAmount; | ||
247 | tex.FaceTextures[i].RGBA = texcolor; | ||
248 | } | ||
249 | } | ||
250 | catch (Exception) | ||
251 | { | ||
252 | //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing different face textures of object: " + e); | ||
253 | continue; | ||
254 | } | ||
255 | } | ||
256 | try { | ||
257 | texcolor = tex.DefaultTexture.RGBA; | ||
258 | texcolor.A = transparencyAmount; | ||
259 | tex.DefaultTexture.RGBA = texcolor; | ||
260 | part.Shape.TextureEntry = tex.GetBytes(); | ||
261 | } | ||
262 | catch (Exception) | ||
263 | { | ||
264 | //m_log.Info("[Content Management]: Exception thrown while accessing default face texture of object: " + e); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | #endregion Public Methods | ||
269 | } | ||
270 | } | ||