aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs151
1 files changed, 121 insertions, 30 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 95e9667..2183fb6 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -40,8 +40,17 @@ namespace OpenSim.Framework
40 /// </summary> 40 /// </summary>
41 public class AvatarAppearance 41 public class AvatarAppearance
42 { 42 {
43 // SL box diferent to size
44 const float AVBOXAJUST = 0.2f;
45 // constrains for ubitode physics
46 const float AVBOXMINX = 0.2f;
47 const float AVBOXMINY = 0.3f;
48 const float AVBOXMINZ = 1.2f;
49
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 51
52 // this is viewer capabilities and weared things dependent
53 // should be only used as initial default value ( V1 viewers )
45 public readonly static int VISUALPARAM_COUNT = 218; 54 public readonly static int VISUALPARAM_COUNT = 218;
46 55
47 public readonly static int TEXTURE_COUNT = 21; 56 public readonly static int TEXTURE_COUNT = 21;
@@ -53,6 +62,10 @@ namespace OpenSim.Framework
53 protected AvatarWearable[] m_wearables; 62 protected AvatarWearable[] m_wearables;
54 protected Dictionary<int, List<AvatarAttachment>> m_attachments; 63 protected Dictionary<int, List<AvatarAttachment>> m_attachments;
55 protected float m_avatarHeight = 0; 64 protected float m_avatarHeight = 0;
65 protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value
66 protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f);
67 protected float m_avatarFeetOffset = 0;
68 protected float m_avatarAnimOffset = 0;
56 69
57 public virtual int Serial 70 public virtual int Serial
58 { 71 {
@@ -66,6 +79,21 @@ namespace OpenSim.Framework
66 set { m_visualparams = value; } 79 set { m_visualparams = value; }
67 } 80 }
68 81
82 public virtual Vector3 AvatarSize
83 {
84 get { return m_avatarSize; }
85 }
86
87 public virtual Vector3 AvatarBoxSize
88 {
89 get { return m_avatarBoxSize; }
90 }
91
92 public virtual float AvatarFeetOffset
93 {
94 get { return m_avatarFeetOffset + m_avatarAnimOffset; }
95 }
96
69 public virtual Primitive.TextureEntry Texture 97 public virtual Primitive.TextureEntry Texture
70 { 98 {
71 get { return m_texture; } 99 get { return m_texture; }
@@ -96,7 +124,8 @@ namespace OpenSim.Framework
96 SetDefaultWearables(); 124 SetDefaultWearables();
97 SetDefaultTexture(); 125 SetDefaultTexture();
98 SetDefaultParams(); 126 SetDefaultParams();
99 SetHeight(); 127// SetHeight();
128 SetSize(new Vector3(0.45f,0.6f,1.9f));
100 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 129 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
101 } 130 }
102 131
@@ -105,7 +134,7 @@ namespace OpenSim.Framework
105// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); 134// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap");
106 135
107 Unpack(map); 136 Unpack(map);
108 SetHeight(); 137// SetHeight(); done in Unpack
109 } 138 }
110 139
111 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) 140 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
@@ -129,7 +158,9 @@ namespace OpenSim.Framework
129 else 158 else
130 SetDefaultParams(); 159 SetDefaultParams();
131 160
132 SetHeight(); 161// SetHeight();
162 if(m_avatarHeight == 0)
163 SetSize(new Vector3(0.45f,0.6f,1.9f));
133 164
134 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 165 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
135 } 166 }
@@ -148,7 +179,8 @@ namespace OpenSim.Framework
148 SetDefaultWearables(); 179 SetDefaultWearables();
149 SetDefaultTexture(); 180 SetDefaultTexture();
150 SetDefaultParams(); 181 SetDefaultParams();
151 SetHeight(); 182// SetHeight();
183 SetSize(new Vector3(0.45f, 0.6f, 1.9f));
152 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 184 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
153 185
154 return; 186 return;
@@ -177,7 +209,8 @@ namespace OpenSim.Framework
177 if (appearance.VisualParams != null) 209 if (appearance.VisualParams != null)
178 m_visualparams = (byte[])appearance.VisualParams.Clone(); 210 m_visualparams = (byte[])appearance.VisualParams.Clone();
179 211
180 m_avatarHeight = appearance.m_avatarHeight; 212// m_avatarHeight = appearance.m_avatarHeight;
213 SetSize(appearance.AvatarSize);
181 214
182 // Copy the attachment, force append mode since that ensures consistency 215 // Copy the attachment, force append mode since that ensures consistency
183 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 216 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
@@ -240,6 +273,21 @@ namespace OpenSim.Framework
240// } 273// }
241 } 274 }
242 275
276 /// <summary>
277 /// Invalidate all of the baked textures in the appearance, useful
278 /// if you know that none are valid
279 /// </summary>
280 public virtual void ResetBakedTextures()
281 {
282 SetDefaultTexture();
283
284 //for (int i = 0; i < BAKE_INDICES.Length; i++)
285 // {
286 // int idx = BAKE_INDICES[i];
287 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
288 // }
289 }
290
243 protected virtual void SetDefaultTexture() 291 protected virtual void SetDefaultTexture()
244 { 292 {
245 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); 293 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
@@ -304,22 +352,33 @@ namespace OpenSim.Framework
304 // made. We determine if any of the visual parameters actually 352 // made. We determine if any of the visual parameters actually
305 // changed to know if the appearance should be saved later 353 // changed to know if the appearance should be saved later
306 bool changed = false; 354 bool changed = false;
307 for (int i = 0; i < AvatarAppearance.VISUALPARAM_COUNT; i++) 355
356 int newsize = visualParams.Length;
357
358 if (newsize != m_visualparams.Length)
359 {
360 changed = true;
361 m_visualparams = (byte[])visualParams.Clone();
362 }
363 else
308 { 364 {
309 if (visualParams[i] != m_visualparams[i]) 365
366 for (int i = 0; i < newsize; i++)
310 { 367 {
311// DEBUG ON 368 if (visualParams[i] != m_visualparams[i])
312// m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", 369 {
313// i,m_visualparams[i],visualParams[i]); 370 // DEBUG ON
314// DEBUG OFF 371 // m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}",
315 m_visualparams[i] = visualParams[i]; 372 // i,m_visualparams[i],visualParams[i]);
316 changed = true; 373 // DEBUG OFF
374 m_visualparams[i] = visualParams[i];
375 changed = true;
376 }
317 } 377 }
318 } 378 }
319
320 // Reset the height if the visual parameters actually changed 379 // Reset the height if the visual parameters actually changed
321 if (changed) 380// if (changed)
322 SetHeight(); 381// SetHeight();
323 382
324 return changed; 383 return changed;
325 } 384 }
@@ -335,6 +394,7 @@ namespace OpenSim.Framework
335 /// </summary> 394 /// </summary>
336 public virtual void SetHeight() 395 public virtual void SetHeight()
337 { 396 {
397/*
338 // Start with shortest possible female avatar height 398 // Start with shortest possible female avatar height
339 m_avatarHeight = 1.14597f; 399 m_avatarHeight = 1.14597f;
340 // Add offset for male avatars 400 // Add offset for male avatars
@@ -347,6 +407,35 @@ namespace OpenSim.Framework
347 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f 407 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f
348 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f 408 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f
349 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; 409 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f;
410*/
411 }
412
413 public void SetSize(Vector3 avSize)
414 {
415 if (avSize.X > 32f)
416 avSize.X = 32f;
417 else if (avSize.X < 0.1f)
418 avSize.X = 0.1f;
419
420 if (avSize.Y > 32f)
421 avSize.Y = 32f;
422 else if (avSize.Y < 0.1f)
423 avSize.Y = 0.1f;
424 if (avSize.Z > 32f)
425 avSize.Z = 32f;
426 else if (avSize.Z < 0.1f)
427 avSize.Z = 0.1f;
428
429 m_avatarSize = avSize;
430 m_avatarBoxSize = avSize;
431 m_avatarBoxSize.Z += AVBOXAJUST;
432 if (m_avatarBoxSize.X < AVBOXMINX)
433 m_avatarBoxSize.X = AVBOXMINX;
434 if (m_avatarBoxSize.Y < AVBOXMINY)
435 m_avatarBoxSize.Y = AVBOXMINY;
436 if (m_avatarBoxSize.Z < AVBOXMINZ)
437 m_avatarBoxSize.Z = AVBOXMINZ;
438 m_avatarHeight = m_avatarSize.Z;
350 } 439 }
351 440
352 public virtual void SetWearable(int wearableId, AvatarWearable wearable) 441 public virtual void SetWearable(int wearableId, AvatarWearable wearable)
@@ -377,7 +466,8 @@ namespace OpenSim.Framework
377 } 466 }
378 467
379 s += "Visual Params: "; 468 s += "Visual Params: ";
380 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) 469 // for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++)
470 for (uint j = 0; j < m_visualparams.Length; j++)
381 s += String.Format("{0},",m_visualparams[j]); 471 s += String.Format("{0},",m_visualparams[j]);
382 s += "\n"; 472 s += "\n";
383 473
@@ -393,19 +483,18 @@ namespace OpenSim.Framework
393 /// </remarks> 483 /// </remarks>
394 public List<AvatarAttachment> GetAttachments() 484 public List<AvatarAttachment> GetAttachments()
395 { 485 {
396 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 486
397 487
398 lock (m_attachments) 488 lock (m_attachments)
399 { 489 {
490 List<AvatarAttachment> alist = new List<AvatarAttachment>();
400 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 491 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
401 { 492 {
402 foreach (AvatarAttachment attach in kvp.Value) 493 foreach (AvatarAttachment attach in kvp.Value)
403 alist.Add(new AvatarAttachment(attach)); 494 alist.Add(new AvatarAttachment(attach));
404 } 495 }
405 } 496 return alist;
406 497 } }
407 return alist;
408 }
409 498
410 internal void AppendAttachment(AvatarAttachment attach) 499 internal void AppendAttachment(AvatarAttachment attach)
411 { 500 {
@@ -534,7 +623,6 @@ namespace OpenSim.Framework
534 return kvp.Key; 623 return kvp.Key;
535 } 624 }
536 } 625 }
537
538 return 0; 626 return 0;
539 } 627 }
540 628
@@ -601,12 +689,14 @@ namespace OpenSim.Framework
601 OSDBinary visualparams = new OSDBinary(m_visualparams); 689 OSDBinary visualparams = new OSDBinary(m_visualparams);
602 data["visualparams"] = visualparams; 690 data["visualparams"] = visualparams;
603 691
604 // Attachments 692 lock (m_attachments)
605 List<AvatarAttachment> attachments = GetAttachments(); 693 {
606 OSDArray attachs = new OSDArray(attachments.Count); 694 // Attachments
607 foreach (AvatarAttachment attach in GetAttachments()) 695 OSDArray attachs = new OSDArray(m_attachments.Count);
608 attachs.Add(attach.Pack()); 696 foreach (AvatarAttachment attach in GetAttachments())
609 data["attachments"] = attachs; 697 attachs.Add(attach.Pack());
698 data["attachments"] = attachs;
699 }
610 700
611 return data; 701 return data;
612 } 702 }
@@ -620,7 +710,8 @@ namespace OpenSim.Framework
620 if ((data != null) && (data["serial"] != null)) 710 if ((data != null) && (data["serial"] != null))
621 m_serial = data["serial"].AsInteger(); 711 m_serial = data["serial"].AsInteger();
622 if ((data != null) && (data["height"] != null)) 712 if ((data != null) && (data["height"] != null))
623 m_avatarHeight = (float)data["height"].AsReal(); 713// m_avatarHeight = (float)data["height"].AsReal();
714 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
624 715
625 try 716 try
626 { 717 {