aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs77
1 files changed, 38 insertions, 39 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 69e1ae6..2906af8 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Framework
46 46
47 public readonly static int TEXTURE_COUNT = 21; 47 public readonly static int TEXTURE_COUNT = 21;
48 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 48 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
49 49
50 protected UUID m_owner; 50 protected UUID m_owner;
51 protected int m_serial = 1; 51 protected int m_serial = 1;
52 protected byte[] m_visualparams; 52 protected byte[] m_visualparams;
@@ -110,10 +110,10 @@ namespace OpenSim.Framework
110 SetDefaultTexture(); 110 SetDefaultTexture();
111 SetDefaultParams(); 111 SetDefaultParams();
112 SetHeight(); 112 SetHeight();
113 113
114 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 114 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
115 } 115 }
116 116
117 public AvatarAppearance(UUID avatarID, OSDMap map) 117 public AvatarAppearance(UUID avatarID, OSDMap map)
118 { 118 {
119// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance for {0} from OSDMap",avatarID); 119// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance for {0} from OSDMap",avatarID);
@@ -122,11 +122,11 @@ namespace OpenSim.Framework
122 Unpack(map); 122 Unpack(map);
123 SetHeight(); 123 SetHeight();
124 } 124 }
125 125
126 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) 126 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
127 { 127 {
128// m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); 128// m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID);
129 129
130 m_serial = 1; 130 m_serial = 1;
131 m_owner = avatarID; 131 m_owner = avatarID;
132 132
@@ -134,7 +134,7 @@ namespace OpenSim.Framework
134 m_wearables = wearables; 134 m_wearables = wearables;
135 else 135 else
136 SetDefaultWearables(); 136 SetDefaultWearables();
137 137
138 if (textureEntry != null) 138 if (textureEntry != null)
139 m_texture = textureEntry; 139 m_texture = textureEntry;
140 else 140 else
@@ -172,41 +172,41 @@ namespace OpenSim.Framework
172 172
173 return; 173 return;
174 } 174 }
175 175
176 m_serial = appearance.Serial; 176 m_serial = appearance.Serial;
177 m_owner = appearance.Owner; 177 m_owner = appearance.Owner;
178 178
179 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 179 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
180 for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) 180 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
181 m_wearables[i] = new AvatarWearable(); 181 m_wearables[i] = new AvatarWearable();
182 if (copyWearables && (appearance.Wearables != null)) 182 if (copyWearables && (appearance.Wearables != null))
183 { 183 {
184 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 184 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
185 SetWearable(i,appearance.Wearables[i]); 185 SetWearable(i,appearance.Wearables[i]);
186 } 186 }
187 187
188 m_texture = null; 188 m_texture = null;
189 if (appearance.Texture != null) 189 if (appearance.Texture != null)
190 { 190 {
191 byte[] tbytes = appearance.Texture.GetBytes(); 191 byte[] tbytes = appearance.Texture.GetBytes();
192 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); 192 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
193 } 193 }
194 194
195 m_visualparams = null; 195 m_visualparams = null;
196 if (appearance.VisualParams != null) 196 if (appearance.VisualParams != null)
197 m_visualparams = (byte[])appearance.VisualParams.Clone(); 197 m_visualparams = (byte[])appearance.VisualParams.Clone();
198 198
199 // Copy the attachment, force append mode since that ensures consistency 199 // Copy the attachment, force append mode since that ensures consistency
200 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 200 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
201 foreach (AvatarAttachment attachment in appearance.GetAttachments()) 201 foreach (AvatarAttachment attachment in appearance.GetAttachments())
202 AppendAttachment(new AvatarAttachment(attachment)); 202 AppendAttachment(new AvatarAttachment(attachment));
203 } 203 }
204 204
205 public void GetAssetsFrom(AvatarAppearance app) 205 public void GetAssetsFrom(AvatarAppearance app)
206 { 206 {
207 for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) 207 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
208 { 208 {
209 for (int j = 0 ; j < m_wearables[i].Count ; j++) 209 for (int j = 0; j < m_wearables[i].Count; j++)
210 { 210 {
211 UUID itemID = m_wearables[i][j].ItemID; 211 UUID itemID = m_wearables[i][j].ItemID;
212 UUID assetID = app.Wearables[i].GetAsset(itemID); 212 UUID assetID = app.Wearables[i].GetAsset(itemID);
@@ -220,7 +220,7 @@ namespace OpenSim.Framework
220 public void ClearWearables() 220 public void ClearWearables()
221 { 221 {
222 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 222 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
223 for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) 223 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
224 m_wearables[i] = new AvatarWearable(); 224 m_wearables[i] = new AvatarWearable();
225 } 225 }
226 226
@@ -248,7 +248,7 @@ namespace OpenSim.Framework
248 /// <summary> 248 /// <summary>
249 /// Set up appearance textures. 249 /// Set up appearance textures.
250 /// Returns boolean that indicates whether the new entries actually change the 250 /// Returns boolean that indicates whether the new entries actually change the
251 /// existing values. 251 /// existing values.
252 /// </summary> 252 /// </summary>
253 public virtual bool SetTextureEntries(Primitive.TextureEntry textureEntry) 253 public virtual bool SetTextureEntries(Primitive.TextureEntry textureEntry)
254 { 254 {
@@ -263,7 +263,7 @@ namespace OpenSim.Framework
263 { 263 {
264 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i]; 264 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i];
265 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i]; 265 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i];
266 266
267 if (newface == null) 267 if (newface == null)
268 { 268 {
269 if (oldface == null) continue; 269 if (oldface == null) continue;
@@ -274,7 +274,7 @@ namespace OpenSim.Framework
274 } 274 }
275 275
276 changed = true; 276 changed = true;
277 277
278// if (newface != null) 278// if (newface != null)
279// 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);
280 } 280 }
@@ -282,11 +282,11 @@ namespace OpenSim.Framework
282 m_texture = textureEntry; 282 m_texture = textureEntry;
283 return changed; 283 return changed;
284 } 284 }
285 285
286 /// <summary> 286 /// <summary>
287 /// Set up visual parameters for the avatar and refresh the avatar height 287 /// Set up visual parameters for the avatar and refresh the avatar height
288 /// Returns boolean that indicates whether the new entries actually change the 288 /// Returns boolean that indicates whether the new entries actually change the
289 /// existing values. 289 /// existing values.
290 /// </summary> 290 /// </summary>
291 public virtual bool SetVisualParams(byte[] visualParams) 291 public virtual bool SetVisualParams(byte[] visualParams)
292 { 292 {
@@ -316,13 +316,13 @@ namespace OpenSim.Framework
316 316
317 return changed; 317 return changed;
318 } 318 }
319 319
320 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) 320 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
321 { 321 {
322 SetTextureEntries(textureEntry); 322 SetTextureEntries(textureEntry);
323 SetVisualParams(visualParams); 323 SetVisualParams(visualParams);
324 } 324 }
325 325
326 public virtual void SetHeight() 326 public virtual void SetHeight()
327 { 327 {
328 m_avatarHeight = 1.23077f // Shortest possible avatar height 328 m_avatarHeight = 1.23077f // Shortest possible avatar height
@@ -347,25 +347,24 @@ namespace OpenSim.Framework
347// 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);
348// DEBUG OFF 348// DEBUG OFF
349 m_wearables[wearableId].Clear(); 349 m_wearables[wearableId].Clear();
350 for (int i = 0 ; i < wearable.Count ; i++) 350 for (int i = 0; i < wearable.Count; i++)
351 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); 351 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
352 } 352 }
353 353
354
355// DEBUG ON 354// DEBUG ON
356 public override String ToString() 355 public override String ToString()
357 { 356 {
358 String s = ""; 357 String s = "";
359 358
360 s += String.Format("Serial: {0}\n",m_serial); 359 s += String.Format("Serial: {0}\n",m_serial);
361 360
362 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) 361 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
363 if (m_texture.FaceTextures[i] != null) 362 if (m_texture.FaceTextures[i] != null)
364 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID); 363 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID);
365 364
366 foreach (AvatarWearable awear in m_wearables) 365 foreach (AvatarWearable awear in m_wearables)
367 { 366 {
368 for ( int i = 0 ; i < awear.Count ; i++ ) 367 for (int i = 0; i < awear.Count; i++)
369 s += String.Format("Wearable: item={0}, asset={1}\n",awear[i].ItemID,awear[i].AssetID); 368 s += String.Format("Wearable: item={0}, asset={1}\n",awear[i].ItemID,awear[i].AssetID);
370 } 369 }
371 370
@@ -373,13 +372,13 @@ namespace OpenSim.Framework
373 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) 372 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++)
374 s += String.Format("{0},",m_visualparams[j]); 373 s += String.Format("{0},",m_visualparams[j]);
375 s += "\n"; 374 s += "\n";
376 375
377 return s; 376 return s;
378 } 377 }
379// DEBUG OFF 378// DEBUG OFF
380 379
381 /// <summary> 380 /// <summary>
382 /// Get a list of the attachments, note that there may be 381 /// Get a list of the attachments, note that there may be
383 /// duplicate attachpoints 382 /// duplicate attachpoints
384 /// </summary> 383 /// </summary>
385 public List<AvatarAttachment> GetAttachments() 384 public List<AvatarAttachment> GetAttachments()
@@ -390,10 +389,10 @@ namespace OpenSim.Framework
390 foreach (AvatarAttachment attach in kvp.Value) 389 foreach (AvatarAttachment attach in kvp.Value)
391 alist.Add(new AvatarAttachment(attach)); 390 alist.Add(new AvatarAttachment(attach));
392 } 391 }
393 392
394 return alist; 393 return alist;
395 } 394 }
396 395
397 internal void AppendAttachment(AvatarAttachment attach) 396 internal void AppendAttachment(AvatarAttachment attach)
398 { 397 {
399 if (! m_attachments.ContainsKey(attach.AttachPoint)) 398 if (! m_attachments.ContainsKey(attach.AttachPoint))
@@ -406,11 +405,11 @@ namespace OpenSim.Framework
406 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 405 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
407 m_attachments[attach.AttachPoint].Add(attach); 406 m_attachments[attach.AttachPoint].Add(attach);
408 } 407 }
409 408
410 /// <summary> 409 /// <summary>
411 /// Add an attachment, if the attachpoint has the 410 /// Add an attachment, if the attachpoint has the
412 /// 0x80 bit set then we assume this is an append 411 /// 0x80 bit set then we assume this is an append
413 /// operation otherwise we replace whatever is 412 /// operation otherwise we replace whatever is
414 /// currently attached at the attachpoint 413 /// currently attached at the attachpoint
415 /// </summary> 414 /// </summary>
416 public void SetAttachment(int attachpoint, UUID item, UUID asset) 415 public void SetAttachment(int attachpoint, UUID item, UUID asset)
@@ -485,14 +484,14 @@ namespace OpenSim.Framework
485 data["serial"] = OSD.FromInteger(m_serial); 484 data["serial"] = OSD.FromInteger(m_serial);
486 data["height"] = OSD.FromReal(m_avatarHeight); 485 data["height"] = OSD.FromReal(m_avatarHeight);
487 data["hipoffset"] = OSD.FromReal(m_hipOffset); 486 data["hipoffset"] = OSD.FromReal(m_hipOffset);
488 487
489 // Wearables 488 // Wearables
490 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); 489 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES);
491 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 490 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
492 wears.Add(m_wearables[i].Pack()); 491 wears.Add(m_wearables[i].Pack());
493 data["wearables"] = wears; 492 data["wearables"] = wears;
494 493
495 // Avatar Textures 494 // Avatar Textures
496 OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT); 495 OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT);
497 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) 496 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
498 { 497 {
@@ -506,7 +505,7 @@ namespace OpenSim.Framework
506 // Visual Parameters 505 // Visual Parameters
507 OSDBinary visualparams = new OSDBinary(m_visualparams); 506 OSDBinary visualparams = new OSDBinary(m_visualparams);
508 data["visualparams"] = visualparams; 507 data["visualparams"] = visualparams;
509 508
510 // Attachments 509 // Attachments
511 OSDArray attachs = new OSDArray(m_attachments.Count); 510 OSDArray attachs = new OSDArray(m_attachments.Count);
512 foreach (AvatarAttachment attach in GetAttachments()) 511 foreach (AvatarAttachment attach in GetAttachments())
@@ -529,14 +528,14 @@ namespace OpenSim.Framework
529 if ((data != null) && (data["hipoffset"] != null)) 528 if ((data != null) && (data["hipoffset"] != null))
530 m_hipOffset = (float)data["hipoffset"].AsReal(); 529 m_hipOffset = (float)data["hipoffset"].AsReal();
531 530
532 try 531 try
533 { 532 {
534 // Wearables 533 // Wearables
535 SetDefaultWearables(); 534 SetDefaultWearables();
536 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) 535 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
537 { 536 {
538 OSDArray wears = (OSDArray)(data["wearables"]); 537 OSDArray wears = (OSDArray)(data["wearables"]);
539 for (int i = 0; i < wears.Count; i++) 538 for (int i = 0; i < wears.Count; i++)
540 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 539 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
541 } 540 }
542 else 541 else