aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 95e9667..ba6d87d 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)
@@ -534,7 +636,6 @@ namespace OpenSim.Framework
534 return kvp.Key; 636 return kvp.Key;
535 } 637 }
536 } 638 }
537
538 return 0; 639 return 0;
539 } 640 }
540 641
@@ -601,12 +702,14 @@ namespace OpenSim.Framework
601 OSDBinary visualparams = new OSDBinary(m_visualparams); 702 OSDBinary visualparams = new OSDBinary(m_visualparams);
602 data["visualparams"] = visualparams; 703 data["visualparams"] = visualparams;
603 704
604 // Attachments 705 lock (m_attachments)
605 List<AvatarAttachment> attachments = GetAttachments(); 706 {
606 OSDArray attachs = new OSDArray(attachments.Count); 707 // Attachments
607 foreach (AvatarAttachment attach in GetAttachments()) 708 OSDArray attachs = new OSDArray(m_attachments.Count);
608 attachs.Add(attach.Pack()); 709 foreach (AvatarAttachment attach in GetAttachments())
609 data["attachments"] = attachs; 710 attachs.Add(attach.Pack());
711 data["attachments"] = attachs;
712 }
610 713
611 return data; 714 return data;
612 } 715 }
@@ -620,7 +723,8 @@ namespace OpenSim.Framework
620 if ((data != null) && (data["serial"] != null)) 723 if ((data != null) && (data["serial"] != null))
621 m_serial = data["serial"].AsInteger(); 724 m_serial = data["serial"].AsInteger();
622 if ((data != null) && (data["height"] != null)) 725 if ((data != null) && (data["height"] != null))
623 m_avatarHeight = (float)data["height"].AsReal(); 726// m_avatarHeight = (float)data["height"].AsReal();
727 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
624 728
625 try 729 try
626 { 730 {
@@ -1453,7 +1557,58 @@ namespace OpenSim.Framework
1453 SHAPE_EYELID_INNER_CORNER_UP = 214, 1557 SHAPE_EYELID_INNER_CORNER_UP = 214,
1454 SKIRT_SKIRT_RED = 215, 1558 SKIRT_SKIRT_RED = 215,
1455 SKIRT_SKIRT_GREEN = 216, 1559 SKIRT_SKIRT_GREEN = 216,
1456 SKIRT_SKIRT_BLUE = 217 1560 SKIRT_SKIRT_BLUE = 217,
1561
1562 /// <summary>
1563 /// Avatar Physics section. These are 0 type visual params which get transmitted.
1564 /// </summary>
1565
1566 /// <summary>
1567 /// Breast Part 1
1568 /// </summary>
1569 BREAST_PHYSICS_MASS = 218,
1570 BREAST_PHYSICS_GRAVITY = 219,
1571 BREAST_PHYSICS_DRAG = 220,
1572 BREAST_PHYSICS_UPDOWN_MAX_EFFECT = 221,
1573 BREAST_PHYSICS_UPDOWN_SPRING = 222,
1574 BREAST_PHYSICS_UPDOWN_GAIN = 223,
1575 BREAST_PHYSICS_UPDOWN_DAMPING = 224,
1576 BREAST_PHYSICS_INOUT_MAX_EFFECT = 225,
1577 BREAST_PHYSICS_INOUT_SPRING = 226,
1578 BREAST_PHYSICS_INOUT_GAIN = 227,
1579 BREAST_PHYSICS_INOUT_DAMPING = 228,
1580 /// <summary>
1581 /// Belly
1582 /// </summary>
1583 BELLY_PHYISCS_MASS = 229,
1584 BELLY_PHYSICS_GRAVITY = 230,
1585 BELLY_PHYSICS_DRAG = 231,
1586 BELLY_PHYISCS_UPDOWN_MAX_EFFECT = 232,
1587 BELLY_PHYSICS_UPDOWN_SPRING = 233,
1588 BELLY_PHYSICS_UPDOWN_GAIN = 234,
1589 BELLY_PHYSICS_UPDOWN_DAMPING = 235,
1590
1591 /// <summary>
1592 /// Butt
1593 /// </summary>
1594 BUTT_PHYSICS_MASS = 236,
1595 BUTT_PHYSICS_GRAVITY = 237,
1596 BUTT_PHYSICS_DRAG = 238,
1597 BUTT_PHYSICS_UPDOWN_MAX_EFFECT = 239,
1598 BUTT_PHYSICS_UPDOWN_SPRING = 240,
1599 BUTT_PHYSICS_UPDOWN_GAIN = 241,
1600 BUTT_PHYSICS_UPDOWN_DAMPING = 242,
1601 BUTT_PHYSICS_LEFTRIGHT_MAX_EFFECT = 243,
1602 BUTT_PHYSICS_LEFTRIGHT_SPRING = 244,
1603 BUTT_PHYSICS_LEFTRIGHT_GAIN = 245,
1604 BUTT_PHYSICS_LEFTRIGHT_DAMPING = 246,
1605 /// <summary>
1606 /// Breast Part 2
1607 /// </summary>
1608 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
1609 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
1610 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
1611 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250
1457 } 1612 }
1458 #endregion 1613 #endregion
1459 } 1614 }