diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 319 |
1 files changed, 59 insertions, 260 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index a4bb765..69e1ae6 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -35,104 +35,6 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework | 36 | namespace OpenSim.Framework |
37 | { | 37 | { |
38 | // A special dictionary for avatar appearance | ||
39 | public struct LayerItem | ||
40 | { | ||
41 | public UUID ItemID; | ||
42 | public UUID AssetID; | ||
43 | |||
44 | public LayerItem(UUID itemID, UUID assetID) | ||
45 | { | ||
46 | ItemID = itemID; | ||
47 | AssetID = assetID; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | public class Layer | ||
52 | { | ||
53 | protected int m_layerType; | ||
54 | protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); | ||
55 | protected List<UUID> m_ids = new List<UUID>(); | ||
56 | |||
57 | public Layer(int type) | ||
58 | { | ||
59 | m_layerType = type; | ||
60 | } | ||
61 | |||
62 | public int LayerType | ||
63 | { | ||
64 | get { return m_layerType; } | ||
65 | } | ||
66 | |||
67 | public int Count | ||
68 | { | ||
69 | get { return m_ids.Count; } | ||
70 | } | ||
71 | |||
72 | public void Add(UUID itemID, UUID assetID) | ||
73 | { | ||
74 | if (m_items.ContainsKey(itemID)) | ||
75 | return; | ||
76 | if (m_ids.Count >= 5) | ||
77 | return; | ||
78 | |||
79 | m_ids.Add(itemID); | ||
80 | m_items[itemID] = assetID; | ||
81 | } | ||
82 | |||
83 | public void Wear(UUID itemID, UUID assetID) | ||
84 | { | ||
85 | Clear(); | ||
86 | Add(itemID, assetID); | ||
87 | } | ||
88 | |||
89 | public void Clear() | ||
90 | { | ||
91 | m_ids.Clear(); | ||
92 | m_items.Clear(); | ||
93 | } | ||
94 | |||
95 | public void RemoveItem(UUID itemID) | ||
96 | { | ||
97 | if (m_items.ContainsKey(itemID)) | ||
98 | { | ||
99 | m_ids.Remove(itemID); | ||
100 | m_items.Remove(itemID); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void RemoveAsset(UUID assetID) | ||
105 | { | ||
106 | UUID itemID = UUID.Zero; | ||
107 | |||
108 | foreach (KeyValuePair<UUID, UUID> kvp in m_items) | ||
109 | { | ||
110 | if (kvp.Value == assetID) | ||
111 | { | ||
112 | itemID = kvp.Key; | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (itemID != UUID.Zero) | ||
118 | { | ||
119 | m_ids.Remove(itemID); | ||
120 | m_items.Remove(itemID); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public LayerItem this [int idx] | ||
125 | { | ||
126 | get | ||
127 | { | ||
128 | if (idx >= m_ids.Count || idx < 0) | ||
129 | return new LayerItem(UUID.Zero, UUID.Zero); | ||
130 | |||
131 | return new LayerItem(m_ids[idx], m_items[m_ids[idx]]); | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | 38 | /// <summary> |
137 | /// Contains the Avatar's Appearance and methods to manipulate the appearance. | 39 | /// Contains the Avatar's Appearance and methods to manipulate the appearance. |
138 | /// </summary> | 40 | /// </summary> |
@@ -184,136 +86,6 @@ namespace OpenSim.Framework | |||
184 | set { m_wearables = value; } | 86 | set { m_wearables = value; } |
185 | } | 87 | } |
186 | 88 | ||
187 | public virtual UUID BodyItem { | ||
188 | get { return m_wearables[AvatarWearable.BODY].ItemID; } | ||
189 | set { m_wearables[AvatarWearable.BODY].ItemID = value; } | ||
190 | } | ||
191 | |||
192 | public virtual UUID BodyAsset { | ||
193 | get { return m_wearables[AvatarWearable.BODY].AssetID; } | ||
194 | set { m_wearables[AvatarWearable.BODY].AssetID = value; } | ||
195 | } | ||
196 | |||
197 | public virtual UUID SkinItem { | ||
198 | get { return m_wearables[AvatarWearable.SKIN].ItemID; } | ||
199 | set { m_wearables[AvatarWearable.SKIN].ItemID = value; } | ||
200 | } | ||
201 | |||
202 | public virtual UUID SkinAsset { | ||
203 | get { return m_wearables[AvatarWearable.SKIN].AssetID; } | ||
204 | set { m_wearables[AvatarWearable.SKIN].AssetID = value; } | ||
205 | } | ||
206 | |||
207 | public virtual UUID HairItem { | ||
208 | get { return m_wearables[AvatarWearable.HAIR].ItemID; } | ||
209 | set { m_wearables[AvatarWearable.HAIR].ItemID = value; } | ||
210 | } | ||
211 | |||
212 | public virtual UUID HairAsset { | ||
213 | get { return m_wearables[AvatarWearable.HAIR].AssetID; } | ||
214 | set { m_wearables[AvatarWearable.HAIR].AssetID = value; } | ||
215 | } | ||
216 | |||
217 | public virtual UUID EyesItem { | ||
218 | get { return m_wearables[AvatarWearable.EYES].ItemID; } | ||
219 | set { m_wearables[AvatarWearable.EYES].ItemID = value; } | ||
220 | } | ||
221 | |||
222 | public virtual UUID EyesAsset { | ||
223 | get { return m_wearables[AvatarWearable.EYES].AssetID; } | ||
224 | set { m_wearables[AvatarWearable.EYES].AssetID = value; } | ||
225 | } | ||
226 | |||
227 | public virtual UUID ShirtItem { | ||
228 | get { return m_wearables[AvatarWearable.SHIRT].ItemID; } | ||
229 | set { m_wearables[AvatarWearable.SHIRT].ItemID = value; } | ||
230 | } | ||
231 | |||
232 | public virtual UUID ShirtAsset { | ||
233 | get { return m_wearables[AvatarWearable.SHIRT].AssetID; } | ||
234 | set { m_wearables[AvatarWearable.SHIRT].AssetID = value; } | ||
235 | } | ||
236 | |||
237 | public virtual UUID PantsItem { | ||
238 | get { return m_wearables[AvatarWearable.PANTS].ItemID; } | ||
239 | set { m_wearables[AvatarWearable.PANTS].ItemID = value; } | ||
240 | } | ||
241 | |||
242 | public virtual UUID PantsAsset { | ||
243 | get { return m_wearables[AvatarWearable.PANTS].AssetID; } | ||
244 | set { m_wearables[AvatarWearable.PANTS].AssetID = value; } | ||
245 | } | ||
246 | |||
247 | public virtual UUID ShoesItem { | ||
248 | get { return m_wearables[AvatarWearable.SHOES].ItemID; } | ||
249 | set { m_wearables[AvatarWearable.SHOES].ItemID = value; } | ||
250 | } | ||
251 | |||
252 | public virtual UUID ShoesAsset { | ||
253 | get { return m_wearables[AvatarWearable.SHOES].AssetID; } | ||
254 | set { m_wearables[AvatarWearable.SHOES].AssetID = value; } | ||
255 | } | ||
256 | |||
257 | public virtual UUID SocksItem { | ||
258 | get { return m_wearables[AvatarWearable.SOCKS].ItemID; } | ||
259 | set { m_wearables[AvatarWearable.SOCKS].ItemID = value; } | ||
260 | } | ||
261 | |||
262 | public virtual UUID SocksAsset { | ||
263 | get { return m_wearables[AvatarWearable.SOCKS].AssetID; } | ||
264 | set { m_wearables[AvatarWearable.SOCKS].AssetID = value; } | ||
265 | } | ||
266 | |||
267 | public virtual UUID JacketItem { | ||
268 | get { return m_wearables[AvatarWearable.JACKET].ItemID; } | ||
269 | set { m_wearables[AvatarWearable.JACKET].ItemID = value; } | ||
270 | } | ||
271 | |||
272 | public virtual UUID JacketAsset { | ||
273 | get { return m_wearables[AvatarWearable.JACKET].AssetID; } | ||
274 | set { m_wearables[AvatarWearable.JACKET].AssetID = value; } | ||
275 | } | ||
276 | |||
277 | public virtual UUID GlovesItem { | ||
278 | get { return m_wearables[AvatarWearable.GLOVES].ItemID; } | ||
279 | set { m_wearables[AvatarWearable.GLOVES].ItemID = value; } | ||
280 | } | ||
281 | |||
282 | public virtual UUID GlovesAsset { | ||
283 | get { return m_wearables[AvatarWearable.GLOVES].AssetID; } | ||
284 | set { m_wearables[AvatarWearable.GLOVES].AssetID = value; } | ||
285 | } | ||
286 | |||
287 | public virtual UUID UnderShirtItem { | ||
288 | get { return m_wearables[AvatarWearable.UNDERSHIRT].ItemID; } | ||
289 | set { m_wearables[AvatarWearable.UNDERSHIRT].ItemID = value; } | ||
290 | } | ||
291 | |||
292 | public virtual UUID UnderShirtAsset { | ||
293 | get { return m_wearables[AvatarWearable.UNDERSHIRT].AssetID; } | ||
294 | set { m_wearables[AvatarWearable.UNDERSHIRT].AssetID = value; } | ||
295 | } | ||
296 | |||
297 | public virtual UUID UnderPantsItem { | ||
298 | get { return m_wearables[AvatarWearable.UNDERPANTS].ItemID; } | ||
299 | set { m_wearables[AvatarWearable.UNDERPANTS].ItemID = value; } | ||
300 | } | ||
301 | |||
302 | public virtual UUID UnderPantsAsset { | ||
303 | get { return m_wearables[AvatarWearable.UNDERPANTS].AssetID; } | ||
304 | set { m_wearables[AvatarWearable.UNDERPANTS].AssetID = value; } | ||
305 | } | ||
306 | |||
307 | public virtual UUID SkirtItem { | ||
308 | get { return m_wearables[AvatarWearable.SKIRT].ItemID; } | ||
309 | set { m_wearables[AvatarWearable.SKIRT].ItemID = value; } | ||
310 | } | ||
311 | |||
312 | public virtual UUID SkirtAsset { | ||
313 | get { return m_wearables[AvatarWearable.SKIRT].AssetID; } | ||
314 | set { m_wearables[AvatarWearable.SKIRT].AssetID = value; } | ||
315 | } | ||
316 | |||
317 | public virtual float AvatarHeight | 89 | public virtual float AvatarHeight |
318 | { | 90 | { |
319 | get { return m_avatarHeight; } | 91 | get { return m_avatarHeight; } |
@@ -329,9 +101,8 @@ namespace OpenSim.Framework | |||
329 | 101 | ||
330 | public AvatarAppearance(UUID owner) | 102 | public AvatarAppearance(UUID owner) |
331 | { | 103 | { |
332 | // DEBUG ON | 104 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance for {0}",owner); |
333 | m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner); | 105 | |
334 | // DEBUG OFF | ||
335 | m_serial = 1; | 106 | m_serial = 1; |
336 | m_owner = owner; | 107 | m_owner = owner; |
337 | 108 | ||
@@ -345,9 +116,8 @@ namespace OpenSim.Framework | |||
345 | 116 | ||
346 | public AvatarAppearance(UUID avatarID, OSDMap map) | 117 | public AvatarAppearance(UUID avatarID, OSDMap map) |
347 | { | 118 | { |
348 | // DEBUG ON | 119 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance for {0} from OSDMap",avatarID); |
349 | m_log.WarnFormat("[AVATAR APPEARANCE] create appearance for {0} from OSDMap",avatarID); | 120 | |
350 | // DEBUG OFF | ||
351 | m_owner = avatarID; | 121 | m_owner = avatarID; |
352 | Unpack(map); | 122 | Unpack(map); |
353 | SetHeight(); | 123 | SetHeight(); |
@@ -355,9 +125,8 @@ namespace OpenSim.Framework | |||
355 | 125 | ||
356 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) | 126 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) |
357 | { | 127 | { |
358 | // DEBUG ON | 128 | // m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); |
359 | m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); | 129 | |
360 | // DEBUG OFF | ||
361 | m_serial = 1; | 130 | m_serial = 1; |
362 | m_owner = avatarID; | 131 | m_owner = avatarID; |
363 | 132 | ||
@@ -381,11 +150,14 @@ namespace OpenSim.Framework | |||
381 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 150 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
382 | } | 151 | } |
383 | 152 | ||
384 | public AvatarAppearance(AvatarAppearance appearance) | 153 | public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) |
385 | { | 154 | { |
386 | // DEBUG ON | 155 | } |
387 | m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); | 156 | |
388 | // DEBUG OFF | 157 | public AvatarAppearance(AvatarAppearance appearance, bool copyWearables) |
158 | { | ||
159 | // m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); | ||
160 | |||
389 | if (appearance == null) | 161 | if (appearance == null) |
390 | { | 162 | { |
391 | m_serial = 1; | 163 | m_serial = 1; |
@@ -404,10 +176,11 @@ namespace OpenSim.Framework | |||
404 | m_serial = appearance.Serial; | 176 | m_serial = appearance.Serial; |
405 | m_owner = appearance.Owner; | 177 | m_owner = appearance.Owner; |
406 | 178 | ||
407 | m_wearables = null; | 179 | m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; |
408 | if (appearance.Wearables != null) | 180 | for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) |
181 | m_wearables[i] = new AvatarWearable(); | ||
182 | if (copyWearables && (appearance.Wearables != null)) | ||
409 | { | 183 | { |
410 | m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; //should be 13 of these | ||
411 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 184 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
412 | SetWearable(i,appearance.Wearables[i]); | 185 | SetWearable(i,appearance.Wearables[i]); |
413 | } | 186 | } |
@@ -429,6 +202,28 @@ namespace OpenSim.Framework | |||
429 | AppendAttachment(new AvatarAttachment(attachment)); | 202 | AppendAttachment(new AvatarAttachment(attachment)); |
430 | } | 203 | } |
431 | 204 | ||
205 | public void GetAssetsFrom(AvatarAppearance app) | ||
206 | { | ||
207 | for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) | ||
208 | { | ||
209 | for (int j = 0 ; j < m_wearables[i].Count ; j++) | ||
210 | { | ||
211 | UUID itemID = m_wearables[i][j].ItemID; | ||
212 | UUID assetID = app.Wearables[i].GetAsset(itemID); | ||
213 | |||
214 | if (assetID != UUID.Zero) | ||
215 | m_wearables[i].Add(itemID, assetID); | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | |||
220 | public void ClearWearables() | ||
221 | { | ||
222 | m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; | ||
223 | for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) | ||
224 | m_wearables[i] = new AvatarWearable(); | ||
225 | } | ||
226 | |||
432 | protected virtual void SetDefaultWearables() | 227 | protected virtual void SetDefaultWearables() |
433 | { | 228 | { |
434 | m_wearables = AvatarWearable.DefaultWearables; | 229 | m_wearables = AvatarWearable.DefaultWearables; |
@@ -436,11 +231,11 @@ namespace OpenSim.Framework | |||
436 | 231 | ||
437 | protected virtual void SetDefaultParams() | 232 | protected virtual void SetDefaultParams() |
438 | { | 233 | { |
439 | m_visualparams = new byte[VISUALPARAM_COUNT]; | 234 | m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 }; |
440 | for (int i = 0; i < VISUALPARAM_COUNT; i++) | 235 | // for (int i = 0; i < VISUALPARAM_COUNT; i++) |
441 | { | 236 | // { |
442 | m_visualparams[i] = 150; | 237 | // m_visualparams[i] = 150; |
443 | } | 238 | // } |
444 | } | 239 | } |
445 | 240 | ||
446 | protected virtual void SetDefaultTexture() | 241 | protected virtual void SetDefaultTexture() |
@@ -479,10 +274,9 @@ namespace OpenSim.Framework | |||
479 | } | 274 | } |
480 | 275 | ||
481 | changed = true; | 276 | changed = true; |
482 | // DEBUG ON | 277 | |
483 | if (newface != null) | 278 | // if (newface != null) |
484 | m_log.WarnFormat("[AVATAR APPEARANCE] index {0}, new texture id {1}",i,newface.TextureID); | 279 | // m_log.WarnFormat("[AVATAR APPEARANCE]: index {0}, new texture id {1}",i,newface.TextureID); |
485 | // DEBUG OFF | ||
486 | } | 280 | } |
487 | 281 | ||
488 | m_texture = textureEntry; | 282 | m_texture = textureEntry; |
@@ -552,7 +346,9 @@ namespace OpenSim.Framework | |||
552 | // DEBUG ON | 346 | // DEBUG ON |
553 | // m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); | 347 | // m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); |
554 | // DEBUG OFF | 348 | // DEBUG OFF |
555 | m_wearables[wearableId] = new AvatarWearable(wearable.ItemID,wearable.AssetID); | 349 | m_wearables[wearableId].Clear(); |
350 | for (int i = 0 ; i < wearable.Count ; i++) | ||
351 | m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); | ||
556 | } | 352 | } |
557 | 353 | ||
558 | 354 | ||
@@ -568,7 +364,10 @@ namespace OpenSim.Framework | |||
568 | s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID); | 364 | s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID); |
569 | 365 | ||
570 | foreach (AvatarWearable awear in m_wearables) | 366 | foreach (AvatarWearable awear in m_wearables) |
571 | s += String.Format("Wearable: item={0}, asset={1}\n",awear.ItemID,awear.AssetID); | 367 | { |
368 | for ( int i = 0 ; i < awear.Count ; i++ ) | ||
369 | s += String.Format("Wearable: item={0}, asset={1}\n",awear[i].ItemID,awear[i].AssetID); | ||
370 | } | ||
572 | 371 | ||
573 | s += "Visual Params: "; | 372 | s += "Visual Params: "; |
574 | for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) | 373 | for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) |
@@ -738,11 +537,11 @@ namespace OpenSim.Framework | |||
738 | { | 537 | { |
739 | OSDArray wears = (OSDArray)(data["wearables"]); | 538 | OSDArray wears = (OSDArray)(data["wearables"]); |
740 | for (int i = 0; i < wears.Count; i++) | 539 | for (int i = 0; i < wears.Count; i++) |
741 | m_wearables[i] = new AvatarWearable((OSDMap)wears[i]); | 540 | m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); |
742 | } | 541 | } |
743 | else | 542 | else |
744 | { | 543 | { |
745 | m_log.Warn("[AVATARAPPEARANCE] failed to unpack wearables"); | 544 | m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); |
746 | } | 545 | } |
747 | 546 | ||
748 | // Avatar Textures | 547 | // Avatar Textures |
@@ -760,7 +559,7 @@ namespace OpenSim.Framework | |||
760 | } | 559 | } |
761 | else | 560 | else |
762 | { | 561 | { |
763 | m_log.Warn("[AVATARAPPEARANCE] failed to unpack textures"); | 562 | m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); |
764 | } | 563 | } |
765 | 564 | ||
766 | // Visual Parameters | 565 | // Visual Parameters |
@@ -772,7 +571,7 @@ namespace OpenSim.Framework | |||
772 | } | 571 | } |
773 | else | 572 | else |
774 | { | 573 | { |
775 | m_log.Warn("[AVATARAPPEARANCE] failed to unpack visual parameters"); | 574 | m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters"); |
776 | } | 575 | } |
777 | 576 | ||
778 | // Attachments | 577 | // Attachments |
@@ -786,7 +585,7 @@ namespace OpenSim.Framework | |||
786 | } | 585 | } |
787 | catch (Exception e) | 586 | catch (Exception e) |
788 | { | 587 | { |
789 | m_log.ErrorFormat("[AVATARAPPEARANCE] unpack failed badly: {0}",e.Message); | 588 | m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace); |
790 | } | 589 | } |
791 | } | 590 | } |
792 | 591 | ||