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.cs217
1 files changed, 186 insertions, 31 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 494ae5e..b7a0adf 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,12 @@ 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;
69 protected WearableCacheItem[] m_cacheitems;
70 protected bool m_cacheItemsDirty = true;
56 71
57 public virtual int Serial 72 public virtual int Serial
58 { 73 {
@@ -66,6 +81,21 @@ namespace OpenSim.Framework
66 set { m_visualparams = value; } 81 set { m_visualparams = value; }
67 } 82 }
68 83
84 public virtual Vector3 AvatarSize
85 {
86 get { return m_avatarSize; }
87 }
88
89 public virtual Vector3 AvatarBoxSize
90 {
91 get { return m_avatarBoxSize; }
92 }
93
94 public virtual float AvatarFeetOffset
95 {
96 get { return m_avatarFeetOffset + m_avatarAnimOffset; }
97 }
98
69 public virtual Primitive.TextureEntry Texture 99 public virtual Primitive.TextureEntry Texture
70 { 100 {
71 get { return m_texture; } 101 get { return m_texture; }
@@ -87,6 +117,18 @@ namespace OpenSim.Framework
87 get { return m_avatarHeight; } 117 get { return m_avatarHeight; }
88 set { m_avatarHeight = value; } 118 set { m_avatarHeight = value; }
89 } 119 }
120
121 public virtual WearableCacheItem[] WearableCacheItems
122 {
123 get { return m_cacheitems; }
124 set { m_cacheitems = value; }
125 }
126
127 public virtual bool WearableCacheItemsDirty
128 {
129 get { return m_cacheItemsDirty; }
130 set { m_cacheItemsDirty = value; }
131 }
90 132
91 public AvatarAppearance() 133 public AvatarAppearance()
92 { 134 {
@@ -96,7 +138,8 @@ namespace OpenSim.Framework
96 SetDefaultWearables(); 138 SetDefaultWearables();
97 SetDefaultTexture(); 139 SetDefaultTexture();
98 SetDefaultParams(); 140 SetDefaultParams();
99 SetHeight(); 141// SetHeight();
142 SetSize(new Vector3(0.45f,0.6f,1.9f));
100 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 143 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
101 } 144 }
102 145
@@ -105,7 +148,7 @@ namespace OpenSim.Framework
105// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); 148// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap");
106 149
107 Unpack(map); 150 Unpack(map);
108 SetHeight(); 151// SetHeight(); done in Unpack
109 } 152 }
110 153
111 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) 154 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
@@ -129,7 +172,9 @@ namespace OpenSim.Framework
129 else 172 else
130 SetDefaultParams(); 173 SetDefaultParams();
131 174
132 SetHeight(); 175// SetHeight();
176 if(m_avatarHeight == 0)
177 SetSize(new Vector3(0.45f,0.6f,1.9f));
133 178
134 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 179 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
135 } 180 }
@@ -148,7 +193,8 @@ namespace OpenSim.Framework
148 SetDefaultWearables(); 193 SetDefaultWearables();
149 SetDefaultTexture(); 194 SetDefaultTexture();
150 SetDefaultParams(); 195 SetDefaultParams();
151 SetHeight(); 196// SetHeight();
197 SetSize(new Vector3(0.45f, 0.6f, 1.9f));
152 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 198 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
153 199
154 return; 200 return;
@@ -177,7 +223,8 @@ namespace OpenSim.Framework
177 if (appearance.VisualParams != null) 223 if (appearance.VisualParams != null)
178 m_visualparams = (byte[])appearance.VisualParams.Clone(); 224 m_visualparams = (byte[])appearance.VisualParams.Clone();
179 225
180 m_avatarHeight = appearance.m_avatarHeight; 226// m_avatarHeight = appearance.m_avatarHeight;
227 SetSize(appearance.AvatarSize);
181 228
182 // Copy the attachment, force append mode since that ensures consistency 229 // Copy the attachment, force append mode since that ensures consistency
183 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 230 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
@@ -240,6 +287,21 @@ namespace OpenSim.Framework
240// } 287// }
241 } 288 }
242 289
290 /// <summary>
291 /// Invalidate all of the baked textures in the appearance, useful
292 /// if you know that none are valid
293 /// </summary>
294 public virtual void ResetBakedTextures()
295 {
296 SetDefaultTexture();
297
298 //for (int i = 0; i < BAKE_INDICES.Length; i++)
299 // {
300 // int idx = BAKE_INDICES[i];
301 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
302 // }
303 }
304
243 protected virtual void SetDefaultTexture() 305 protected virtual void SetDefaultTexture()
244 { 306 {
245 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); 307 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
@@ -304,22 +366,33 @@ namespace OpenSim.Framework
304 // made. We determine if any of the visual parameters actually 366 // made. We determine if any of the visual parameters actually
305 // changed to know if the appearance should be saved later 367 // changed to know if the appearance should be saved later
306 bool changed = false; 368 bool changed = false;
307 for (int i = 0; i < AvatarAppearance.VISUALPARAM_COUNT; i++) 369
370 int newsize = visualParams.Length;
371
372 if (newsize != m_visualparams.Length)
308 { 373 {
309 if (visualParams[i] != m_visualparams[i]) 374 changed = true;
375 m_visualparams = (byte[])visualParams.Clone();
376 }
377 else
378 {
379
380 for (int i = 0; i < newsize; i++)
310 { 381 {
311// DEBUG ON 382 if (visualParams[i] != m_visualparams[i])
312// m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", 383 {
313// i,m_visualparams[i],visualParams[i]); 384 // DEBUG ON
314// DEBUG OFF 385 // m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}",
315 m_visualparams[i] = visualParams[i]; 386 // i,m_visualparams[i],visualParams[i]);
316 changed = true; 387 // DEBUG OFF
388 m_visualparams[i] = visualParams[i];
389 changed = true;
390 }
317 } 391 }
318 } 392 }
319
320 // Reset the height if the visual parameters actually changed 393 // Reset the height if the visual parameters actually changed
321 if (changed) 394// if (changed)
322 SetHeight(); 395// SetHeight();
323 396
324 return changed; 397 return changed;
325 } 398 }
@@ -335,6 +408,7 @@ namespace OpenSim.Framework
335 /// </summary> 408 /// </summary>
336 public virtual void SetHeight() 409 public virtual void SetHeight()
337 { 410 {
411/*
338 // Start with shortest possible female avatar height 412 // Start with shortest possible female avatar height
339 m_avatarHeight = 1.14597f; 413 m_avatarHeight = 1.14597f;
340 // Add offset for male avatars 414 // Add offset for male avatars
@@ -347,6 +421,35 @@ namespace OpenSim.Framework
347 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f 421 + 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 422 + 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; 423 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f;
424*/
425 }
426
427 public void SetSize(Vector3 avSize)
428 {
429 if (avSize.X > 32f)
430 avSize.X = 32f;
431 else if (avSize.X < 0.1f)
432 avSize.X = 0.1f;
433
434 if (avSize.Y > 32f)
435 avSize.Y = 32f;
436 else if (avSize.Y < 0.1f)
437 avSize.Y = 0.1f;
438 if (avSize.Z > 32f)
439 avSize.Z = 32f;
440 else if (avSize.Z < 0.1f)
441 avSize.Z = 0.1f;
442
443 m_avatarSize = avSize;
444 m_avatarBoxSize = avSize;
445 m_avatarBoxSize.Z += AVBOXAJUST;
446 if (m_avatarBoxSize.X < AVBOXMINX)
447 m_avatarBoxSize.X = AVBOXMINX;
448 if (m_avatarBoxSize.Y < AVBOXMINY)
449 m_avatarBoxSize.Y = AVBOXMINY;
450 if (m_avatarBoxSize.Z < AVBOXMINZ)
451 m_avatarBoxSize.Z = AVBOXMINZ;
452 m_avatarHeight = m_avatarSize.Z;
350 } 453 }
351 454
352 public virtual void SetWearable(int wearableId, AvatarWearable wearable) 455 public virtual void SetWearable(int wearableId, AvatarWearable wearable)
@@ -377,7 +480,8 @@ namespace OpenSim.Framework
377 } 480 }
378 481
379 s += "Visual Params: "; 482 s += "Visual Params: ";
380 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) 483 // for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++)
484 for (uint j = 0; j < m_visualparams.Length; j++)
381 s += String.Format("{0},",m_visualparams[j]); 485 s += String.Format("{0},",m_visualparams[j]);
382 s += "\n"; 486 s += "\n";
383 487
@@ -393,18 +497,16 @@ namespace OpenSim.Framework
393 /// </remarks> 497 /// </remarks>
394 public List<AvatarAttachment> GetAttachments() 498 public List<AvatarAttachment> GetAttachments()
395 { 499 {
396 List<AvatarAttachment> alist = new List<AvatarAttachment>();
397
398 lock (m_attachments) 500 lock (m_attachments)
399 { 501 {
502 List<AvatarAttachment> alist = new List<AvatarAttachment>();
400 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 503 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
401 { 504 {
402 foreach (AvatarAttachment attach in kvp.Value) 505 foreach (AvatarAttachment attach in kvp.Value)
403 alist.Add(new AvatarAttachment(attach)); 506 alist.Add(new AvatarAttachment(attach));
404 } 507 }
405 } 508 return alist;
406 509 }
407 return alist;
408 } 510 }
409 511
410 internal void AppendAttachment(AvatarAttachment attach) 512 internal void AppendAttachment(AvatarAttachment attach)
@@ -548,7 +650,6 @@ namespace OpenSim.Framework
548 return kvp.Key; 650 return kvp.Key;
549 } 651 }
550 } 652 }
551
552 return 0; 653 return 0;
553 } 654 }
554 655
@@ -619,12 +720,14 @@ namespace OpenSim.Framework
619 OSDBinary visualparams = new OSDBinary(m_visualparams); 720 OSDBinary visualparams = new OSDBinary(m_visualparams);
620 data["visualparams"] = visualparams; 721 data["visualparams"] = visualparams;
621 722
622 // Attachments 723 lock (m_attachments)
623 List<AvatarAttachment> attachments = GetAttachments(); 724 {
624 OSDArray attachs = new OSDArray(attachments.Count); 725 // Attachments
625 foreach (AvatarAttachment attach in GetAttachments()) 726 OSDArray attachs = new OSDArray(m_attachments.Count);
626 attachs.Add(attach.Pack()); 727 foreach (AvatarAttachment attach in GetAttachments())
627 data["attachments"] = attachs; 728 attachs.Add(attach.Pack());
729 data["attachments"] = attachs;
730 }
628 731
629 return data; 732 return data;
630 } 733 }
@@ -638,7 +741,8 @@ namespace OpenSim.Framework
638 if ((data != null) && (data["serial"] != null)) 741 if ((data != null) && (data["serial"] != null))
639 m_serial = data["serial"].AsInteger(); 742 m_serial = data["serial"].AsInteger();
640 if ((data != null) && (data["height"] != null)) 743 if ((data != null) && (data["height"] != null))
641 m_avatarHeight = (float)data["height"].AsReal(); 744// m_avatarHeight = (float)data["height"].AsReal();
745 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
642 746
643 try 747 try
644 { 748 {
@@ -1471,7 +1575,58 @@ namespace OpenSim.Framework
1471 SHAPE_EYELID_INNER_CORNER_UP = 214, 1575 SHAPE_EYELID_INNER_CORNER_UP = 214,
1472 SKIRT_SKIRT_RED = 215, 1576 SKIRT_SKIRT_RED = 215,
1473 SKIRT_SKIRT_GREEN = 216, 1577 SKIRT_SKIRT_GREEN = 216,
1474 SKIRT_SKIRT_BLUE = 217 1578 SKIRT_SKIRT_BLUE = 217,
1579
1580 /// <summary>
1581 /// Avatar Physics section. These are 0 type visual params which get transmitted.
1582 /// </summary>
1583
1584 /// <summary>
1585 /// Breast Part 1
1586 /// </summary>
1587 BREAST_PHYSICS_MASS = 218,
1588 BREAST_PHYSICS_GRAVITY = 219,
1589 BREAST_PHYSICS_DRAG = 220,
1590 BREAST_PHYSICS_UPDOWN_MAX_EFFECT = 221,
1591 BREAST_PHYSICS_UPDOWN_SPRING = 222,
1592 BREAST_PHYSICS_UPDOWN_GAIN = 223,
1593 BREAST_PHYSICS_UPDOWN_DAMPING = 224,
1594 BREAST_PHYSICS_INOUT_MAX_EFFECT = 225,
1595 BREAST_PHYSICS_INOUT_SPRING = 226,
1596 BREAST_PHYSICS_INOUT_GAIN = 227,
1597 BREAST_PHYSICS_INOUT_DAMPING = 228,
1598 /// <summary>
1599 /// Belly
1600 /// </summary>
1601 BELLY_PHYISCS_MASS = 229,
1602 BELLY_PHYSICS_GRAVITY = 230,
1603 BELLY_PHYSICS_DRAG = 231,
1604 BELLY_PHYISCS_UPDOWN_MAX_EFFECT = 232,
1605 BELLY_PHYSICS_UPDOWN_SPRING = 233,
1606 BELLY_PHYSICS_UPDOWN_GAIN = 234,
1607 BELLY_PHYSICS_UPDOWN_DAMPING = 235,
1608
1609 /// <summary>
1610 /// Butt
1611 /// </summary>
1612 BUTT_PHYSICS_MASS = 236,
1613 BUTT_PHYSICS_GRAVITY = 237,
1614 BUTT_PHYSICS_DRAG = 238,
1615 BUTT_PHYSICS_UPDOWN_MAX_EFFECT = 239,
1616 BUTT_PHYSICS_UPDOWN_SPRING = 240,
1617 BUTT_PHYSICS_UPDOWN_GAIN = 241,
1618 BUTT_PHYSICS_UPDOWN_DAMPING = 242,
1619 BUTT_PHYSICS_LEFTRIGHT_MAX_EFFECT = 243,
1620 BUTT_PHYSICS_LEFTRIGHT_SPRING = 244,
1621 BUTT_PHYSICS_LEFTRIGHT_GAIN = 245,
1622 BUTT_PHYSICS_LEFTRIGHT_DAMPING = 246,
1623 /// <summary>
1624 /// Breast Part 2
1625 /// </summary>
1626 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
1627 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
1628 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
1629 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250
1475 } 1630 }
1476 #endregion 1631 #endregion
1477 } 1632 }