aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMaster ScienceSim2010-10-20 16:17:54 -0700
committerMaster ScienceSim2010-10-20 16:17:54 -0700
commitb1c8d0588829dfa76f89460eeb8406d9c4fc479f (patch)
tree463cbb0bf2eab5c7e7f98ebdc0dc7113dea56688 /OpenSim
parentMerge branch 'master' of /var/git/opensim/ (diff)
downloadopensim-SC-b1c8d0588829dfa76f89460eeb8406d9c4fc479f.zip
opensim-SC-b1c8d0588829dfa76f89460eeb8406d9c4fc479f.tar.gz
opensim-SC-b1c8d0588829dfa76f89460eeb8406d9c4fc479f.tar.bz2
opensim-SC-b1c8d0588829dfa76f89460eeb8406d9c4fc479f.tar.xz
Major refactoring of appearance handling.
AvatarService -- add two new methods, GetAppearance and SetAppearance to get around the lossy encoding in AvatarData. Preseve the old functions to avoid changing the behavior for ROBUST services. AvatarAppearance -- major refactor, moved the various encoding methods used by AgentCircuitData, ClientAgentUpdate and ScenePresence into one location. Changed initialization. AvatarAttachments -- added a class specifically to handle attachments in preparation for additional functionality that will be needed for viewer 2. AvatarFactory -- removed a number of unused or methods duplicated in other locations. Moved in all appearance event handling from ScenePresence. Required a change to IClientAPI that propogated throughout all the IClientAPI implementations.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs28
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs4
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs4
-rw-r--r--OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs2
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs61
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs839
-rw-r--r--OpenSim/Framework/AvatarAttachment.cs (renamed from OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs)50
-rw-r--r--OpenSim/Framework/AvatarWearable.cs46
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs4
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs70
-rw-r--r--OpenSim/Framework/IClientAPI.cs6
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitDataTest.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs237
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs11
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs163
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs16
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs14
-rw-r--r--OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs12
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs82
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs32
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs10
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
28 files changed, 955 insertions, 779 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index aeed467..0589748 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -1472,12 +1472,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1472 { 1472 {
1473 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source); 1473 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source);
1474 Scene scene = m_application.SceneManager.CurrentOrFirstScene; 1474 Scene scene = m_application.SceneManager.CurrentOrFirstScene;
1475 AvatarAppearance avatarAppearance = null;
1476 AvatarData avatar = scene.AvatarService.GetAvatar(source);
1477 if (avatar != null)
1478 avatarAppearance = avatar.ToAvatarAppearance(source);
1479 1475
1480 // If the model has no associated appearance we're done. 1476 // If the model has no associated appearance we're done.
1477 AvatarAppearance avatarAppearance = scene.AvatarService.GetAppearance(source);
1481 if (avatarAppearance == null) 1478 if (avatarAppearance == null)
1482 return; 1479 return;
1483 1480
@@ -1491,8 +1488,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1491 { 1488 {
1492 CopyWearablesAndAttachments(destination, source, avatarAppearance); 1489 CopyWearablesAndAttachments(destination, source, avatarAppearance);
1493 1490
1494 AvatarData avatarData = new AvatarData(avatarAppearance); 1491 scene.AvatarService.SetAppearance(destination, avatarAppearance);
1495 scene.AvatarService.SetAvatar(destination, avatarData);
1496 } 1492 }
1497 catch (Exception e) 1493 catch (Exception e)
1498 { 1494 {
@@ -1523,8 +1519,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1523 } 1519 }
1524 } 1520 }
1525 1521
1526 AvatarData avatarData = new AvatarData(avatarAppearance); 1522 scene.AvatarService.SetAppearance(destination, avatarAppearance);
1527 scene.AvatarService.SetAvatar(destination, avatarData);
1528 } 1523 }
1529 catch (Exception e) 1524 catch (Exception e)
1530 { 1525 {
@@ -1619,12 +1614,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1619 } 1614 }
1620 1615
1621 // Attachments 1616 // Attachments
1622 Dictionary<int, UUID[]> attachments = avatarAppearance.GetAttachmentDictionary(); 1617 Dictionary<int, AvatarAttachment> attachments = avatarAppearance.Attachments;
1623 1618
1624 foreach (KeyValuePair<int, UUID[]> attachment in attachments) 1619 foreach (KeyValuePair<int, AvatarAttachment> attachment in attachments)
1625 { 1620 {
1626 int attachpoint = attachment.Key; 1621 int attachpoint = attachment.Value.AttachPoint;
1627 UUID itemID = attachment.Value[0]; 1622 UUID itemID = attachment.Value.ItemID;
1628 1623
1629 if (itemID != UUID.Zero) 1624 if (itemID != UUID.Zero)
1630 { 1625 {
@@ -1908,10 +1903,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1908 if (include) 1903 if (include)
1909 { 1904 {
1910 // Setup for appearance processing 1905 // Setup for appearance processing
1911 AvatarData avatarData = scene.AvatarService.GetAvatar(ID); 1906 avatarAppearance = scene.AvatarService.GetAppearance(ID);
1912 if (avatarData != null) 1907 if (avatarAppearance == null)
1913 avatarAppearance = avatarData.ToAvatarAppearance(ID);
1914 else
1915 avatarAppearance = new AvatarAppearance(); 1908 avatarAppearance = new AvatarAppearance();
1916 1909
1917 AvatarWearable[] wearables = avatarAppearance.Wearables; 1910 AvatarWearable[] wearables = avatarAppearance.Wearables;
@@ -2076,8 +2069,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2076 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName); 2069 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName);
2077 } // foreach outfit 2070 } // foreach outfit
2078 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); 2071 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
2079 AvatarData avatarData2 = new AvatarData(avatarAppearance); 2072 scene.AvatarService.SetAppearance(ID, avatarAppearance);
2080 scene.AvatarService.SetAvatar(ID, avatarData2);
2081 } 2073 }
2082 catch (Exception e) 2074 catch (Exception e)
2083 { 2075 {
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index af9478e..19331c6 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -596,7 +596,7 @@ namespace OpenSim.Client.MXP.ClientStack
596 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 596 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
597 public event DeRezObject OnDeRezObject; 597 public event DeRezObject OnDeRezObject;
598 public event Action<IClientAPI> OnRegionHandShakeReply; 598 public event Action<IClientAPI> OnRegionHandShakeReply;
599 public event GenericCall2 OnRequestWearables; 599 public event GenericCall1 OnRequestWearables;
600 public event GenericCall1 OnCompleteMovementToRegion; 600 public event GenericCall1 OnCompleteMovementToRegion;
601 public event UpdateAgent OnPreAgentUpdate; 601 public event UpdateAgent OnPreAgentUpdate;
602 public event UpdateAgent OnAgentUpdate; 602 public event UpdateAgent OnAgentUpdate;
@@ -861,7 +861,7 @@ namespace OpenSim.Client.MXP.ClientStack
861 OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene; 861 OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene;
862 AvatarAppearance appearance; 862 AvatarAppearance appearance;
863 scene.GetAvatarAppearance(this,out appearance); 863 scene.GetAvatarAppearance(this,out appearance);
864 OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); 864 OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
865 } 865 }
866 866
867 public void Stop() 867 public void Stop()
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index 7056e01..dcecb8b 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -533,9 +533,7 @@ namespace OpenSim.Client.MXP.PacketHandler
533 agent.InventoryFolder = UUID.Zero; 533 agent.InventoryFolder = UUID.Zero;
534 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position 534 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
535 agent.CapsPath = "http://localhost/"; 535 agent.CapsPath = "http://localhost/";
536 AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID); 536 agent.Appearance = scene.AvatarService.GetAppearance(account.PrincipalID);
537 if (avatar != null)
538 agent.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); //userService.GetUserAppearance(userProfile.ID);
539 537
540 if (agent.Appearance == null) 538 if (agent.Appearance == null)
541 { 539 {
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
index 99a46dc..0d23232 100644
--- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
+++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
@@ -245,7 +245,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
245 public event TeleportLandmarkRequest OnTeleportLandmarkRequest = delegate { }; 245 public event TeleportLandmarkRequest OnTeleportLandmarkRequest = delegate { };
246 public event DeRezObject OnDeRezObject = delegate { }; 246 public event DeRezObject OnDeRezObject = delegate { };
247 public event Action<IClientAPI> OnRegionHandShakeReply = delegate { }; 247 public event Action<IClientAPI> OnRegionHandShakeReply = delegate { };
248 public event GenericCall2 OnRequestWearables = delegate { }; 248 public event GenericCall1 OnRequestWearables = delegate { };
249 public event GenericCall1 OnCompleteMovementToRegion = delegate { }; 249 public event GenericCall1 OnCompleteMovementToRegion = delegate { };
250 public event UpdateAgent OnPreAgentUpdate; 250 public event UpdateAgent OnPreAgentUpdate;
251 public event UpdateAgent OnAgentUpdate = delegate { }; 251 public event UpdateAgent OnAgentUpdate = delegate { };
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 4f89d78..be98380 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31using OpenMetaverse.StructuredData; 33using OpenMetaverse.StructuredData;
32 34
@@ -38,6 +40,12 @@ namespace OpenSim.Framework
38 /// </summary> 40 /// </summary>
39 public class AgentCircuitData 41 public class AgentCircuitData
40 { 42 {
43// DEBUG ON
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47// DEBUG OFF
48
41 /// <summary> 49 /// <summary>
42 /// Avatar Unique Agent Identifier 50 /// Avatar Unique Agent Identifier
43 /// </summary> 51 /// </summary>
@@ -205,6 +213,7 @@ namespace OpenSim.Framework
205 args["mac"] = OSD.FromString(Mac); 213 args["mac"] = OSD.FromString(Mac);
206 args["id0"] = OSD.FromString(Id0); 214 args["id0"] = OSD.FromString(Id0);
207 215
216/*
208 if (Appearance != null) 217 if (Appearance != null)
209 { 218 {
210 //System.Console.WriteLine("XXX Before packing Wearables"); 219 //System.Console.WriteLine("XXX Before packing Wearables");
@@ -221,20 +230,26 @@ namespace OpenSim.Framework
221 } 230 }
222 231
223 //System.Console.WriteLine("XXX Before packing Attachments"); 232 //System.Console.WriteLine("XXX Before packing Attachments");
224 Dictionary<int, UUID[]> attachments = Appearance.GetAttachmentDictionary(); 233 Dictionary<int, AvatarAttachment> attachments = Appearance.Attachments;
225 if ((attachments != null) && (attachments.Count > 0)) 234 if ((attachments != null) && (attachments.Count > 0))
226 { 235 {
227 OSDArray attachs = new OSDArray(attachments.Count); 236 OSDArray attachs = new OSDArray(attachments.Count);
228 foreach (KeyValuePair<int, UUID[]> kvp in attachments) 237 foreach (KeyValuePair<int, AvatarAttachment> kvp in attachments)
229 { 238 {
230 AttachmentData adata = new AttachmentData(kvp.Key, kvp.Value[0], kvp.Value[1]); 239 AvatarAttachment adata = new AvatarAttachment(kvp.Value);
231 attachs.Add(adata.PackUpdateMessage()); 240 attachs.Add(adata.Pack());
232 //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]); 241 //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]);
233 } 242 }
234 args["attachments"] = attachs; 243 args["attachments"] = attachs;
235 } 244 }
236 } 245 }
237 246*/
247 if (Appearance != null)
248 {
249 OSDMap appmap = Appearance.Pack();
250 args["packed_appearance"] = appmap;
251 }
252
238 if (ServiceURLs != null && ServiceURLs.Count > 0) 253 if (ServiceURLs != null && ServiceURLs.Count > 0)
239 { 254 {
240 OSDArray urls = new OSDArray(ServiceURLs.Count * 2); 255 OSDArray urls = new OSDArray(ServiceURLs.Count * 2);
@@ -317,9 +332,37 @@ namespace OpenSim.Framework
317 if (args["start_pos"] != null) 332 if (args["start_pos"] != null)
318 Vector3.TryParse(args["start_pos"].AsString(), out startpos); 333 Vector3.TryParse(args["start_pos"].AsString(), out startpos);
319 334
335// DEBUG ON
336 m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}",AgentID,child,startpos.ToString());
337// DEBUG OFF
338
339 try {
340 // Unpack various appearance elements
320 Appearance = new AvatarAppearance(AgentID); 341 Appearance = new AvatarAppearance(AgentID);
342 if (args["packed_appearance"] != null)
343 {
344 if (args["packed_appearance"].Type == OSDType.Map)
345 {
346 Appearance.Unpack((OSDMap)args["packed_appearance"]);
347 m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
348 }
349 else
350 m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString());
351 }
352// DEBUG ON
353 else
354 m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
355// DEBUG OFF
356 } catch (Exception e)
357 {
358 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
359 }
360
361
362/*
321 if (args["appearance_serial"] != null) 363 if (args["appearance_serial"] != null)
322 Appearance.Serial = args["appearance_serial"].AsInteger(); 364 Appearance.Serial = args["appearance_serial"].AsInteger();
365
323 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) 366 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
324 { 367 {
325 OSDArray wears = (OSDArray)(args["wearables"]); 368 OSDArray wears = (OSDArray)(args["wearables"]);
@@ -328,23 +371,23 @@ namespace OpenSim.Framework
328 Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); 371 Appearance.Wearables[i].ItemID = wears[i*2].AsUUID();
329 Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); 372 Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID();
330 } 373 }
331 } 374 }
332 375
333 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 376 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
334 { 377 {
335 OSDArray attachs = (OSDArray)(args["attachments"]); 378 OSDArray attachs = (OSDArray)(args["attachments"]);
336 AttachmentData[] attachments = new AttachmentData[attachs.Count]; 379 AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count];
337 int i = 0; 380 int i = 0;
338 foreach (OSD o in attachs) 381 foreach (OSD o in attachs)
339 { 382 {
340 if (o.Type == OSDType.Map) 383 if (o.Type == OSDType.Map)
341 { 384 {
342 attachments[i++] = new AttachmentData((OSDMap)o); 385 attachments[i++] = new AvatarAttachment((OSDMap)o);
343 } 386 }
344 } 387 }
345 Appearance.SetAttachments(attachments); 388 Appearance.SetAttachments(attachments);
346 } 389 }
347 390*/
348 ServiceURLs = new Dictionary<string, object>(); 391 ServiceURLs = new Dictionary<string, object>();
349 if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) 392 if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
350 { 393 {
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 5da8ba1..55646dd 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -26,9 +26,12 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
29using System.Collections; 30using System.Collections;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using OpenMetaverse; 32using OpenMetaverse;
33using OpenMetaverse.StructuredData;
34using log4net;
32 35
33namespace OpenSim.Framework 36namespace OpenSim.Framework
34{ 37{
@@ -37,48 +40,26 @@ namespace OpenSim.Framework
37 /// </summary> 40 /// </summary>
38 public class AvatarAppearance 41 public class AvatarAppearance
39 { 42 {
40 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 // these are guessed at by the list here -
43 // http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
44 // correct them over time for when were are wrong.
45 public readonly static int BODY = 0;
46 public readonly static int SKIN = 1;
47 public readonly static int HAIR = 2;
48 public readonly static int EYES = 3;
49 public readonly static int SHIRT = 4;
50 public readonly static int PANTS = 5;
51 public readonly static int SHOES = 6;
52 public readonly static int SOCKS = 7;
53 public readonly static int JACKET = 8;
54 public readonly static int GLOVES = 9;
55 public readonly static int UNDERSHIRT = 10;
56 public readonly static int UNDERPANTS = 11;
57 public readonly static int SKIRT = 12;
58
59 private readonly static int MAX_WEARABLES = 13;
60
61 private static UUID BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
62 private static UUID BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
63 private static UUID SKIN_ASSET = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb");
64 private static UUID SKIN_ITEM = new UUID("77c41e39-38f9-f75a-024e-585989bfabc9");
65 private static UUID SHIRT_ASSET = new UUID("00000000-38f9-1111-024e-222222111110");
66 private static UUID SHIRT_ITEM = new UUID("77c41e39-38f9-f75a-0000-585989bf0000");
67 private static UUID PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120");
68 private static UUID PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111");
69 private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66");
70 private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66");
71 44
72 public readonly static int VISUALPARAM_COUNT = 218; 45 public readonly static int VISUALPARAM_COUNT = 218;
73 46
47 public readonly static int TEXTURE_COUNT = 21;
48
74 protected UUID m_owner; 49 protected UUID m_owner;
50 protected int m_serial = 1;
51 protected byte[] m_visualparams;
52 protected Primitive.TextureEntry m_texture;
53 protected AvatarWearable[] m_wearables;
54 protected Dictionary<int, AvatarAttachment> m_attachments;
55 protected float m_avatarHeight = 0;
56 protected float m_hipOffset = 0;
75 57
76 public virtual UUID Owner 58 public virtual UUID Owner
77 { 59 {
78 get { return m_owner; } 60 get { return m_owner; }
79 set { m_owner = value; } 61 set { m_owner = value; }
80 } 62 }
81 protected int m_serial = 1;
82 63
83 public virtual int Serial 64 public virtual int Serial
84 { 65 {
@@ -86,15 +67,17 @@ namespace OpenSim.Framework
86 set { m_serial = value; } 67 set { m_serial = value; }
87 } 68 }
88 69
89 protected byte[] m_visualparams;
90
91 public virtual byte[] VisualParams 70 public virtual byte[] VisualParams
92 { 71 {
93 get { return m_visualparams; } 72 get { return m_visualparams; }
94 set { m_visualparams = value; } 73 set { m_visualparams = value; }
95 } 74 }
96 75
97 protected AvatarWearable[] m_wearables; 76 public virtual Primitive.TextureEntry Texture
77 {
78 get { return m_texture; }
79 set { m_texture = value; }
80 }
98 81
99 public virtual AvatarWearable[] Wearables 82 public virtual AvatarWearable[] Wearables
100 { 83 {
@@ -102,287 +85,363 @@ namespace OpenSim.Framework
102 set { m_wearables = value; } 85 set { m_wearables = value; }
103 } 86 }
104 87
88 public virtual Dictionary<int, AvatarAttachment> Attachments
89 {
90 get { return m_attachments; }
91 }
92
105 public virtual UUID BodyItem { 93 public virtual UUID BodyItem {
106 get { return m_wearables[BODY].ItemID; } 94 get { return m_wearables[AvatarWearable.BODY].ItemID; }
107 set { m_wearables[BODY].ItemID = value; } 95 set { m_wearables[AvatarWearable.BODY].ItemID = value; }
108 } 96 }
109 97
110 public virtual UUID BodyAsset { 98 public virtual UUID BodyAsset {
111 get { return m_wearables[BODY].AssetID; } 99 get { return m_wearables[AvatarWearable.BODY].AssetID; }
112 set { m_wearables[BODY].AssetID = value; } 100 set { m_wearables[AvatarWearable.BODY].AssetID = value; }
113 } 101 }
114 102
115 public virtual UUID SkinItem { 103 public virtual UUID SkinItem {
116 get { return m_wearables[SKIN].ItemID; } 104 get { return m_wearables[AvatarWearable.SKIN].ItemID; }
117 set { m_wearables[SKIN].ItemID = value; } 105 set { m_wearables[AvatarWearable.SKIN].ItemID = value; }
118 } 106 }
119 107
120 public virtual UUID SkinAsset { 108 public virtual UUID SkinAsset {
121 get { return m_wearables[SKIN].AssetID; } 109 get { return m_wearables[AvatarWearable.SKIN].AssetID; }
122 set { m_wearables[SKIN].AssetID = value; } 110 set { m_wearables[AvatarWearable.SKIN].AssetID = value; }
123 } 111 }
124 112
125 public virtual UUID HairItem { 113 public virtual UUID HairItem {
126 get { return m_wearables[HAIR].ItemID; } 114 get { return m_wearables[AvatarWearable.HAIR].ItemID; }
127 set { m_wearables[HAIR].ItemID = value; } 115 set { m_wearables[AvatarWearable.HAIR].ItemID = value; }
128 } 116 }
129 117
130 public virtual UUID HairAsset { 118 public virtual UUID HairAsset {
131 get { return m_wearables[HAIR].AssetID; } 119 get { return m_wearables[AvatarWearable.HAIR].AssetID; }
132 set { m_wearables[HAIR].AssetID = value; } 120 set { m_wearables[AvatarWearable.HAIR].AssetID = value; }
133 } 121 }
134 122
135 public virtual UUID EyesItem { 123 public virtual UUID EyesItem {
136 get { return m_wearables[EYES].ItemID; } 124 get { return m_wearables[AvatarWearable.EYES].ItemID; }
137 set { m_wearables[EYES].ItemID = value; } 125 set { m_wearables[AvatarWearable.EYES].ItemID = value; }
138 } 126 }
139 127
140 public virtual UUID EyesAsset { 128 public virtual UUID EyesAsset {
141 get { return m_wearables[EYES].AssetID; } 129 get { return m_wearables[AvatarWearable.EYES].AssetID; }
142 set { m_wearables[EYES].AssetID = value; } 130 set { m_wearables[AvatarWearable.EYES].AssetID = value; }
143 } 131 }
144 132
145 public virtual UUID ShirtItem { 133 public virtual UUID ShirtItem {
146 get { return m_wearables[SHIRT].ItemID; } 134 get { return m_wearables[AvatarWearable.SHIRT].ItemID; }
147 set { m_wearables[SHIRT].ItemID = value; } 135 set { m_wearables[AvatarWearable.SHIRT].ItemID = value; }
148 } 136 }
149 137
150 public virtual UUID ShirtAsset { 138 public virtual UUID ShirtAsset {
151 get { return m_wearables[SHIRT].AssetID; } 139 get { return m_wearables[AvatarWearable.SHIRT].AssetID; }
152 set { m_wearables[SHIRT].AssetID = value; } 140 set { m_wearables[AvatarWearable.SHIRT].AssetID = value; }
153 } 141 }
154 142
155 public virtual UUID PantsItem { 143 public virtual UUID PantsItem {
156 get { return m_wearables[PANTS].ItemID; } 144 get { return m_wearables[AvatarWearable.PANTS].ItemID; }
157 set { m_wearables[PANTS].ItemID = value; } 145 set { m_wearables[AvatarWearable.PANTS].ItemID = value; }
158 } 146 }
159 147
160 public virtual UUID PantsAsset { 148 public virtual UUID PantsAsset {
161 get { return m_wearables[PANTS].AssetID; } 149 get { return m_wearables[AvatarWearable.PANTS].AssetID; }
162 set { m_wearables[PANTS].AssetID = value; } 150 set { m_wearables[AvatarWearable.PANTS].AssetID = value; }
163 } 151 }
164 152
165 public virtual UUID ShoesItem { 153 public virtual UUID ShoesItem {
166 get { return m_wearables[SHOES].ItemID; } 154 get { return m_wearables[AvatarWearable.SHOES].ItemID; }
167 set { m_wearables[SHOES].ItemID = value; } 155 set { m_wearables[AvatarWearable.SHOES].ItemID = value; }
168 } 156 }
169 157
170 public virtual UUID ShoesAsset { 158 public virtual UUID ShoesAsset {
171 get { return m_wearables[SHOES].AssetID; } 159 get { return m_wearables[AvatarWearable.SHOES].AssetID; }
172 set { m_wearables[SHOES].AssetID = value; } 160 set { m_wearables[AvatarWearable.SHOES].AssetID = value; }
173 } 161 }
174 162
175 public virtual UUID SocksItem { 163 public virtual UUID SocksItem {
176 get { return m_wearables[SOCKS].ItemID; } 164 get { return m_wearables[AvatarWearable.SOCKS].ItemID; }
177 set { m_wearables[SOCKS].ItemID = value; } 165 set { m_wearables[AvatarWearable.SOCKS].ItemID = value; }
178 } 166 }
179 167
180 public virtual UUID SocksAsset { 168 public virtual UUID SocksAsset {
181 get { return m_wearables[SOCKS].AssetID; } 169 get { return m_wearables[AvatarWearable.SOCKS].AssetID; }
182 set { m_wearables[SOCKS].AssetID = value; } 170 set { m_wearables[AvatarWearable.SOCKS].AssetID = value; }
183 } 171 }
184 172
185 public virtual UUID JacketItem { 173 public virtual UUID JacketItem {
186 get { return m_wearables[JACKET].ItemID; } 174 get { return m_wearables[AvatarWearable.JACKET].ItemID; }
187 set { m_wearables[JACKET].ItemID = value; } 175 set { m_wearables[AvatarWearable.JACKET].ItemID = value; }
188 } 176 }
189 177
190 public virtual UUID JacketAsset { 178 public virtual UUID JacketAsset {
191 get { return m_wearables[JACKET].AssetID; } 179 get { return m_wearables[AvatarWearable.JACKET].AssetID; }
192 set { m_wearables[JACKET].AssetID = value; } 180 set { m_wearables[AvatarWearable.JACKET].AssetID = value; }
193 } 181 }
194 182
195 public virtual UUID GlovesItem { 183 public virtual UUID GlovesItem {
196 get { return m_wearables[GLOVES].ItemID; } 184 get { return m_wearables[AvatarWearable.GLOVES].ItemID; }
197 set { m_wearables[GLOVES].ItemID = value; } 185 set { m_wearables[AvatarWearable.GLOVES].ItemID = value; }
198 } 186 }
199 187
200 public virtual UUID GlovesAsset { 188 public virtual UUID GlovesAsset {
201 get { return m_wearables[GLOVES].AssetID; } 189 get { return m_wearables[AvatarWearable.GLOVES].AssetID; }
202 set { m_wearables[GLOVES].AssetID = value; } 190 set { m_wearables[AvatarWearable.GLOVES].AssetID = value; }
203 } 191 }
204 192
205 public virtual UUID UnderShirtItem { 193 public virtual UUID UnderShirtItem {
206 get { return m_wearables[UNDERSHIRT].ItemID; } 194 get { return m_wearables[AvatarWearable.UNDERSHIRT].ItemID; }
207 set { m_wearables[UNDERSHIRT].ItemID = value; } 195 set { m_wearables[AvatarWearable.UNDERSHIRT].ItemID = value; }
208 } 196 }
209 197
210 public virtual UUID UnderShirtAsset { 198 public virtual UUID UnderShirtAsset {
211 get { return m_wearables[UNDERSHIRT].AssetID; } 199 get { return m_wearables[AvatarWearable.UNDERSHIRT].AssetID; }
212 set { m_wearables[UNDERSHIRT].AssetID = value; } 200 set { m_wearables[AvatarWearable.UNDERSHIRT].AssetID = value; }
213 } 201 }
214 202
215 public virtual UUID UnderPantsItem { 203 public virtual UUID UnderPantsItem {
216 get { return m_wearables[UNDERPANTS].ItemID; } 204 get { return m_wearables[AvatarWearable.UNDERPANTS].ItemID; }
217 set { m_wearables[UNDERPANTS].ItemID = value; } 205 set { m_wearables[AvatarWearable.UNDERPANTS].ItemID = value; }
218 } 206 }
219 207
220 public virtual UUID UnderPantsAsset { 208 public virtual UUID UnderPantsAsset {
221 get { return m_wearables[UNDERPANTS].AssetID; } 209 get { return m_wearables[AvatarWearable.UNDERPANTS].AssetID; }
222 set { m_wearables[UNDERPANTS].AssetID = value; } 210 set { m_wearables[AvatarWearable.UNDERPANTS].AssetID = value; }
223 } 211 }
224 212
225 public virtual UUID SkirtItem { 213 public virtual UUID SkirtItem {
226 get { return m_wearables[SKIRT].ItemID; } 214 get { return m_wearables[AvatarWearable.SKIRT].ItemID; }
227 set { m_wearables[SKIRT].ItemID = value; } 215 set { m_wearables[AvatarWearable.SKIRT].ItemID = value; }
228 } 216 }
229 217
230 public virtual UUID SkirtAsset { 218 public virtual UUID SkirtAsset {
231 get { return m_wearables[SKIRT].AssetID; } 219 get { return m_wearables[AvatarWearable.SKIRT].AssetID; }
232 set { m_wearables[SKIRT].AssetID = value; } 220 set { m_wearables[AvatarWearable.SKIRT].AssetID = value; }
233 } 221 }
234 222
235 public virtual void SetDefaultWearables() 223 public virtual float AvatarHeight
236 { 224 {
237 m_wearables[BODY].AssetID = BODY_ASSET; 225 get { return m_avatarHeight; }
238 m_wearables[BODY].ItemID = BODY_ITEM; 226 set { m_avatarHeight = value; }
239 m_wearables[SKIN].AssetID = SKIN_ASSET;
240 m_wearables[SKIN].ItemID = SKIN_ITEM;
241 m_wearables[HAIR].AssetID = HAIR_ASSET;
242 m_wearables[HAIR].ItemID = HAIR_ITEM;
243 m_wearables[SHIRT].AssetID = SHIRT_ASSET;
244 m_wearables[SHIRT].ItemID = SHIRT_ITEM;
245 m_wearables[PANTS].AssetID = PANTS_ASSET;
246 m_wearables[PANTS].ItemID = PANTS_ITEM;
247 } 227 }
248 228
249 public virtual void ClearWearables() 229 public virtual float HipOffset
250 { 230 {
251 for (int i = 0; i < 13; i++) 231 get { return m_hipOffset; }
252 {
253 m_wearables[i].AssetID = UUID.Zero;
254 m_wearables[i].ItemID = UUID.Zero;
255 }
256 } 232 }
257 233
258 public virtual void SetDefaultParams(byte[] vparams) 234 public AvatarAppearance() : this(UUID.Zero) {}
235
236 public AvatarAppearance(UUID owner)
259 { 237 {
260 // TODO: Figure out better values then 'fat scientist 150' or 'alien 0' 238// DEBUG ON
261 for (int i = 0; i < VISUALPARAM_COUNT; i++) 239 m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner);
262 { 240// DEBUG OFF
263 vparams[i] = 150; 241 m_serial = 0;
264 } 242 m_owner = owner;
243
244 SetDefaultWearables();
245 SetDefaultTexture();
246 SetDefaultParams();
247 SetHeight();
248
249 m_attachments = new Dictionary<int, AvatarAttachment>();
265 } 250 }
251
252 public AvatarAppearance(UUID avatarID, OSDMap map)
253 {
254// DEBUG ON
255 m_log.WarnFormat("[AVATAR APPEARANCE] create appearance for {0} from OSDMap",avatarID);
256// DEBUG OFF
257 m_owner = avatarID;
258 Unpack(map);
259 SetHeight();
260 }
261
262 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
263 {
264// DEBUG ON
265 m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID);
266// DEBUG OFF
267 m_serial = 1;
268 m_owner = avatarID;
266 269
267 protected Primitive.TextureEntry m_texture; 270 if (wearables != null)
271 m_wearables = wearables;
272 else
273 SetDefaultWearables();
274
275 if (textureEntry != null)
276 m_texture = textureEntry;
277 else
278 SetDefaultTexture();
268 279
269 public virtual Primitive.TextureEntry Texture 280 if (visualParams != null)
270 { 281 m_visualparams = visualParams;
271 get { return m_texture; } 282 else
272 set { m_texture = value; } 283 SetDefaultParams();
284
285 SetHeight();
286
287 m_attachments = new Dictionary<int, AvatarAttachment>();
273 } 288 }
274 289
275 protected float m_avatarHeight = 0; 290 public AvatarAppearance(AvatarAppearance appearance)
276 protected float m_hipOffset = 0; 291 {
292// DEBUG ON
293 m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");
294// DEBUG OFF
295 if (appearance == null)
296 {
297 m_serial = 0;
298 m_owner = UUID.Zero;
277 299
278 public virtual float AvatarHeight 300 SetDefaultWearables();
301 SetDefaultTexture();
302 SetDefaultParams();
303 SetHeight();
304
305 m_attachments = new Dictionary<int, AvatarAttachment>();
306
307 return;
308 }
309
310 m_serial = appearance.Serial;
311 m_owner = appearance.Owner;
312
313 m_wearables = null;
314 if (appearance.Wearables != null)
315 {
316 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; //should be 13 of these
317 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
318 SetWearable(i,appearance.Wearables[i]);
319 }
320
321 m_texture = null;
322 if (appearance.Texture != null)
323 {
324 byte[] tbytes = appearance.Texture.GetBytes();
325 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
326 }
327
328 m_visualparams = null;
329 if (appearance.VisualParams != null)
330 m_visualparams = (byte[])appearance.VisualParams.Clone();
331
332 m_attachments = new Dictionary<int, AvatarAttachment>();
333 foreach (KeyValuePair<int, AvatarAttachment> kvp in appearance.Attachments)
334 m_attachments[kvp.Key] = new AvatarAttachment(kvp.Value);
335 }
336
337 protected virtual void SetDefaultWearables()
279 { 338 {
280 get { return m_avatarHeight; } 339 m_wearables = AvatarWearable.DefaultWearables;
281 set { m_avatarHeight = value; }
282 } 340 }
283 341
284 public virtual float HipOffset 342 protected virtual void SetDefaultParams()
285 { 343 {
286 get { return m_hipOffset; } 344 m_visualparams = new byte[VISUALPARAM_COUNT];
345 for (int i = 0; i < VISUALPARAM_COUNT; i++)
346 {
347 m_visualparams[i] = 150;
348 }
287 } 349 }
288 350
289 //Builds the VisualParam Enum using LIBOMV's Visual Param NameValues 351 protected virtual void SetDefaultTexture()
290 /*
291 public void BuildVisualParamEnum()
292 { 352 {
293 Dictionary<string, int> IndexedParams = new Dictionary<string, int>(); 353 m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
294 int vpIndex = 0; 354 // The initialization of these seems to force a rebake regardless of whether it is needed
295 IndexedParams = new Dictionary<string, int>(); 355 // m_textures.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012");
296 356 // m_textures.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
297 System.Text.StringBuilder sb = new System.Text.StringBuilder(); 357 // m_textures.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID;
358 // m_textures.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
359 // m_textures.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
360 // m_textures.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010");
361 // m_textures.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011");
362 }
298 363
299 sb.Append("public enum VPElement: int\n"); 364 /// <summary>
300 sb.Append("{\n"); 365 /// Set up appearance textures.
301 foreach (KeyValuePair<int, VisualParam> kvp in OpenMetaverse.VisualParams.Params) 366 /// Returns boolean that indicates whether the new entries actually change the
367 /// existing values.
368 /// </summary>
369 public virtual bool SetTextureEntries(Primitive.TextureEntry textureEntry)
370 {
371 if (textureEntry == null)
372 return false;
373
374 // There are much simpler versions of this copy that could be
375 // made. We determine if any of the textures actually
376 // changed to know if the appearance should be saved later
377 bool changed = false;
378 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
302 { 379 {
303 VisualParam vp = kvp.Value; 380 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i];
304 381 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i];
305 // Only Group-0 parameters are sent in AgentSetAppearance packets
306 if (kvp.Value.Group == 0)
307 {
308 382
309 if (!IndexedParams.ContainsKey(vp.Name)) 383 if (newface == null)
310 { 384 {
311 385 if (oldface == null) continue;
312 if (vp.Label.Length > 0 || vp.LabelMin.Length > 0 || vp.LabelMax.Length > 0)
313 {
314
315 sb.Append("/// <summary>\n");
316 if (vp.LabelMin.Length > 0 && vp.LabelMax.Length > 0)
317 sb.Append(string.Format("/// {0} - {1} 0--+255 {2}\n", vp.Label, vp.LabelMin,
318 vp.LabelMax));
319
320 else
321 sb.Append(string.Format("/// {0}\n", vp.Label));
322
323 sb.Append("/// </summary>\n");
324 }
325 sb.Append(string.Format(" {0}_{1} = {2}", vp.Wearable.ToUpper(), vp.Name.ToUpper().Replace(" ", "_"),vpIndex));
326
327 IndexedParams.Add(vp.Name, vpIndex++);
328 }
329 else
330 {
331 sb.Append(string.Format(" {0}_{1}_{2} = {2}", vp.Wearable.ToUpper(), vp.Name.ToUpper().Replace(" ", "_"), vpIndex));
332 vpIndex++;
333 //int i = 0;
334 }
335 } 386 }
336 if (vpIndex < 217)
337 sb.Append(",\n");
338 else 387 else
339 sb.Append("\n"); 388 {
389 if (oldface != null && oldface.TextureID == newface.TextureID) continue;
390 }
340 391
392 m_texture.FaceTextures[i] = (newface != null) ? new Primitive.TextureEntryFace(newface) : null;
393 changed = true;
394// DEBUG ON
395 if (newface != null)
396 m_log.WarnFormat("[SCENEPRESENCE] index {0}, new texture id {1}",i,newface.TextureID);
397// DEBUG OFF
341 } 398 }
342 sb.Append("}\n");
343 399
400 return changed;
344 } 401 }
345 */ 402
346 403 /// <summary>
347 public AvatarAppearance() : this(UUID.Zero) {} 404 /// Set up visual parameters for the avatar and refresh the avatar height
348 405 /// Returns boolean that indicates whether the new entries actually change the
349 public AvatarAppearance(UUID owner) 406 /// existing values.
407 /// </summary>
408 public virtual bool SetVisualParams(byte[] visualParams)
350 { 409 {
351 m_wearables = new AvatarWearable[MAX_WEARABLES]; 410 if (visualParams == null)
352 for (int i = 0; i < MAX_WEARABLES; i++) 411 return false;
412
413 // There are much simpler versions of this copy that could be
414 // made. We determine if any of the visual parameters actually
415 // changed to know if the appearance should be saved later
416 bool changed = false;
417 for (int i = 0; i < AvatarAppearance.VISUALPARAM_COUNT; i++)
353 { 418 {
354 // this makes them all null 419 if (visualParams[i] != m_visualparams[i])
355 m_wearables[i] = new AvatarWearable(); 420 {
421// DEBUG ON
422 m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}",
423 i,m_visualparams[i],visualParams[i]);
424// DEBUG OFF
425 m_visualparams[i] = visualParams[i];
426 changed = true;
427 }
356 } 428 }
357 m_serial = 0; 429
358 m_owner = owner; 430 // Reset the height if the visual parameters actually changed
359 //BuildVisualParamEnum() 431 if (changed)
360 m_visualparams = new byte[VISUALPARAM_COUNT]; 432 SetHeight();
361 // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist 433
362 SetDefaultParams(m_visualparams); 434 return changed;
363 SetDefaultWearables();
364 m_texture = GetDefaultTexture();
365 } 435 }
366 436
367 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) 437 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
368 { 438 {
369 m_owner = avatarID; 439 SetTextureEntries(textureEntry);
370 m_serial = 1; 440 SetVisualParams(visualParams);
371 m_wearables = wearables;
372 m_visualparams = visualParams;
373 m_texture = GetDefaultTexture();
374 } 441 }
375 442
376 /// <summary> 443 public virtual void SetHeight()
377 /// Set up appearance textures and avatar parameters, including a height calculation
378 /// </summary>
379 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
380 { 444 {
381 if (textureEntry != null)
382 m_texture = textureEntry;
383 if (visualParams != null)
384 m_visualparams = visualParams;
385
386 m_avatarHeight = 1.23077f // Shortest possible avatar height 445 m_avatarHeight = 1.23077f // Shortest possible avatar height
387 + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height 446 + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height
388 + 0.072514f * (float)m_visualparams[(int)VPElement.SHAPE_HEAD_SIZE] / 255.0f // Head size 447 + 0.072514f * (float)m_visualparams[(int)VPElement.SHAPE_HEAD_SIZE] / 255.0f // Head size
@@ -390,217 +449,63 @@ namespace OpenSim.Framework
390 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height 449 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height
391 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height 450 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height
392 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; // Neck length 451 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; // Neck length
452
393 m_hipOffset = (((1.23077f // Half of avatar 453 m_hipOffset = (((1.23077f // Half of avatar
394 + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height 454 + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height
395 + 0.3836f * (float)m_visualparams[(int)VPElement.SHAPE_LEG_LENGTH] / 255.0f // Leg length 455 + 0.3836f * (float)m_visualparams[(int)VPElement.SHAPE_LEG_LENGTH] / 255.0f // Leg length
396 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height 456 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height
397 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height 457 + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height
398 ) / 2) - m_avatarHeight / 2) * 0.31f - 0.0425f; 458 ) / 2) - m_avatarHeight / 2) * 0.31f - 0.0425f;
399
400
401
402 //System.Console.WriteLine(">>>>>>> [APPEARANCE]: Height {0} Hip offset {1}" + m_avatarHeight + " " + m_hipOffset);
403 //m_log.Debug("------------- Set Appearance Texture ---------------");
404 //Primitive.TextureEntryFace[] faces = Texture.FaceTextures;
405 //foreach (Primitive.TextureEntryFace face in faces)
406 //{
407 // if (face != null)
408 // m_log.Debug(" ++ " + face.TextureID);
409 // else
410 // m_log.Debug(" ++ NULL ");
411 //}
412 //m_log.Debug("----------------------------");
413
414 } 459 }
415 460
416 public virtual void SetWearable(int wearableId, AvatarWearable wearable) 461 public virtual void SetWearable(int wearableId, AvatarWearable wearable)
417 { 462 {
418 m_wearables[wearableId] = wearable; 463// DEBUG ON
464// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID);
465// DEBUG OFF
466 m_wearables[wearableId] = new AvatarWearable(wearable.ItemID,wearable.AssetID);
419 } 467 }
420 468
421 public static Primitive.TextureEntry GetDefaultTexture()
422 {
423 Primitive.TextureEntry textu = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
424 textu.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012");
425 textu.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
426 textu.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID;
427 textu.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
428 textu.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
429 textu.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010");
430 textu.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011");
431 return textu;
432 }
433
434 public static byte[] GetDefaultVisualParams()
435 {
436 byte[] visualParams;
437 visualParams = new byte[VISUALPARAM_COUNT];
438 for (int i = 0; i < VISUALPARAM_COUNT; i++)
439 {
440 visualParams[i] = 100;
441 }
442 return visualParams;
443 }
444 469
470// DEBUG ON
445 public override String ToString() 471 public override String ToString()
446 { 472 {
447 String s = "[Wearables] =>"; 473 String s = "";
448 s += " Body Item: " + BodyItem.ToString() + ";"; 474 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
449 s += " Skin Item: " + SkinItem.ToString() + ";"; 475 if (m_texture.FaceTextures[i] != null)
450 s += " Shirt Item: " + ShirtItem.ToString() + ";"; 476 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID);
451 s += " Pants Item: " + PantsItem.ToString() + ";"; 477
452 return s; 478 foreach (AvatarWearable awear in m_wearables)
453 } 479 s += String.Format("Wearable: item={0}, asset={1}\n",awear.ItemID,awear.AssetID);
454 480
455 // this is used for OGS1 481 s += "Visual Params: ";
456 public virtual Hashtable ToHashTable() 482 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++)
457 { 483 s += String.Format("{0},",m_visualparams[j]);
458 Hashtable h = new Hashtable(); 484 s += "\n";
459 h["owner"] = Owner.ToString();
460 h["serial"] = Serial.ToString();
461 h["visual_params"] = VisualParams;
462 h["texture"] = Texture.GetBytes();
463 h["avatar_height"] = AvatarHeight.ToString();
464 h["body_item"] = BodyItem.ToString();
465 h["body_asset"] = BodyAsset.ToString();
466 h["skin_item"] = SkinItem.ToString();
467 h["skin_asset"] = SkinAsset.ToString();
468 h["hair_item"] = HairItem.ToString();
469 h["hair_asset"] = HairAsset.ToString();
470 h["eyes_item"] = EyesItem.ToString();
471 h["eyes_asset"] = EyesAsset.ToString();
472 h["shirt_item"] = ShirtItem.ToString();
473 h["shirt_asset"] = ShirtAsset.ToString();
474 h["pants_item"] = PantsItem.ToString();
475 h["pants_asset"] = PantsAsset.ToString();
476 h["shoes_item"] = ShoesItem.ToString();
477 h["shoes_asset"] = ShoesAsset.ToString();
478 h["socks_item"] = SocksItem.ToString();
479 h["socks_asset"] = SocksAsset.ToString();
480 h["jacket_item"] = JacketItem.ToString();
481 h["jacket_asset"] = JacketAsset.ToString();
482 h["gloves_item"] = GlovesItem.ToString();
483 h["gloves_asset"] = GlovesAsset.ToString();
484 h["undershirt_item"] = UnderShirtItem.ToString();
485 h["undershirt_asset"] = UnderShirtAsset.ToString();
486 h["underpants_item"] = UnderPantsItem.ToString();
487 h["underpants_asset"] = UnderPantsAsset.ToString();
488 h["skirt_item"] = SkirtItem.ToString();
489 h["skirt_asset"] = SkirtAsset.ToString();
490
491 string attachments = GetAttachmentsString();
492 if (attachments != String.Empty)
493 h["attachments"] = attachments;
494
495 return h;
496 }
497
498 public AvatarAppearance(Hashtable h)
499 {
500 Owner = new UUID((string)h["owner"]);
501 Serial = Convert.ToInt32((string)h["serial"]);
502 VisualParams = (byte[])h["visual_params"];
503
504 if (h.Contains("texture"))
505 {
506 byte[] te = h["texture"] as byte[];
507 if (te != null && te.Length > 0)
508 Texture = new Primitive.TextureEntry(te, 0, te.Length);
509 }
510 else
511 {
512 // We shouldn't be receiving appearance hashtables without a TextureEntry,
513 // but in case we do this will prevent a failure when saving to the database
514 Texture = GetDefaultTexture();
515 }
516
517 485
518 AvatarHeight = (float)Convert.ToDouble((string)h["avatar_height"]); 486 return s;
519
520 m_wearables = new AvatarWearable[MAX_WEARABLES];
521 for (int i = 0; i < MAX_WEARABLES; i++)
522 {
523 // this makes them all null
524 m_wearables[i] = new AvatarWearable();
525 }
526
527 BodyItem = new UUID((string)h["body_item"]);
528 BodyAsset = new UUID((string)h["body_asset"]);
529 SkinItem = new UUID((string)h["skin_item"]);
530 SkinAsset = new UUID((string)h["skin_asset"]);
531 HairItem = new UUID((string)h["hair_item"]);
532 HairAsset = new UUID((string)h["hair_asset"]);
533 EyesItem = new UUID((string)h["eyes_item"]);
534 EyesAsset = new UUID((string)h["eyes_asset"]);
535 ShirtItem = new UUID((string)h["shirt_item"]);
536 ShirtAsset = new UUID((string)h["shirt_asset"]);
537 PantsItem = new UUID((string)h["pants_item"]);
538 PantsAsset = new UUID((string)h["pants_asset"]);
539 ShoesItem = new UUID((string)h["shoes_item"]);
540 ShoesAsset = new UUID((string)h["shoes_asset"]);
541 SocksItem = new UUID((string)h["socks_item"]);
542 SocksAsset = new UUID((string)h["socks_asset"]);
543 JacketItem = new UUID((string)h["jacket_item"]);
544 JacketAsset = new UUID((string)h["jacket_asset"]);
545 GlovesItem = new UUID((string)h["gloves_item"]);
546 GlovesAsset = new UUID((string)h["gloves_asset"]);
547 UnderShirtItem = new UUID((string)h["undershirt_item"]);
548 UnderShirtAsset = new UUID((string)h["undershirt_asset"]);
549 UnderPantsItem = new UUID((string)h["underpants_item"]);
550 UnderPantsAsset = new UUID((string)h["underpants_asset"]);
551 SkirtItem = new UUID((string)h["skirt_item"]);
552 SkirtAsset = new UUID((string)h["skirt_asset"]);
553
554 if (h.ContainsKey("attachments"))
555 {
556 SetAttachmentsString(h["attachments"].ToString());
557 }
558 } 487 }
488// DEBUG OFF
559 489
560 private Dictionary<int, UUID[]> m_attachments = new Dictionary<int, UUID[]>(); 490 public void SetAttachments(AvatarAttachment[] data)
561
562 public void SetAttachments(AttachmentData[] data)
563 { 491 {
564 foreach (AttachmentData a in data) 492 foreach (AvatarAttachment attach in data)
565 { 493 m_attachments[attach.AttachPoint] = new AvatarAttachment(attach);
566 m_attachments[a.AttachPoint] = new UUID[2];
567 m_attachments[a.AttachPoint][0] = a.ItemID;
568 m_attachments[a.AttachPoint][1] = a.AssetID;
569 }
570 } 494 }
571 495
572 public void SetAttachments(Hashtable data) 496 public void SetAttachment(int attachpoint, UUID item, UUID asset)
573 { 497 {
574 m_attachments.Clear(); 498 if (attachpoint == 0)
575
576 if (data == null)
577 return; 499 return;
578 500
579 foreach (DictionaryEntry e in data) 501 if (item == UUID.Zero)
580 { 502 {
581 int attachpoint = Convert.ToInt32(e.Key);
582
583 if (m_attachments.ContainsKey(attachpoint)) 503 if (m_attachments.ContainsKey(attachpoint))
584 continue; 504 m_attachments.Remove(attachpoint);
585 505 return;
586 UUID item;
587 UUID asset;
588
589 Hashtable uuids = (Hashtable) e.Value;
590 UUID.TryParse(uuids["item"].ToString(), out item);
591 UUID.TryParse(uuids["asset"].ToString(), out asset);
592
593 UUID[] attachment = new UUID[2];
594 attachment[0] = item;
595 attachment[1] = asset;
596
597 m_attachments[attachpoint] = attachment;
598 } 506 }
599 }
600 507
601 public Dictionary<int, UUID[]> GetAttachmentDictionary() 508 m_attachments[attachpoint] = new AvatarAttachment(attachpoint,item,asset);
602 {
603 return m_attachments;
604 } 509 }
605 510
606 public Hashtable GetAttachments() 511 public Hashtable GetAttachments()
@@ -610,16 +515,13 @@ namespace OpenSim.Framework
610 515
611 Hashtable ret = new Hashtable(); 516 Hashtable ret = new Hashtable();
612 517
613 foreach (KeyValuePair<int, UUID[]> kvp in m_attachments) 518 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
614 { 519 {
615 int attachpoint = kvp.Key;
616 UUID[] uuids = kvp.Value;
617
618 Hashtable data = new Hashtable(); 520 Hashtable data = new Hashtable();
619 data["item"] = uuids[0].ToString(); 521 data["item"] = kvp.Value.ItemID.ToString();
620 data["asset"] = uuids[1].ToString(); 522 data["asset"] = kvp.Value.AssetID.ToString();
621 523
622 ret[attachpoint] = data; 524 ret[kvp.Key] = data;
623 } 525 }
624 526
625 return ret; 527 return ret;
@@ -635,7 +537,7 @@ namespace OpenSim.Framework
635 if (!m_attachments.ContainsKey(attachpoint)) 537 if (!m_attachments.ContainsKey(attachpoint))
636 return UUID.Zero; 538 return UUID.Zero;
637 539
638 return m_attachments[attachpoint][0]; 540 return m_attachments[attachpoint].ItemID;
639 } 541 }
640 542
641 public UUID GetAttachedAsset(int attachpoint) 543 public UUID GetAttachedAsset(int attachpoint)
@@ -643,33 +545,14 @@ namespace OpenSim.Framework
643 if (!m_attachments.ContainsKey(attachpoint)) 545 if (!m_attachments.ContainsKey(attachpoint))
644 return UUID.Zero; 546 return UUID.Zero;
645 547
646 return m_attachments[attachpoint][1]; 548 return m_attachments[attachpoint].AssetID;
647 }
648
649 public void SetAttachment(int attachpoint, UUID item, UUID asset)
650 {
651 if (attachpoint == 0)
652 return;
653
654 if (item == UUID.Zero)
655 {
656 if (m_attachments.ContainsKey(attachpoint))
657 m_attachments.Remove(attachpoint);
658 return;
659 }
660
661 if (!m_attachments.ContainsKey(attachpoint))
662 m_attachments[attachpoint] = new UUID[2];
663
664 m_attachments[attachpoint][0] = item;
665 m_attachments[attachpoint][1] = asset;
666 } 549 }
667 550
668 public int GetAttachpoint(UUID itemID) 551 public int GetAttachpoint(UUID itemID)
669 { 552 {
670 foreach (KeyValuePair<int, UUID[]> kvp in m_attachments) 553 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
671 { 554 {
672 if (kvp.Value[0] == itemID) 555 if (kvp.Value.ItemID == itemID)
673 { 556 {
674 return kvp.Key; 557 return kvp.Key;
675 } 558 }
@@ -690,42 +573,126 @@ namespace OpenSim.Framework
690 m_attachments.Clear(); 573 m_attachments.Clear();
691 } 574 }
692 575
693 string GetAttachmentsString() 576 /// <summary>
577 /// Create an OSDMap from the appearance data
578 /// </summary>
579 public OSDMap Pack()
694 { 580 {
695 List<string> strings = new List<string>(); 581 OSDMap data = new OSDMap();
696 582
697 foreach (KeyValuePair<int, UUID[]> e in m_attachments) 583 data["serial"] = OSD.FromInteger(m_serial);
584 data["height"] = OSD.FromReal(m_avatarHeight);
585 data["hipoffset"] = OSD.FromReal(m_hipOffset);
586
587 // Wearables
588 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES);
589 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
590 wears.Add(m_wearables[i].Pack());
591 data["wearables"] = wears;
592
593 // Avatar Textures
594 OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT);
595 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
698 { 596 {
699 strings.Add(e.Key.ToString()); 597 if (m_texture.FaceTextures[i] != null)
700 strings.Add(e.Value[0].ToString()); 598 textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID));
701 strings.Add(e.Value[1].ToString()); 599 else
600 textures.Add(OSD.FromUUID(UUID.Zero));
702 } 601 }
602 data["textures"] = textures;
703 603
704 return String.Join(",", strings.ToArray()); 604 // Visual Parameters
605 OSDBinary visualparams = new OSDBinary(m_visualparams);
606 data["visualparams"] = visualparams;
607
608 // Attachments
609 OSDArray attachs = new OSDArray(m_attachments.Count);
610 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
611 attachs.Add(kvp.Value.Pack());
612 data["attachments"] = attachs;
613
614 return data;
705 } 615 }
706 616
707 void SetAttachmentsString(string data) 617 /// <summary>
618 /// Unpack and OSDMap and initialize the appearance
619 /// from it
620 /// </summary>
621 public void Unpack(OSDMap data)
708 { 622 {
709 string[] strings = data.Split(new char[] {','}); 623 if ((data != null) && (data["appearance_serial"] != null))
710 int i = 0; 624 m_serial = data["appearance_serial"].AsInteger();
625 if ((data != null) && (data["height"] != null))
626 m_avatarHeight = (float)data["height"].AsReal();
627 if ((data != null) && (data["hipoffset"] != null))
628 m_hipOffset = (float)data["hipoffset"].AsReal();
629
630 try
631 {
632 // Wearables
633 SetDefaultWearables();
634 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
635 {
636 OSDArray wears = (OSDArray)(data["wearables"]);
637 for (int i = 0; i < wears.Count; i++)
638 m_wearables[i] = new AvatarWearable((OSDMap)wears[i]);
639 }
640 else
641 {
642 m_log.Warn("[AVATARAPPEARANCE] failed to unpack wearables");
643 }
711 644
712 m_attachments.Clear(); 645 // Avatar Textures
646 SetDefaultTexture();
647 if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
648 {
649 OSDArray textures = (OSDArray)(data["textures"]);
650 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
651 {
652 if (textures[i] != null)
653 {
654 UUID textureID = textures[i].AsUUID();
655 if (textureID != UUID.Zero)
656 m_texture.CreateFace((uint)i).TextureID = textureID;
657 }
658 }
659 }
660 else
661 {
662 m_log.Warn("[AVATARAPPEARANCE] failed to unpack textures");
663 }
713 664
714 while (strings.Length - i > 2) 665 // Visual Parameters
715 { 666 SetDefaultParams();
716 int attachpoint = Int32.Parse(strings[i]); 667 if ((data != null) && (data["visualparams"] != null))
717 UUID item = new UUID(strings[i+1]); 668 {
718 UUID asset = new UUID(strings[i+2]); 669 if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
719 i += 3; 670 m_visualparams = data["visualparams"].AsBinary();
671 }
672 else
673 {
674 m_log.Warn("[AVATARAPPEARANCE] failed to unpack visual parameters");
675 }
720 676
721 if (!m_attachments.ContainsKey(attachpoint)) 677 // Attachments
678 m_attachments = new Dictionary<int, AvatarAttachment>();
679 if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
722 { 680 {
723 m_attachments[attachpoint] = new UUID[2]; 681 OSDArray attachs = (OSDArray)(data["attachments"]);
724 m_attachments[attachpoint][0] = item; 682 for (int i = 0; i < attachs.Count; i++)
725 m_attachments[attachpoint][1] = asset; 683 {
684 AvatarAttachment attach = new AvatarAttachment((OSDMap)attachs[i]);
685 m_attachments[attach.AttachPoint] = attach;
686 }
726 } 687 }
727 } 688 }
689 catch (Exception e)
690 {
691 m_log.ErrorFormat("[AVATARAPPEARANCE] unpack failed badly: {0}",e.Message);
692 }
728 } 693 }
694
695
729 /// <summary> 696 /// <summary>
730 /// Viewer Params Array Element for AgentSetAppearance 697 /// Viewer Params Array Element for AgentSetAppearance
731 /// Generated from LibOMV's Visual Params list 698 /// Generated from LibOMV's Visual Params list
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Framework/AvatarAttachment.cs
index c967f30..c68d78d 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs
+++ b/OpenSim/Framework/AvatarAttachment.cs
@@ -25,14 +25,54 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenMetaverse.StructuredData;
30 31
31namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Framework
32{ 33{
33 public interface IAvatarFactory 34 public class AvatarAttachment
34 { 35 {
35 bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance); 36 public int AttachPoint;
36 void UpdateDatabase(UUID userID, AvatarAppearance avatAppearance); 37 public UUID ItemID;
38 public UUID AssetID;
39
40 public AvatarAttachment(AvatarAttachment attach)
41 {
42 AttachPoint = attach.AttachPoint;
43 ItemID = attach.ItemID;
44 AssetID = attach.AssetID;
45 }
46
47 public AvatarAttachment(int point, UUID item, UUID asset)
48 {
49 AttachPoint = point;
50 ItemID = item;
51 AssetID = asset;
52 }
53
54 public AvatarAttachment(OSDMap args)
55 {
56 Unpack(args);
57 }
58
59 public OSDMap Pack()
60 {
61 OSDMap attachdata = new OSDMap();
62 attachdata["point"] = OSD.FromInteger(AttachPoint);
63 attachdata["item"] = OSD.FromUUID(ItemID);
64 attachdata["asset"] = OSD.FromUUID(AssetID);
65
66 return attachdata;
67 }
68
69
70 public void Unpack(OSDMap args)
71 {
72 if (args["point"] != null)
73 AttachPoint = args["point"].AsInteger();
74 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
75 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
76 }
37 } 77 }
38} 78}
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index 30c5172..87098bf 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -26,14 +26,32 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Runtime.Serialization;
30using System.Security.Permissions;
31using OpenMetaverse; 29using OpenMetaverse;
30using OpenMetaverse.StructuredData;
32 31
33namespace OpenSim.Framework 32namespace OpenSim.Framework
34{ 33{
35 public class AvatarWearable 34 public class AvatarWearable
36 { 35 {
36 // these are guessed at by the list here -
37 // http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
38 // correct them over time for when were are wrong.
39 public static readonly int BODY = 0;
40 public static readonly int SKIN = 1;
41 public static readonly int HAIR = 2;
42 public static readonly int EYES = 3;
43 public static readonly int SHIRT = 4;
44 public static readonly int PANTS = 5;
45 public static readonly int SHOES = 6;
46 public static readonly int SOCKS = 7;
47 public static readonly int JACKET = 8;
48 public static readonly int GLOVES = 9;
49 public static readonly int UNDERSHIRT = 10;
50 public static readonly int UNDERPANTS = 11;
51 public static readonly int SKIRT = 12;
52
53 public static readonly int MAX_WEARABLES = 13;
54
37 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); 55 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
38 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); 56 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
39 57
@@ -62,12 +80,32 @@ namespace OpenSim.Framework
62 ItemID = itemId; 80 ItemID = itemId;
63 } 81 }
64 82
83 public AvatarWearable(OSDMap args)
84 {
85 Unpack(args);
86 }
87
88 public OSDMap Pack()
89 {
90 OSDMap weardata = new OSDMap();
91 weardata["item"] = OSD.FromUUID(ItemID);
92 weardata["asset"] = OSD.FromUUID(AssetID);
93
94 return weardata;
95 }
96
97 public void Unpack(OSDMap args)
98 {
99 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
100 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
101 }
102
65 public static AvatarWearable[] DefaultWearables 103 public static AvatarWearable[] DefaultWearables
66 { 104 {
67 get 105 get
68 { 106 {
69 AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these 107 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these
70 for (int i = 0; i < 13; i++) 108 for (int i = 0; i < MAX_WEARABLES; i++)
71 { 109 {
72 defaultWearables[i] = new AvatarWearable(); 110 defaultWearables[i] = new AvatarWearable();
73 } 111 }
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 72283de..6b64e12 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -976,7 +976,9 @@ namespace OpenSim.Framework.Capabilities
976 976
977 public void BakedTextureUploaded(UUID assetID, byte[] data) 977 public void BakedTextureUploaded(UUID assetID, byte[] data)
978 { 978 {
979 m_log.DebugFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); 979// DEBUG ON
980 m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
981// DEBUG OFF
980 AssetBase asset; 982 AssetBase asset;
981 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); 983 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
982 asset.Data = data; 984 asset.Data = data;
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 0dc5dbc..fdebba3 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -225,46 +225,6 @@ namespace OpenSim.Framework
225 } 225 }
226 } 226 }
227 227
228 public class AttachmentData
229 {
230 public int AttachPoint;
231 public UUID ItemID;
232 public UUID AssetID;
233
234 public AttachmentData(int point, UUID item, UUID asset)
235 {
236 AttachPoint = point;
237 ItemID = item;
238 AssetID = asset;
239 }
240
241 public AttachmentData(OSDMap args)
242 {
243 UnpackUpdateMessage(args);
244 }
245
246 public OSDMap PackUpdateMessage()
247 {
248 OSDMap attachdata = new OSDMap();
249 attachdata["point"] = OSD.FromInteger(AttachPoint);
250 attachdata["item"] = OSD.FromUUID(ItemID);
251 attachdata["asset"] = OSD.FromUUID(AssetID);
252
253 return attachdata;
254 }
255
256
257 public void UnpackUpdateMessage(OSDMap args)
258 {
259 if (args["point"] != null)
260 AttachPoint = args["point"].AsInteger();
261 if (args["item"] != null)
262 ItemID = args["item"].AsUUID();
263 if (args["asset"] != null)
264 AssetID = args["asset"].AsUUID();
265 }
266 }
267
268 public class ControllerData 228 public class ControllerData
269 { 229 {
270 public UUID ItemID; 230 public UUID ItemID;
@@ -348,11 +308,14 @@ namespace OpenSim.Framework
348 public UUID GranterID; 308 public UUID GranterID;
349 309
350 // Appearance 310 // Appearance
311 public AvatarAppearance Appearance;
312
313/*
351 public byte[] AgentTextures; 314 public byte[] AgentTextures;
352 public byte[] VisualParams; 315 public byte[] VisualParams;
353 public UUID[] Wearables; 316 public UUID[] Wearables;
354 public AttachmentData[] Attachments; 317 public AvatarAttachment[] Attachments;
355 318*/
356 // Scripted 319 // Scripted
357 public ControllerData[] Controllers; 320 public ControllerData[] Controllers;
358 321
@@ -413,6 +376,9 @@ namespace OpenSim.Framework
413 args["animations"] = anims; 376 args["animations"] = anims;
414 } 377 }
415 378
379 if (Appearance != null)
380 args["packed_appearance"] = Appearance.Pack();
381
416 //if ((AgentTextures != null) && (AgentTextures.Length > 0)) 382 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
417 //{ 383 //{
418 // OSDArray textures = new OSDArray(AgentTextures.Length); 384 // OSDArray textures = new OSDArray(AgentTextures.Length);
@@ -421,7 +387,7 @@ namespace OpenSim.Framework
421 // args["agent_textures"] = textures; 387 // args["agent_textures"] = textures;
422 //} 388 //}
423 389
424 390/*
425 if ((AgentTextures != null) && (AgentTextures.Length > 0)) 391 if ((AgentTextures != null) && (AgentTextures.Length > 0))
426 args["texture_entry"] = OSD.FromBinary(AgentTextures); 392 args["texture_entry"] = OSD.FromBinary(AgentTextures);
427 393
@@ -441,11 +407,11 @@ namespace OpenSim.Framework
441 if ((Attachments != null) && (Attachments.Length > 0)) 407 if ((Attachments != null) && (Attachments.Length > 0))
442 { 408 {
443 OSDArray attachs = new OSDArray(Attachments.Length); 409 OSDArray attachs = new OSDArray(Attachments.Length);
444 foreach (AttachmentData att in Attachments) 410 foreach (AvatarAttachment att in Attachments)
445 attachs.Add(att.PackUpdateMessage()); 411 attachs.Add(att.Pack());
446 args["attachments"] = attachs; 412 args["attachments"] = attachs;
447 } 413 }
448 414*/
449 if ((Controllers != null) && (Controllers.Length > 0)) 415 if ((Controllers != null) && (Controllers.Length > 0))
450 { 416 {
451 OSDArray controls = new OSDArray(Controllers.Length); 417 OSDArray controls = new OSDArray(Controllers.Length);
@@ -581,6 +547,12 @@ namespace OpenSim.Framework
581 // AgentTextures[i++] = o.AsUUID(); 547 // AgentTextures[i++] = o.AsUUID();
582 //} 548 //}
583 549
550 if (args["packed_appearance"] != null)
551 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
552 else
553 Appearance = new AvatarAppearance(AgentID);
554
555/*
584 if (args["texture_entry"] != null) 556 if (args["texture_entry"] != null)
585 AgentTextures = args["texture_entry"].AsBinary(); 557 AgentTextures = args["texture_entry"].AsBinary();
586 558
@@ -599,17 +571,17 @@ namespace OpenSim.Framework
599 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 571 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
600 { 572 {
601 OSDArray attachs = (OSDArray)(args["attachments"]); 573 OSDArray attachs = (OSDArray)(args["attachments"]);
602 Attachments = new AttachmentData[attachs.Count]; 574 Attachments = new AvatarAttachment[attachs.Count];
603 int i = 0; 575 int i = 0;
604 foreach (OSD o in attachs) 576 foreach (OSD o in attachs)
605 { 577 {
606 if (o.Type == OSDType.Map) 578 if (o.Type == OSDType.Map)
607 { 579 {
608 Attachments[i++] = new AttachmentData((OSDMap)o); 580 Attachments[i++] = new AvatarAttachment((OSDMap)o);
609 } 581 }
610 } 582 }
611 } 583 }
612 584*/
613 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 585 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
614 { 586 {
615 OSDArray controls = (OSDArray)(args["controllers"]); 587 OSDArray controls = (OSDArray)(args["controllers"]);
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 94815cd..027f9c5 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
43 43
44 public delegate void TextureRequest(Object sender, TextureRequestArgs e); 44 public delegate void TextureRequest(Object sender, TextureRequestArgs e);
45 45
46 public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e); 46 public delegate void AvatarNowWearing(IClientAPI sender, AvatarWearingArgs e);
47 47
48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im); 48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
49 49
@@ -65,7 +65,7 @@ namespace OpenSim.Framework
65 65
66 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 66 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
67 67
68 public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams); 68 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams);
69 69
70 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 70 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
71 71
@@ -711,7 +711,7 @@ namespace OpenSim.Framework
711 event TeleportLandmarkRequest OnTeleportLandmarkRequest; 711 event TeleportLandmarkRequest OnTeleportLandmarkRequest;
712 event DeRezObject OnDeRezObject; 712 event DeRezObject OnDeRezObject;
713 event Action<IClientAPI> OnRegionHandShakeReply; 713 event Action<IClientAPI> OnRegionHandShakeReply;
714 event GenericCall2 OnRequestWearables; 714 event GenericCall1 OnRequestWearables;
715 event GenericCall1 OnCompleteMovementToRegion; 715 event GenericCall1 OnCompleteMovementToRegion;
716 event UpdateAgent OnPreAgentUpdate; 716 event UpdateAgent OnPreAgentUpdate;
717 event UpdateAgent OnAgentUpdate; 717 event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 2fda6f3..05d8469 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -65,9 +65,7 @@ namespace OpenSim.Framework.Tests
65 SessionId = UUID.Random(); 65 SessionId = UUID.Random();
66 66
67 AvAppearance = new AvatarAppearance(AgentId); 67 AvAppearance = new AvatarAppearance(AgentId);
68 AvAppearance.SetDefaultWearables();
69 VisualParams = new byte[218]; 68 VisualParams = new byte[218];
70 AvAppearance.SetDefaultParams(VisualParams);
71 69
72 //body 70 //body
73 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155; 71 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 48d5a12..426e1df 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
79 public event DeRezObject OnDeRezObject; 79 public event DeRezObject OnDeRezObject;
80 public event ModifyTerrain OnModifyTerrain; 80 public event ModifyTerrain OnModifyTerrain;
81 public event Action<IClientAPI> OnRegionHandShakeReply; 81 public event Action<IClientAPI> OnRegionHandShakeReply;
82 public event GenericCall2 OnRequestWearables; 82 public event GenericCall1 OnRequestWearables;
83 public event SetAppearance OnSetAppearance; 83 public event SetAppearance OnSetAppearance;
84 public event AvatarNowWearing OnAvatarNowWearing; 84 public event AvatarNowWearing OnAvatarNowWearing;
85 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 85 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -5647,11 +5647,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5647 5647
5648 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack) 5648 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
5649 { 5649 {
5650 GenericCall2 handlerRequestWearables = OnRequestWearables; 5650 GenericCall1 handlerRequestWearables = OnRequestWearables;
5651 5651
5652 if (handlerRequestWearables != null) 5652 if (handlerRequestWearables != null)
5653 { 5653 {
5654 handlerRequestWearables(); 5654 handlerRequestWearables(sender);
5655 } 5655 }
5656 5656
5657 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData; 5657 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
@@ -5694,7 +5694,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5694 if (appear.ObjectData.TextureEntry.Length > 1) 5694 if (appear.ObjectData.TextureEntry.Length > 1)
5695 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); 5695 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
5696 5696
5697 handlerSetAppearance(te, visualparams); 5697 handlerSetAppearance(sender, te, visualparams);
5698 } 5698 }
5699 catch (Exception e) 5699 catch (Exception e)
5700 { 5700 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2a0c0b1..ad6b1de 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -124,13 +124,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
124 124
125 // Save avatar attachment information 125 // Save avatar attachment information
126 ScenePresence presence; 126 ScenePresence presence;
127 if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 127 if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
128 { 128 {
129 m_log.Info( 129 m_log.Info(
130 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 130 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
131 + ", AttachmentPoint: " + AttachmentPt); 131 + ", AttachmentPoint: " + AttachmentPt);
132 132
133 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 133 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
134 } 134 }
135 } 135 }
136 } 136 }
@@ -382,8 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
382 item = m_scene.InventoryService.GetItem(item); 382 item = m_scene.InventoryService.GetItem(item);
383 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); 383 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
384 384
385 if (m_scene.AvatarFactory != null) 385 if (m_scene.AvatarService != null)
386 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 386 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
387 } 387 }
388 } 388 }
389 389
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
405 presence.Appearance.DetachAttachment(itemID); 405 presence.Appearance.DetachAttachment(itemID);
406 406
407 // Save avatar attachment information 407 // Save avatar attachment information
408 if (m_scene.AvatarFactory != null) 408 if (m_scene.AvatarService != null)
409 { 409 {
410 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); 410 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
411 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 411 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
412 } 412 }
413 } 413 }
414 414
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
435 435
436 presence.Appearance.DetachAttachment(itemID); 436 presence.Appearance.DetachAttachment(itemID);
437 437
438 if (m_scene.AvatarFactory != null) 438 if (m_scene.AvatarService != null)
439 { 439 {
440 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 440 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
441 } 441 }
442 part.ParentGroup.DetachToGround(); 442 part.ParentGroup.DetachToGround();
443 443
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 22c8937..9f7ff7f 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -38,48 +38,20 @@ using OpenSim.Services.Interfaces;
38 38
39namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory 39namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
40{ 40{
41 public class AvatarFactoryModule : IAvatarFactory, IRegionModule 41 public class AvatarFactoryModule : IRegionModule
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
44 private Scene m_scene = null; 45 private Scene m_scene = null;
45 private static readonly AvatarAppearance def = new AvatarAppearance();
46 46
47 public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) 47 private bool m_startAnimationSet = false;
48 {
49 AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId);
50 //if ((profile != null) && (profile.RootFolder != null))
51 if (avatar != null)
52 {
53 appearance = avatar.ToAvatarAppearance(avatarId);
54 return true;
55 }
56
57 m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId);
58 appearance = CreateDefault(avatarId);
59 return false;
60 }
61
62 private AvatarAppearance CreateDefault(UUID avatarId)
63 {
64 AvatarAppearance appearance = null;
65 AvatarWearable[] wearables;
66 byte[] visualParams;
67 GetDefaultAvatarAppearance(out wearables, out visualParams);
68 appearance = new AvatarAppearance(avatarId, wearables, visualParams);
69
70 return appearance;
71 }
72 48
73 public void Initialise(Scene scene, IConfigSource source) 49 public void Initialise(Scene scene, IConfigSource source)
74 { 50 {
75 scene.RegisterModuleInterface<IAvatarFactory>(this);
76 scene.EventManager.OnNewClient += NewClient; 51 scene.EventManager.OnNewClient += NewClient;
77 52
78 if (m_scene == null) 53 if (m_scene == null)
79 {
80 m_scene = scene; 54 m_scene = scene;
81 }
82
83 } 55 }
84 56
85 public void PostInitialise() 57 public void PostInitialise()
@@ -102,6 +74,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
102 74
103 public void NewClient(IClientAPI client) 75 public void NewClient(IClientAPI client)
104 { 76 {
77 client.OnRequestWearables += SendWearables;
78 client.OnSetAppearance += SetAppearance;
105 client.OnAvatarNowWearing += AvatarIsWearing; 79 client.OnAvatarNowWearing += AvatarIsWearing;
106 } 80 }
107 81
@@ -110,42 +84,115 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
110 // client.OnAvatarNowWearing -= AvatarIsWearing; 84 // client.OnAvatarNowWearing -= AvatarIsWearing;
111 } 85 }
112 86
113 public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 87 /// <summary>
88 /// Set appearance data (textureentry and slider settings) received from the client
89 /// </summary>
90 /// <param name="texture"></param>
91 /// <param name="visualParam"></param>
92 public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
114 { 93 {
115 IInventoryService invService = m_scene.InventoryService; 94 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
95 if (sp == null)
96 {
97 m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
98 return;
99 }
100
101// DEBUG ON
102 m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId);
103// DEBUG OFF
116 104
117 if (invService.GetRootFolder(userID) != null) 105/*
106 if (m_physicsActor != null)
118 { 107 {
119 for (int i = 0; i < 13; i++) 108 if (!IsChildAgent)
120 { 109 {
121 if (appearance.Wearables[i].ItemID == UUID.Zero) 110 // This may seem like it's redundant, remove the avatar from the physics scene
122 { 111 // just to add it back again, but it saves us from having to update
123 appearance.Wearables[i].AssetID = UUID.Zero; 112 // 3 variables 10 times a second.
124 } 113 bool flyingTemp = m_physicsActor.Flying;
125 else 114 RemoveFromPhysicalScene();
126 { 115 //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
127 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
128 baseItem = invService.GetItem(baseItem);
129 116
130 if (baseItem != null) 117 //PhysicsActor = null;
131 { 118
132 appearance.Wearables[i].AssetID = baseItem.AssetID; 119 AddToPhysicalScene(flyingTemp);
133 } 120 }
134 else 121 }
122*/
123 #region Bake Cache Check
124
125 bool changed = false;
126
127 // Process the texture entry
128 if (textureEntry != null)
129 {
130 for (int i = 0; i < BAKE_INDICES.Length; i++)
131 {
132 int j = BAKE_INDICES[i];
133 Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
134
135 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
136 {
137 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
135 { 138 {
136 m_log.ErrorFormat( 139 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",face.TextureID,j,this.Name);
137 "[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default", 140 client.SendRebakeAvatarTextures(face.TextureID);
138 appearance.Wearables[i].ItemID, (WearableType)i);
139
140 appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
141 } 141 }
142 } 142 }
143 } 143 }
144 changed = sp.Appearance.SetTextureEntries(textureEntry);
145
146 }
147
148 #endregion Bake Cache Check
149
150 changed = sp.Appearance.SetVisualParams(visualParams) || changed;
151
152 // If nothing changed (this happens frequently) just return
153 if (changed)
154 {
155// DEBUG ON
156 m_log.Warn("[AVFACTORY] Appearance changed");
157// DEBUG OFF
158 sp.Appearance.SetAppearance(textureEntry, visualParams);
159 if (sp.Appearance.AvatarHeight > 0)
160 sp.SetHeight(sp.Appearance.AvatarHeight);
161
162 m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance);
144 } 163 }
164// DEBUG ON
145 else 165 else
166 m_log.Warn("[AVFACTORY] Appearance did not change");
167// DEBUG OFF
168
169 sp.SendAppearanceToAllOtherAgents();
170 if (!m_startAnimationSet)
171 {
172 sp.Animator.UpdateMovementAnimations();
173 m_startAnimationSet = true;
174 }
175
176 client.SendAvatarDataImmediate(sp);
177 client.SendAppearance(sp.Appearance.Owner,sp.Appearance.VisualParams,sp.Appearance.Texture.GetBytes());
178 }
179
180 /// <summary>
181 /// Tell the client for this scene presence what items it should be wearing now
182 /// </summary>
183 public void SendWearables(IClientAPI client)
184 {
185 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
186 if (sp == null)
146 { 187 {
147 m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID); 188 m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId);
189 return;
148 } 190 }
191
192// DEBUG ON
193 m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
194// DEBUG OFF
195 client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++);
149 } 196 }
150 197
151 /// <summary> 198 /// <summary>
@@ -153,65 +200,81 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
153 /// </summary> 200 /// </summary>
154 /// <param name="sender"></param> 201 /// <param name="sender"></param>
155 /// <param name="e"></param> 202 /// <param name="e"></param>
156 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 203 public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
157 { 204 {
158 m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing"); 205 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
159 206 if (sp == null)
160 IClientAPI clientView = (IClientAPI)sender;
161 ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
162
163 if (sp == null)
164 { 207 {
165 m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); 208 m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId);
166 return; 209 return;
167 } 210 }
211
212// DEBUG ON
213 m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId);
214// DEBUG OFF
215
216 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
168 217
169 AvatarAppearance avatAppearance = sp.Appearance; 218 //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
170 //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
171 //{ 219 //{
172 // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); 220 // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
173 // avatAppearance = sp.Appearance; 221 // avatAppearance = sp.Appearance;
174 //} 222 //}
175 223
176 //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); 224 //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
177 225
178 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 226 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
179 { 227 {
180 if (wear.Type < 13) 228 if (wear.Type < AvatarWearable.MAX_WEARABLES)
181 { 229 {
182 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; 230 AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
231 avatAppearance.SetWearable(wear.Type, newWearable);
183 } 232 }
184 } 233 }
185 234
186 SetAppearanceAssets(sp.UUID, ref avatAppearance); 235 SetAppearanceAssets(sp.UUID, ref avatAppearance);
187 AvatarData adata = new AvatarData(avatAppearance);
188 m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
189 236
237 m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
190 sp.Appearance = avatAppearance; 238 sp.Appearance = avatAppearance;
191 } 239 }
192 240
193 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) 241 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
194 { 242 {
195 visualParams = GetDefaultVisualParams(); 243 IInventoryService invService = m_scene.InventoryService;
196 wearables = AvatarWearable.DefaultWearables;
197 }
198 244
199 public void UpdateDatabase(UUID user, AvatarAppearance appearance) 245 if (invService.GetRootFolder(userID) != null)
200 { 246 {
201 //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); 247 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
202 AvatarData adata = new AvatarData(appearance); 248 {
203 m_scene.AvatarService.SetAvatar(user, adata); 249 if (appearance.Wearables[i].ItemID == UUID.Zero)
204 } 250 {
251 appearance.Wearables[i].AssetID = UUID.Zero;
252 }
253 else
254 {
255 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
256 baseItem = invService.GetItem(baseItem);
205 257
206 private static byte[] GetDefaultVisualParams() 258 if (baseItem != null)
207 { 259 {
208 byte[] visualParams; 260 appearance.Wearables[i].AssetID = baseItem.AssetID;
209 visualParams = new byte[218]; 261 }
210 for (int i = 0; i < 218; i++) 262 else
263 {
264 m_log.ErrorFormat(
265 "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
266 appearance.Wearables[i].ItemID, (WearableType)i);
267
268 appearance.Wearables[i].ItemID = UUID.Zero;
269 appearance.Wearables[i].AssetID = UUID.Zero;
270 }
271 }
272 }
273 }
274 else
211 { 275 {
212 visualParams[i] = 100; 276 m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
213 } 277 }
214 return visualParams;
215 } 278 }
216 } 279 }
217} 280}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
index 47f19a3..9ee19f8 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base; 36using OpenSim.Server.Base;
@@ -137,6 +138,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
137 138
138 #region IAvatarService 139 #region IAvatarService
139 140
141 public AvatarAppearance GetAppearance(UUID userID)
142 {
143 return m_AvatarService.GetAppearance(userID);
144 }
145
146 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
147 {
148 return m_AvatarService.SetAppearance(userID,appearance);
149 }
150
140 public AvatarData GetAvatar(UUID userID) 151 public AvatarData GetAvatar(UUID userID)
141 { 152 {
142 return m_AvatarService.GetAvatar(userID); 153 return m_AvatarService.GetAvatar(userID);
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 268612e..f128aa2 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Examples.SimpleModule
82 82
83 public event DeRezObject OnDeRezObject; 83 public event DeRezObject OnDeRezObject;
84 public event Action<IClientAPI> OnRegionHandShakeReply; 84 public event Action<IClientAPI> OnRegionHandShakeReply;
85 public event GenericCall2 OnRequestWearables; 85 public event GenericCall1 OnRequestWearables;
86 public event GenericCall1 OnCompleteMovementToRegion; 86 public event GenericCall1 OnCompleteMovementToRegion;
87 public event UpdateAgent OnPreAgentUpdate; 87 public event UpdateAgent OnPreAgentUpdate;
88 public event UpdateAgent OnAgentUpdate; 88 public event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0cfc235..c69c9b1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -119,7 +119,6 @@ namespace OpenSim.Region.Framework.Scenes
119 119
120 protected IXMLRPC m_xmlrpcModule; 120 protected IXMLRPC m_xmlrpcModule;
121 protected IWorldComm m_worldCommModule; 121 protected IWorldComm m_worldCommModule;
122 protected IAvatarFactory m_AvatarFactory;
123 protected IConfigSource m_config; 122 protected IConfigSource m_config;
124 protected IRegionSerialiserModule m_serialiser; 123 protected IRegionSerialiserModule m_serialiser;
125 protected IDialogModule m_dialogModule; 124 protected IDialogModule m_dialogModule;
@@ -399,11 +398,6 @@ namespace OpenSim.Region.Framework.Scenes
399 398
400 public IAttachmentsModule AttachmentsModule { get; set; } 399 public IAttachmentsModule AttachmentsModule { get; set; }
401 400
402 public IAvatarFactory AvatarFactory
403 {
404 get { return m_AvatarFactory; }
405 }
406
407 public ICapabilitiesModule CapsModule 401 public ICapabilitiesModule CapsModule
408 { 402 {
409 get { return m_capsModule; } 403 get { return m_capsModule; }
@@ -1161,7 +1155,6 @@ namespace OpenSim.Region.Framework.Scenes
1161 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); 1155 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
1162 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1156 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1163 XferManager = RequestModuleInterface<IXfer>(); 1157 XferManager = RequestModuleInterface<IXfer>();
1164 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1165 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); 1158 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1166 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1159 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1167 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1160 m_dialogModule = RequestModuleInterface<IDialogModule>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 13d9964..5dc48d7 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -75,7 +75,6 @@ namespace OpenSim.Region.Framework.Scenes
75 75
76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
77 77
78 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
79// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 78// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
80 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 79 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
81 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 80 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -137,8 +136,6 @@ namespace OpenSim.Region.Framework.Scenes
137 136
138 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 137 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
139 138
140 private bool m_startAnimationSet;
141
142 //private Vector3 m_requestedSitOffset = new Vector3(); 139 //private Vector3 m_requestedSitOffset = new Vector3();
143 140
144 private Vector3 m_LastFinitePos; 141 private Vector3 m_LastFinitePos;
@@ -713,13 +710,14 @@ namespace OpenSim.Region.Framework.Scenes
713 SetDirectionVectors(); 710 SetDirectionVectors();
714 } 711 }
715 712
713/*
716 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 714 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
717 AvatarWearable[] wearables) 715 AvatarWearable[] wearables)
718 : this(client, world, reginfo) 716 : this(client, world, reginfo)
719 { 717 {
720 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 718 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
721 } 719 }
722 720*/
723 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 721 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
724 : this(client, world, reginfo) 722 : this(client, world, reginfo)
725 { 723 {
@@ -733,8 +731,6 @@ namespace OpenSim.Region.Framework.Scenes
733 731
734 public void RegisterToEvents() 732 public void RegisterToEvents()
735 { 733 {
736 m_controllingClient.OnRequestWearables += SendWearables;
737 m_controllingClient.OnSetAppearance += SetAppearance;
738 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 734 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
739 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; 735 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
740 m_controllingClient.OnAgentUpdate += HandleAgentUpdate; 736 m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@@ -1068,7 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes
1068 /// <summary> 1064 /// <summary>
1069 /// Sets avatar height in the phyiscs plugin 1065 /// Sets avatar height in the phyiscs plugin
1070 /// </summary> 1066 /// </summary>
1071 internal void SetHeight(float height) 1067 public void SetHeight(float height)
1072 { 1068 {
1073 m_avHeight = height; 1069 m_avHeight = height;
1074 if (PhysicsActor != null && !IsChildAgent) 1070 if (PhysicsActor != null && !IsChildAgent)
@@ -1133,7 +1129,6 @@ namespace OpenSim.Region.Framework.Scenes
1133 if (friendsModule != null) 1129 if (friendsModule != null)
1134 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1130 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1135 } 1131 }
1136
1137 } 1132 }
1138 1133
1139 /// <summary> 1134 /// <summary>
@@ -2392,9 +2387,12 @@ namespace OpenSim.Region.Framework.Scenes
2392 if (m_appearance.Texture == null) 2387 if (m_appearance.Texture == null)
2393 return; 2388 return;
2394 2389
2395 Vector3 pos = m_pos; 2390 if (IsChildAgent)
2396 pos.Z += m_appearance.HipOffset; 2391 {
2397 2392 m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data");
2393 return;
2394 }
2395
2398 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2396 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
2399 m_scene.StatsReporter.AddAgentUpdates(1); 2397 m_scene.StatsReporter.AddAgentUpdates(1);
2400 } 2398 }
@@ -2437,6 +2435,12 @@ namespace OpenSim.Region.Framework.Scenes
2437 m_perfMonMS = Util.EnvironmentTickCount(); 2435 m_perfMonMS = Util.EnvironmentTickCount();
2438 2436
2439 // only send update from root agents to other clients; children are only "listening posts" 2437 // only send update from root agents to other clients; children are only "listening posts"
2438 if (IsChildAgent)
2439 {
2440 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2441 return;
2442 }
2443
2440 int count = 0; 2444 int count = 0;
2441 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2445 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2442 { 2446 {
@@ -2460,29 +2464,20 @@ namespace OpenSim.Region.Framework.Scenes
2460 // the inventory arrives 2464 // the inventory arrives
2461 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2465 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2462 2466
2463 Vector3 pos = m_pos;
2464 pos.Z += m_appearance.HipOffset;
2465
2466 m_controllingClient.SendAvatarDataImmediate(this); 2467 m_controllingClient.SendAvatarDataImmediate(this);
2468 m_controllingClient.SendAppearance(m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
2467 2469
2468 SendInitialFullUpdateToAllClients(); 2470 SendInitialFullUpdateToAllClients();
2469 } 2471 }
2470 2472
2471 /// <summary> 2473 /// <summary>
2472 /// Tell the client for this scene presence what items it should be wearing now
2473 /// </summary>
2474 public void SendWearables()
2475 {
2476 m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name);
2477
2478 ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2479 }
2480
2481 /// <summary>
2482 /// 2474 ///
2483 /// </summary> 2475 /// </summary>
2484 public void SendAppearanceToAllOtherAgents() 2476 public void SendAppearanceToAllOtherAgents()
2485 { 2477 {
2478// DEBUG ON
2479 m_log.WarnFormat("[SP] Send appearance from {0} to all other agents",m_uuid);
2480// DEBUG OFF
2486 m_perfMonMS = Util.EnvironmentTickCount(); 2481 m_perfMonMS = Util.EnvironmentTickCount();
2487 2482
2488 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2483 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
@@ -2502,87 +2497,13 @@ namespace OpenSim.Region.Framework.Scenes
2502 /// <param name="avatar"></param> 2497 /// <param name="avatar"></param>
2503 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2498 public void SendAppearanceToOtherAgent(ScenePresence avatar)
2504 { 2499 {
2500// DEBUG ON
2501 m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2502// DEBUG OFF
2505 avatar.ControllingClient.SendAppearance( 2503 avatar.ControllingClient.SendAppearance(
2506 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2504 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
2507 } 2505 }
2508 2506
2509 /// <summary>
2510 /// Set appearance data (textureentry and slider settings) received from the client
2511 /// </summary>
2512 /// <param name="texture"></param>
2513 /// <param name="visualParam"></param>
2514 public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
2515 {
2516 if (m_physicsActor != null)
2517 {
2518 if (!IsChildAgent)
2519 {
2520 // This may seem like it's redundant, remove the avatar from the physics scene
2521 // just to add it back again, but it saves us from having to update
2522 // 3 variables 10 times a second.
2523 bool flyingTemp = m_physicsActor.Flying;
2524 RemoveFromPhysicalScene();
2525 //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
2526
2527 //PhysicsActor = null;
2528
2529 AddToPhysicalScene(flyingTemp);
2530 }
2531 }
2532
2533 #region Bake Cache Check
2534
2535 if (textureEntry != null)
2536 {
2537 for (int i = 0; i < BAKE_INDICES.Length; i++)
2538 {
2539 int j = BAKE_INDICES[i];
2540 Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
2541
2542 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
2543 {
2544 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
2545 {
2546 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
2547 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
2548 }
2549 }
2550 }
2551
2552 }
2553
2554
2555 #endregion Bake Cache Check
2556
2557 m_appearance.SetAppearance(textureEntry, visualParams);
2558 if (m_appearance.AvatarHeight > 0)
2559 SetHeight(m_appearance.AvatarHeight);
2560
2561 // This is not needed, because only the transient data changed
2562 //AvatarData adata = new AvatarData(m_appearance);
2563 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2564
2565 SendAppearanceToAllOtherAgents();
2566 if (!m_startAnimationSet)
2567 {
2568 Animator.UpdateMovementAnimations();
2569 m_startAnimationSet = true;
2570 }
2571
2572 Vector3 pos = m_pos;
2573 pos.Z += m_appearance.HipOffset;
2574
2575 m_controllingClient.SendAvatarDataImmediate(this);
2576 }
2577
2578 public void SetWearable(int wearableId, AvatarWearable wearable)
2579 {
2580 m_appearance.SetWearable(wearableId, wearable);
2581 AvatarData adata = new AvatarData(m_appearance);
2582 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2583 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2584 }
2585
2586 // Because appearance setting is in a module, we actually need 2507 // Because appearance setting is in a module, we actually need
2587 // to give it access to our appearance directly, otherwise we 2508 // to give it access to our appearance directly, otherwise we
2588 // get a synchronization issue. 2509 // get a synchronization issue.
@@ -2976,6 +2897,9 @@ namespace OpenSim.Region.Framework.Scenes
2976 2897
2977 public void CopyTo(AgentData cAgent) 2898 public void CopyTo(AgentData cAgent)
2978 { 2899 {
2900// DEBUG ON
2901 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYTO");
2902// DEBUG OFF
2979 cAgent.AgentID = UUID; 2903 cAgent.AgentID = UUID;
2980 cAgent.RegionID = Scene.RegionInfo.RegionID; 2904 cAgent.RegionID = Scene.RegionInfo.RegionID;
2981 2905
@@ -3015,6 +2939,9 @@ namespace OpenSim.Region.Framework.Scenes
3015 2939
3016 cAgent.AlwaysRun = m_setAlwaysRun; 2940 cAgent.AlwaysRun = m_setAlwaysRun;
3017 2941
2942 cAgent.Appearance = new AvatarAppearance(m_appearance);
2943
2944/*
3018 try 2945 try
3019 { 2946 {
3020 // We might not pass the Wearables in all cases... 2947 // We might not pass the Wearables in all cases...
@@ -3054,14 +2981,14 @@ namespace OpenSim.Region.Framework.Scenes
3054 { 2981 {
3055 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); 2982 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3056 int i = 0; 2983 int i = 0;
3057 AttachmentData[] attachs = new AttachmentData[attPoints.Count]; 2984 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3058 foreach (int point in attPoints) 2985 foreach (int point in attPoints)
3059 { 2986 {
3060 attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); 2987 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3061 } 2988 }
3062 cAgent.Attachments = attachs; 2989 cAgent.Attachments = attachs;
3063 } 2990 }
3064 2991*/
3065 lock (scriptedcontrols) 2992 lock (scriptedcontrols)
3066 { 2993 {
3067 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 2994 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3088,6 +3015,9 @@ namespace OpenSim.Region.Framework.Scenes
3088 3015
3089 public void CopyFrom(AgentData cAgent) 3016 public void CopyFrom(AgentData cAgent)
3090 { 3017 {
3018// DEBUG ON
3019 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3020// DEBUG OFF
3091 m_originRegionID = cAgent.RegionID; 3021 m_originRegionID = cAgent.RegionID;
3092 3022
3093 m_callbackURI = cAgent.CallbackURI; 3023 m_callbackURI = cAgent.CallbackURI;
@@ -3113,6 +3043,9 @@ namespace OpenSim.Region.Framework.Scenes
3113 m_godLevel = cAgent.GodLevel; 3043 m_godLevel = cAgent.GodLevel;
3114 m_setAlwaysRun = cAgent.AlwaysRun; 3044 m_setAlwaysRun = cAgent.AlwaysRun;
3115 3045
3046 m_appearance = new AvatarAppearance(cAgent.Appearance);
3047
3048/*
3116 uint i = 0; 3049 uint i = 0;
3117 try 3050 try
3118 { 3051 {
@@ -3125,15 +3058,17 @@ namespace OpenSim.Region.Framework.Scenes
3125 UUID assetId = cAgent.Wearables[n + 1]; 3058 UUID assetId = cAgent.Wearables[n + 1];
3126 wears[i++] = new AvatarWearable(itemId, assetId); 3059 wears[i++] = new AvatarWearable(itemId, assetId);
3127 } 3060 }
3128 m_appearance.Wearables = wears; 3061 // m_appearance.Wearables = wears;
3129 Primitive.TextureEntry te; 3062 Primitive.TextureEntry textures = null;
3130 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) 3063 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3131 te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); 3064 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3132 else 3065
3133 te = AvatarAppearance.GetDefaultTexture(); 3066 byte[] visuals = null;
3134 if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) 3067
3135 cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); 3068 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3136 m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); 3069 visuals = (byte[])cAgent.VisualParams.Clone();
3070
3071 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3137 } 3072 }
3138 catch (Exception e) 3073 catch (Exception e)
3139 { 3074 {
@@ -3146,14 +3081,14 @@ namespace OpenSim.Region.Framework.Scenes
3146 if (cAgent.Attachments != null) 3081 if (cAgent.Attachments != null)
3147 { 3082 {
3148 m_appearance.ClearAttachments(); 3083 m_appearance.ClearAttachments();
3149 foreach (AttachmentData att in cAgent.Attachments) 3084 foreach (AvatarAttachment att in cAgent.Attachments)
3150 { 3085 {
3151 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); 3086 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3152 } 3087 }
3153 } 3088 }
3154 } 3089 }
3155 catch { } 3090 catch { }
3156 3091*/
3157 try 3092 try
3158 { 3093 {
3159 lock (scriptedcontrols) 3094 lock (scriptedcontrols)
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 159af79..fc17192 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -676,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
676 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 676 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
677 public event DeRezObject OnDeRezObject; 677 public event DeRezObject OnDeRezObject;
678 public event Action<IClientAPI> OnRegionHandShakeReply; 678 public event Action<IClientAPI> OnRegionHandShakeReply;
679 public event GenericCall2 OnRequestWearables; 679 public event GenericCall1 OnRequestWearables;
680 public event GenericCall1 OnCompleteMovementToRegion; 680 public event GenericCall1 OnCompleteMovementToRegion;
681 public event UpdateAgent OnPreAgentUpdate; 681 public event UpdateAgent OnPreAgentUpdate;
682 public event UpdateAgent OnAgentUpdate; 682 public event UpdateAgent OnAgentUpdate;
@@ -899,7 +899,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
899 Scene scene = (Scene)Scene; 899 Scene scene = (Scene)Scene;
900 AvatarAppearance appearance; 900 AvatarAppearance appearance;
901 scene.GetAvatarAppearance(this, out appearance); 901 scene.GetAvatarAppearance(this, out appearance);
902 OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); 902 OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
903 } 903 }
904 904
905 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) 905 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index fae12b6..6928c4e 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -188,7 +188,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
188 188
189 public event DeRezObject OnDeRezObject; 189 public event DeRezObject OnDeRezObject;
190 public event Action<IClientAPI> OnRegionHandShakeReply; 190 public event Action<IClientAPI> OnRegionHandShakeReply;
191 public event GenericCall2 OnRequestWearables; 191 public event GenericCall1 OnRequestWearables;
192 public event GenericCall1 OnCompleteMovementToRegion; 192 public event GenericCall1 OnCompleteMovementToRegion;
193 public event UpdateAgent OnPreAgentUpdate; 193 public event UpdateAgent OnPreAgentUpdate;
194 public event UpdateAgent OnAgentUpdate; 194 public event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index ab0be77..c471636 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -64,15 +64,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
64 if (m_appearanceCache.ContainsKey(target)) 64 if (m_appearanceCache.ContainsKey(target))
65 return m_appearanceCache[target]; 65 return m_appearanceCache[target];
66 66
67 AvatarData adata = scene.AvatarService.GetAvatar(target); 67 AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
68 if (adata != null) 68 if (appearance != null)
69 { 69 {
70 AvatarAppearance x = adata.ToAvatarAppearance(target); 70 m_appearanceCache.Add(target, appearance);
71 71 return appearance;
72 m_appearanceCache.Add(target, x);
73
74 return x;
75 } 72 }
73
76 return new AvatarAppearance(); 74 return new AvatarAppearance();
77 } 75 }
78 76
@@ -169,7 +167,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
169 { 167 {
170 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); 168 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
171 169
172 sp.SetAppearance(x.Texture, (byte[])x.VisualParams.Clone()); 170 sp.Appearance.SetTextureEntries(x.Texture);
171 sp.Appearance.SetVisualParams((byte[])x.VisualParams.Clone());
172 sp.SendAppearanceToAllOtherAgents();
173 } 173 }
174 174
175 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 175 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs
index 19e662c..a8ad413 100644
--- a/OpenSim/Services/AvatarService/AvatarService.cs
+++ b/OpenSim/Services/AvatarService/AvatarService.cs
@@ -51,6 +51,20 @@ namespace OpenSim.Services.AvatarService
51 m_log.Debug("[AVATAR SERVICE]: Starting avatar service"); 51 m_log.Debug("[AVATAR SERVICE]: Starting avatar service");
52 } 52 }
53 53
54 // Get|SetAppearance should preserve existing semantics
55 // until AvatarData can be removed completely
56 public AvatarAppearance GetAppearance(UUID principalID)
57 {
58 AvatarData avatar = GetAvatar(principalID);
59 return avatar.ToAvatarAppearance(principalID);
60 }
61
62 public bool SetAppearance(UUID principalID, AvatarAppearance appearance)
63 {
64 AvatarData avatar = new AvatarData(appearance);
65 return SetAvatar(principalID,avatar);
66 }
67
54 public AvatarData GetAvatar(UUID principalID) 68 public AvatarData GetAvatar(UUID principalID)
55 { 69 {
56 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); 70 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString());
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
index 96c05a9..1cd6bf8 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
@@ -87,6 +87,18 @@ namespace OpenSim.Services.Connectors
87 87
88 #region IAvatarService 88 #region IAvatarService
89 89
90 public AvatarAppearance GetAppearance(UUID userID)
91 {
92 AvatarData avatar = GetAvatar(userID);
93 return avatar.ToAvatarAppearance(userID);
94 }
95
96 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
97 {
98 AvatarData avatar = new AvatarData(appearance);
99 return SetAvatar(userID,avatar);
100 }
101
90 public AvatarData GetAvatar(UUID userID) 102 public AvatarData GetAvatar(UUID userID)
91 { 103 {
92 Dictionary<string, object> sendData = new Dictionary<string, object>(); 104 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index 4d0d53e..ea9b4b4 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -28,6 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31// DEBUG ON
32using System.Diagnostics;
33// DEBUG OFF
31using System.Reflection; 34using System.Reflection;
32using log4net; 35using log4net;
33using Mono.Addins; 36using Mono.Addins;
@@ -106,6 +109,80 @@ namespace OpenSim.Services.Connectors.SimianGrid
106 109
107 #region IAvatarService 110 #region IAvatarService
108 111
112 // <summary>
113 // Retrieves the LLPackedAppearance field from user data and unpacks
114 // it into an AvatarAppearance structure
115 // </summary>
116 // <param name="userID"></param>
117 public AvatarAppearance GetAppearance(UUID userID)
118 {
119 NameValueCollection requestArgs = new NameValueCollection
120 {
121 { "RequestMethod", "GetUser" },
122 { "UserID", userID.ToString() }
123 };
124
125 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
126 if (response["Success"].AsBoolean())
127 {
128 OSDMap map = null;
129 try { map = OSDParser.DeserializeJson(response["LLPackedAppearance"].AsString()) as OSDMap; }
130 catch { }
131
132 if (map != null)
133 {
134 AvatarAppearance appearance = new AvatarAppearance(map);
135// DEBUG ON
136 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] retrieved appearance for {0}:\n{1}",userID,appearance.ToString());
137// DEBUG OFF
138 return appearance;
139 }
140
141 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to decode appearance for {0}",userID);
142 return null;
143 }
144
145 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to get appearance for {0}: {1}",
146 userID,response["Message"].AsString());
147 return null;
148 }
149
150 // <summary>
151 // </summary>
152 // <param name=""></param>
153 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
154 {
155 OSDMap map = appearance.Pack();
156 if (map == null)
157 {
158 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
159 return false;
160 }
161
162// DEBUG ON
163 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] save appearance for {0}",userID);
164// DEBUG OFF
165
166 NameValueCollection requestArgs = new NameValueCollection
167 {
168 { "RequestMethod", "AddUserData" },
169 { "UserID", userID.ToString() },
170 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
171 };
172
173 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
174 bool success = response["Success"].AsBoolean();
175
176 if (! success)
177 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to save appearance for {0}: {1}",
178 userID,response["Message"].AsString());
179
180 return success;
181 }
182
183 // <summary>
184 // </summary>
185 // <param name=""></param>
109 public AvatarData GetAvatar(UUID userID) 186 public AvatarData GetAvatar(UUID userID)
110 { 187 {
111 NameValueCollection requestArgs = new NameValueCollection 188 NameValueCollection requestArgs = new NameValueCollection
@@ -154,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
154 foreach (KeyValuePair<string, OSD> kvp in map) 231 foreach (KeyValuePair<string, OSD> kvp in map)
155 avatar.Data[kvp.Key] = kvp.Value.AsString(); 232 avatar.Data[kvp.Key] = kvp.Value.AsString();
156 } 233 }
157 234
158 return avatar; 235 return avatar;
159 } 236 }
160 else 237 else
@@ -173,6 +250,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
173 return null; 250 return null;
174 } 251 }
175 252
253 // <summary>
254 // </summary>
255 // <param name=""></param>
176 public bool SetAvatar(UUID userID, AvatarData avatar) 256 public bool SetAvatar(UUID userID, AvatarData avatar)
177 { 257 {
178 m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID); 258 m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID);
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index de3bcf9..93b977b 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -42,6 +42,21 @@ namespace OpenSim.Services.Interfaces
42 /// </summary> 42 /// </summary>
43 /// <param name="userID"></param> 43 /// <param name="userID"></param>
44 /// <returns></returns> 44 /// <returns></returns>
45 AvatarAppearance GetAppearance(UUID userID);
46
47 /// <summary>
48 /// Called by everyone who can change the avatar data (so, regions)
49 /// </summary>
50 /// <param name="userID"></param>
51 /// <param name="appearance"></param>
52 /// <returns></returns>
53 bool SetAppearance(UUID userID, AvatarAppearance appearance);
54
55 /// <summary>
56 /// Called by the login service
57 /// </summary>
58 /// <param name="userID"></param>
59 /// <returns></returns>
45 AvatarData GetAvatar(UUID userID); 60 AvatarData GetAvatar(UUID userID);
46 61
47 /// <summary> 62 /// <summary>
@@ -217,23 +232,26 @@ namespace OpenSim.Services.Interfaces
217 foreach (KeyValuePair<string, string> _kvp in Data) 232 foreach (KeyValuePair<string, string> _kvp in Data)
218 if (_kvp.Key.StartsWith("_ap_")) 233 if (_kvp.Key.StartsWith("_ap_"))
219 attchs[_kvp.Key] = _kvp.Value; 234 attchs[_kvp.Key] = _kvp.Value;
220 Hashtable aaAttachs = new Hashtable(); 235
221 foreach (KeyValuePair<string, string> _kvp in attchs) 236 foreach (KeyValuePair<string, string> _kvp in attchs)
222 { 237 {
223 string pointStr = _kvp.Key.Substring(4); 238 string pointStr = _kvp.Key.Substring(4);
224 int point = 0; 239 int point = 0;
225 if (!Int32.TryParse(pointStr, out point)) 240 if (!Int32.TryParse(pointStr, out point))
226 continue; 241 continue;
227 Hashtable tmp = new Hashtable(); 242
228 UUID uuid = UUID.Zero; 243 UUID uuid = UUID.Zero;
229 UUID.TryParse(_kvp.Value, out uuid); 244 UUID.TryParse(_kvp.Value, out uuid);
230 tmp["item"] = uuid; 245
231 tmp["asset"] = UUID.Zero.ToString(); 246 appearance.SetAttachment(point,uuid,UUID.Zero);
232 aaAttachs[point] = tmp;
233 } 247 }
234 appearance.SetAttachments(aaAttachs);
235 } 248 }
236 catch { } 249 catch
250 {
251 // We really should report something here, returning null
252 // will at least break the wrapper
253 return null;
254 }
237 255
238 return appearance; 256 return appearance;
239 } 257 }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 127c4b2..a06476e 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -330,10 +330,10 @@ namespace OpenSim.Services.LLLoginService
330 // 330 //
331 // Get the avatar 331 // Get the avatar
332 // 332 //
333 AvatarData avatar = null; 333 AvatarAppearance avatar = null;
334 if (m_AvatarService != null) 334 if (m_AvatarService != null)
335 { 335 {
336 avatar = m_AvatarService.GetAvatar(account.PrincipalID); 336 avatar = m_AvatarService.GetAppearance(account.PrincipalID);
337 } 337 }
338 338
339 // 339 //
@@ -601,7 +601,7 @@ namespace OpenSim.Services.LLLoginService
601 } 601 }
602 } 602 }
603 603
604 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar, 604 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
605 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, 605 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
606 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest) 606 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest)
607 { 607 {
@@ -697,14 +697,14 @@ namespace OpenSim.Services.LLLoginService
697 } 697 }
698 698
699 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 699 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
700 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 700 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
701 string ipaddress, string viewer, string channel, string mac, string id0) 701 string ipaddress, string viewer, string channel, string mac, string id0)
702 { 702 {
703 AgentCircuitData aCircuit = new AgentCircuitData(); 703 AgentCircuitData aCircuit = new AgentCircuitData();
704 704
705 aCircuit.AgentID = account.PrincipalID; 705 aCircuit.AgentID = account.PrincipalID;
706 if (avatar != null) 706 if (avatar != null)
707 aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); 707 aCircuit.Appearance = new AvatarAppearance(avatar);
708 else 708 else
709 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID); 709 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID);
710 710
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index e46f9b7..b2c8b35 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Tests.Common.Mock
94 94
95 public event DeRezObject OnDeRezObject; 95 public event DeRezObject OnDeRezObject;
96 public event Action<IClientAPI> OnRegionHandShakeReply; 96 public event Action<IClientAPI> OnRegionHandShakeReply;
97 public event GenericCall2 OnRequestWearables; 97 public event GenericCall1 OnRequestWearables;
98 public event GenericCall1 OnCompleteMovementToRegion; 98 public event GenericCall1 OnCompleteMovementToRegion;
99 public event UpdateAgent OnPreAgentUpdate; 99 public event UpdateAgent OnPreAgentUpdate;
100 public event UpdateAgent OnAgentUpdate; 100 public event UpdateAgent OnAgentUpdate;