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.cs165
1 files changed, 135 insertions, 30 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 95e9667..ffc3527 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)
373 {
374 changed = true;
375 m_visualparams = (byte[])visualParams.Clone();
376 }
377 else
308 { 378 {
309 if (visualParams[i] != m_visualparams[i]) 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,19 +497,18 @@ 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>(); 500
397 501
398 lock (m_attachments) 502 lock (m_attachments)
399 { 503 {
504 List<AvatarAttachment> alist = new List<AvatarAttachment>();
400 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 505 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
401 { 506 {
402 foreach (AvatarAttachment attach in kvp.Value) 507 foreach (AvatarAttachment attach in kvp.Value)
403 alist.Add(new AvatarAttachment(attach)); 508 alist.Add(new AvatarAttachment(attach));
404 } 509 }
405 } 510 return alist;
406 511 } }
407 return alist;
408 }
409 512
410 internal void AppendAttachment(AvatarAttachment attach) 513 internal void AppendAttachment(AvatarAttachment attach)
411 { 514 {
@@ -534,7 +637,6 @@ namespace OpenSim.Framework
534 return kvp.Key; 637 return kvp.Key;
535 } 638 }
536 } 639 }
537
538 return 0; 640 return 0;
539 } 641 }
540 642
@@ -601,12 +703,14 @@ namespace OpenSim.Framework
601 OSDBinary visualparams = new OSDBinary(m_visualparams); 703 OSDBinary visualparams = new OSDBinary(m_visualparams);
602 data["visualparams"] = visualparams; 704 data["visualparams"] = visualparams;
603 705
604 // Attachments 706 lock (m_attachments)
605 List<AvatarAttachment> attachments = GetAttachments(); 707 {
606 OSDArray attachs = new OSDArray(attachments.Count); 708 // Attachments
607 foreach (AvatarAttachment attach in GetAttachments()) 709 OSDArray attachs = new OSDArray(m_attachments.Count);
608 attachs.Add(attach.Pack()); 710 foreach (AvatarAttachment attach in GetAttachments())
609 data["attachments"] = attachs; 711 attachs.Add(attach.Pack());
712 data["attachments"] = attachs;
713 }
610 714
611 return data; 715 return data;
612 } 716 }
@@ -620,7 +724,8 @@ namespace OpenSim.Framework
620 if ((data != null) && (data["serial"] != null)) 724 if ((data != null) && (data["serial"] != null))
621 m_serial = data["serial"].AsInteger(); 725 m_serial = data["serial"].AsInteger();
622 if ((data != null) && (data["height"] != null)) 726 if ((data != null) && (data["height"] != null))
623 m_avatarHeight = (float)data["height"].AsReal(); 727// m_avatarHeight = (float)data["height"].AsReal();
728 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
624 729
625 try 730 try
626 { 731 {