aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs
diff options
context:
space:
mode:
authorSean Dague2008-09-03 18:11:44 +0000
committerSean Dague2008-09-03 18:11:44 +0000
commitaf5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e (patch)
treefcc52c0f3e20f005873def97e3be5cd9ca16270e /OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs
parentwhite space fixes (diff)
downloadopensim-SC-af5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e.zip
opensim-SC-af5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e.tar.gz
opensim-SC-af5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e.tar.bz2
opensim-SC-af5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e.tar.xz
narrange to do basic cleanup of the CMS module
Diffstat (limited to 'OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs435
1 files changed, 236 insertions, 199 deletions
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs
index f0763d3..c203054 100644
--- a/OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs
+++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/MetaEntity.cs
@@ -1,219 +1,256 @@
1#region Header
2
1// MetaEntity.cs 3// MetaEntity.cs
2// User: bongiojp 4// User: bongiojp
3// 5//
4// TODO: 6// TODO:
5// Create a physics manager to the meta object if there isn't one or the object knows of no scene but the user wants physics enabled. 7// Create a physics manager to the meta object if there isn't one or the object knows of no scene but the user wants physics enabled.
6 8
9#endregion Header
7 10
8using System; 11using System;
9using System.Collections.Generic; 12using System.Collections.Generic;
10using System.Drawing; 13using System.Drawing;
14
11using libsecondlife; 15using libsecondlife;
16
12using Nini.Config; 17using Nini.Config;
18
13using OpenSim.Framework; 19using OpenSim.Framework;
14using OpenSim.Region.Environment.Interfaces; 20using OpenSim.Region.Environment.Interfaces;
15using OpenSim.Region.Environment.Scenes; 21using OpenSim.Region.Environment.Scenes;
16using log4net;
17using OpenSim.Region.Physics.Manager; 22using OpenSim.Region.Physics.Manager;
23
24using log4net;
25
18using Axiom.Math; 26using Axiom.Math;
19 27
20namespace OpenSim.Region.Environment.Modules.ContentManagement 28namespace OpenSim.Region.Environment.Modules.ContentManagement
21{ 29{
22 public class MetaEntity 30 public class MetaEntity
23 { 31 {
24 protected static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 32 #region Constants
25 33
26 protected SceneObjectGroup m_Entity = null; // The scene object group that represents this meta entity. 34 public const float INVISIBLE = .95f;
27 protected uint m_metaLocalid; 35
28 36 // Settings for transparency of metaentity
29 // Settings for transparency of metaentity 37 public const float NONE = 0f;
30 public const float NONE = 0f; 38 public const float TRANSLUCENT = .5f;
31 public const float TRANSLUCENT = .5f; 39
32 public const float INVISIBLE = .95f; 40 #endregion Constants
33 41
34 public Scene Scene 42 #region Static Fields
35 { 43
36 get { return m_Entity.Scene; } 44 protected static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
37 } 45
38 46 #endregion Static Fields
39 public SceneObjectPart RootPart 47
40 { 48 #region Fields
41 get { return m_Entity.RootPart; } 49
42 set { m_Entity.RootPart = value; } 50 protected SceneObjectGroup m_Entity = null; // The scene object group that represents this meta entity.
43 } 51 protected uint m_metaLocalid;
44 52
45 public LLUUID UUID 53 #endregion Fields
46 { 54
47 get { return m_Entity.UUID; } 55 #region Constructors
48 set { m_Entity.UUID = value; } 56
49 } 57 public MetaEntity()
50 58 {
51 public uint LocalId 59 }
52 { 60
53 get { return m_Entity.LocalId; } 61 /// <summary>
54 set { m_Entity.LocalId = value; } 62 /// Makes a new meta entity by copying the given scene object group.
55 } 63 /// The physics boolean is just a stub right now.
56 64 /// </summary>
57 public SceneObjectGroup ObjectGroup 65 public MetaEntity(SceneObjectGroup orig, bool physics)
58 { 66 {
59 get { return m_Entity; } 67 m_Entity = orig.Copy(orig.RootPart.OwnerID, orig.RootPart.GroupID, false);
60 } 68 Initialize(physics);
61 69 }
62 public Dictionary<LLUUID, SceneObjectPart> Children 70
63 { 71 /// <summary>
64 get { return m_Entity.Children; } 72 /// Takes an XML description of a scene object group and converts it to a meta entity.
65 set { m_Entity.Children = value; } 73 /// </summary>
66 } 74 public MetaEntity(string objectXML, Scene scene, bool physics)
67 75 {
68 public int PrimCount 76 m_Entity = new SceneObjectGroup(objectXML);
69 { 77 m_Entity.SetScene(scene);
70 get { return m_Entity.PrimCount; } 78 Initialize(physics);
71 } 79 }
72 80
73 public MetaEntity() 81 #endregion Constructors
74 { 82
75 } 83 #region Public Properties
76 84
77 /// <summary> 85 public Dictionary<LLUUID, SceneObjectPart> Children
78 /// Makes a new meta entity by copying the given scene object group. 86 {
79 /// The physics boolean is just a stub right now. 87 get { return m_Entity.Children; }
80 /// </summary> 88 set { m_Entity.Children = value; }
81 public MetaEntity(SceneObjectGroup orig, bool physics) 89 }
82 { 90
83 m_Entity = orig.Copy(orig.RootPart.OwnerID, orig.RootPart.GroupID, false); 91 public uint LocalId
84 Initialize(physics); 92 {
85 } 93 get { return m_Entity.LocalId; }
86 94 set { m_Entity.LocalId = value; }
87 /// <summary> 95 }
88 /// Takes an XML description of a scene object group and converts it to a meta entity. 96
89 /// </summary> 97 public SceneObjectGroup ObjectGroup
90 public MetaEntity(string objectXML, Scene scene, bool physics) 98 {
91 { 99 get { return m_Entity; }
92 m_Entity = new SceneObjectGroup(objectXML); 100 }
93 m_Entity.SetScene(scene); 101
94 Initialize(physics); 102 public int PrimCount
95 } 103 {
96 104 get { return m_Entity.PrimCount; }
97 // The metaentity objectgroup must have unique localids as well as unique uuids. 105 }
98 // localids are used by the client to refer to parts. 106
99 // uuids are sent to the client and back to the server to identify parts on the server side. 107 public SceneObjectPart RootPart
100 /// <summary> 108 {
101 /// Changes localids and uuids of m_Entity. 109 get { return m_Entity.RootPart; }
102 /// </summary> 110 set { m_Entity.RootPart = value; }
103 protected void Initialize(bool physics) 111 }
104 { 112
105 //make new uuids 113 public Scene Scene
106 Dictionary<LLUUID, SceneObjectPart> parts = new Dictionary<LLUUID, SceneObjectPart>(); 114 {
107 foreach(SceneObjectPart part in m_Entity.Children.Values) 115 get { return m_Entity.Scene; }
108 { 116 }
109 part.ResetIDs(part.LinkNum); 117
110 parts.Add(part.UUID, part); 118 public LLUUID UUID
111 } 119 {
112 120 get { return m_Entity.UUID; }
113 // make new localids 121 set { m_Entity.UUID = value; }
114 foreach (SceneObjectPart part in m_Entity.Children.Values) 122 }
115 part.LocalId = m_Entity.Scene.PrimIDAllocate(); 123
116 124 #endregion Public Properties
117 //finalize 125
118 m_Entity.UpdateParentIDs(); 126 #region Protected Methods
119 m_Entity.RootPart.PhysActor = null; 127
120 m_Entity.Children = parts; 128 // The metaentity objectgroup must have unique localids as well as unique uuids.
121 129 // localids are used by the client to refer to parts.
122 } 130 // uuids are sent to the client and back to the server to identify parts on the server side.
123 131 /// <summary>
124 public void SendFullUpdate(IClientAPI client) 132 /// Changes localids and uuids of m_Entity.
125 { 133 /// </summary>
126 // Not sure what clientFlags should be but 0 seems to work 134 protected void Initialize(bool physics)
127 SendFullUpdate(client, 0); 135 {
128 } 136 //make new uuids
129 public void SendFullUpdateToAll() 137 Dictionary<LLUUID, SceneObjectPart> parts = new Dictionary<LLUUID, SceneObjectPart>();
130 { 138 foreach(SceneObjectPart part in m_Entity.Children.Values)
131 uint clientFlags = 0; 139 {
132 m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller) 140 part.ResetIDs(part.LinkNum);
133 { m_Entity.SendFullUpdateToClient(controller, clientFlags); } 141 parts.Add(part.UUID, part);
134 ); 142 }
135 } 143
136 144 // make new localids
137 public void SendFullUpdate(IClientAPI client, uint clientFlags) 145 foreach (SceneObjectPart part in m_Entity.Children.Values)
138 { 146 part.LocalId = m_Entity.Scene.PrimIDAllocate();
139 m_Entity.SendFullUpdateToClient(client, clientFlags); 147
140 } 148 //finalize
141 149 m_Entity.UpdateParentIDs();
142 /// <summary> 150 m_Entity.RootPart.PhysActor = null;
143 /// Hides the metaentity from a single client. 151 m_Entity.Children = parts;
144 /// </summary> 152 }
145 public virtual void Hide(IClientAPI client) 153
146 { 154 #endregion Protected Methods
147 //This deletes the group without removing from any databases. 155
148 //This is important because we are not IN any database. 156 #region Public Methods
149 //m_Entity.FakeDeleteGroup(); 157
150 foreach( SceneObjectPart part in m_Entity.Children.Values) 158 /// <summary>
151 client.SendKillObject(m_Entity.RegionHandle, part.LocalId); 159 /// Hides the metaentity from a single client.
152 } 160 /// </summary>
153 161 public virtual void Hide(IClientAPI client)
154 /// <summary> 162 {
155 /// Sends a kill object message to all clients, effectively "hiding" the metaentity even though it's still on the server. 163 //This deletes the group without removing from any databases.
156 /// </summary> 164 //This is important because we are not IN any database.
157 public virtual void HideFromAll() 165 //m_Entity.FakeDeleteGroup();
158 { 166 foreach( SceneObjectPart part in m_Entity.Children.Values)
159 foreach( SceneObjectPart part in m_Entity.Children.Values) 167 client.SendKillObject(m_Entity.RegionHandle, part.LocalId);
160 m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller) 168 }
161 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } 169
162 ); 170 /// <summary>
163 } 171 /// Sends a kill object message to all clients, effectively "hiding" the metaentity even though it's still on the server.
164 172 /// </summary>
165 /// <summary> 173 public virtual void HideFromAll()
166 /// Makes a single SceneObjectPart see through. 174 {
167 /// </summary> 175 foreach( SceneObjectPart part in m_Entity.Children.Values)
168 /// <param name="part"> 176 m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
169 /// A <see cref="SceneObjectPart"/> 177 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
170 /// The part to make see through 178 );
171 /// </param> 179 }
172 /// <param name="transparencyAmount"> 180
173 /// A <see cref="System.Single"/> 181 public void SendFullUpdate(IClientAPI client)
174 /// The degree of transparency to imbue the part with, 0f being solid and .95f being invisible. 182 {
175 /// </param> 183 // Not sure what clientFlags should be but 0 seems to work
176 public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount) 184 SendFullUpdate(client, 0);
177 { 185 }
178 LLObject.TextureEntry tex = null; 186
179 LLColor texcolor; 187 public void SendFullUpdate(IClientAPI client, uint clientFlags)
180 try 188 {
181 { 189 m_Entity.SendFullUpdateToClient(client, clientFlags);
182 tex = part.Shape.Textures; 190 }
183 texcolor = new LLColor(); 191
184 } 192 public void SendFullUpdateToAll()
185 catch(Exception) 193 {
186 { 194 uint clientFlags = 0;
187 //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing textures of scene object: " + e); 195 m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
188 return; 196 { m_Entity.SendFullUpdateToClient(controller, clientFlags); }
189 } 197 );
190 198 }
191 for (uint i = 0; i < tex.FaceTextures.Length; i++) 199
192 { 200 /// <summary>
193 try { 201 /// Makes a single SceneObjectPart see through.
194 if (tex.FaceTextures[i] != null) 202 /// </summary>
195 { 203 /// <param name="part">
196 texcolor = tex.FaceTextures[i].RGBA; 204 /// A <see cref="SceneObjectPart"/>
197 texcolor.A = transparencyAmount; 205 /// The part to make see through
198 tex.FaceTextures[i].RGBA = texcolor; 206 /// </param>
199 } 207 /// <param name="transparencyAmount">
200 } 208 /// A <see cref="System.Single"/>
201 catch (Exception) 209 /// The degree of transparency to imbue the part with, 0f being solid and .95f being invisible.
202 { 210 /// </param>
203 //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing different face textures of object: " + e); 211 public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount)
204 continue; 212 {
205 } 213 LLObject.TextureEntry tex = null;
206 } 214 LLColor texcolor;
207 try { 215 try
208 texcolor = tex.DefaultTexture.RGBA; 216 {
209 texcolor.A = transparencyAmount; 217 tex = part.Shape.Textures;
210 tex.DefaultTexture.RGBA = texcolor; 218 texcolor = new LLColor();
211 part.Shape.TextureEntry = tex.ToBytes(); 219 }
212 } 220 catch(Exception)
213 catch (Exception) 221 {
214 { 222 //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing textures of scene object: " + e);
215 //m_log.Info("[Content Management]: Exception thrown while accessing default face texture of object: " + e); 223 return;
216 } 224 }
217 } 225
218 } 226 for (uint i = 0; i < tex.FaceTextures.Length; i++)
227 {
228 try {
229 if (tex.FaceTextures[i] != null)
230 {
231 texcolor = tex.FaceTextures[i].RGBA;
232 texcolor.A = transparencyAmount;
233 tex.FaceTextures[i].RGBA = texcolor;
234 }
235 }
236 catch (Exception)
237 {
238 //m_log.ErrorFormat("[Content Management]: Exception thrown while accessing different face textures of object: " + e);
239 continue;
240 }
241 }
242 try {
243 texcolor = tex.DefaultTexture.RGBA;
244 texcolor.A = transparencyAmount;
245 tex.DefaultTexture.RGBA = texcolor;
246 part.Shape.TextureEntry = tex.ToBytes();
247 }
248 catch (Exception)
249 {
250 //m_log.Info("[Content Management]: Exception thrown while accessing default face texture of object: " + e);
251 }
252 }
253
254 #endregion Public Methods
255 }
219} \ No newline at end of file 256} \ No newline at end of file