aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-10-29 20:40:48 +0100
committerMelanie2010-10-29 20:40:48 +0100
commit9331898c320d7d6046c6d1ad467cdee0e32c8b71 (patch)
tree917ff7facdeb38d96f5f69576a134cbad4776eae /OpenSim
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
parentMerge branch 'dev-appearance' (diff)
downloadopensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.zip
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.gz
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.bz2
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-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.cs171
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs1
-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/GridService/HypergridLinker.cs47
-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
31 files changed, 982 insertions, 810 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 76c9046..d6fe347 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -1590,12 +1590,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1590 { 1590 {
1591 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source); 1591 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source);
1592 Scene scene = m_application.SceneManager.CurrentOrFirstScene; 1592 Scene scene = m_application.SceneManager.CurrentOrFirstScene;
1593 AvatarAppearance avatarAppearance = null;
1594 AvatarData avatar = scene.AvatarService.GetAvatar(source);
1595 if (avatar != null)
1596 avatarAppearance = avatar.ToAvatarAppearance(source);
1597 1593
1598 // If the model has no associated appearance we're done. 1594 // If the model has no associated appearance we're done.
1595 AvatarAppearance avatarAppearance = scene.AvatarService.GetAppearance(source);
1599 if (avatarAppearance == null) 1596 if (avatarAppearance == null)
1600 return; 1597 return;
1601 1598
@@ -1609,8 +1606,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1609 { 1606 {
1610 CopyWearablesAndAttachments(destination, source, avatarAppearance); 1607 CopyWearablesAndAttachments(destination, source, avatarAppearance);
1611 1608
1612 AvatarData avatarData = new AvatarData(avatarAppearance); 1609 scene.AvatarService.SetAppearance(destination, avatarAppearance);
1613 scene.AvatarService.SetAvatar(destination, avatarData);
1614 } 1610 }
1615 catch (Exception e) 1611 catch (Exception e)
1616 { 1612 {
@@ -1641,8 +1637,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1641 } 1637 }
1642 } 1638 }
1643 1639
1644 AvatarData avatarData = new AvatarData(avatarAppearance); 1640 scene.AvatarService.SetAppearance(destination, avatarAppearance);
1645 scene.AvatarService.SetAvatar(destination, avatarData);
1646 } 1641 }
1647 catch (Exception e) 1642 catch (Exception e)
1648 { 1643 {
@@ -1737,12 +1732,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1737 } 1732 }
1738 1733
1739 // Attachments 1734 // Attachments
1740 Dictionary<int, UUID[]> attachments = avatarAppearance.GetAttachmentDictionary(); 1735 Dictionary<int, AvatarAttachment> attachments = avatarAppearance.Attachments;
1741 1736
1742 foreach (KeyValuePair<int, UUID[]> attachment in attachments) 1737 foreach (KeyValuePair<int, AvatarAttachment> attachment in attachments)
1743 { 1738 {
1744 int attachpoint = attachment.Key; 1739 int attachpoint = attachment.Value.AttachPoint;
1745 UUID itemID = attachment.Value[0]; 1740 UUID itemID = attachment.Value.ItemID;
1746 1741
1747 if (itemID != UUID.Zero) 1742 if (itemID != UUID.Zero)
1748 { 1743 {
@@ -2026,10 +2021,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2026 if (include) 2021 if (include)
2027 { 2022 {
2028 // Setup for appearance processing 2023 // Setup for appearance processing
2029 AvatarData avatarData = scene.AvatarService.GetAvatar(ID); 2024 avatarAppearance = scene.AvatarService.GetAppearance(ID);
2030 if (avatarData != null) 2025 if (avatarAppearance == null)
2031 avatarAppearance = avatarData.ToAvatarAppearance(ID);
2032 else
2033 avatarAppearance = new AvatarAppearance(); 2026 avatarAppearance = new AvatarAppearance();
2034 2027
2035 AvatarWearable[] wearables = avatarAppearance.Wearables; 2028 AvatarWearable[] wearables = avatarAppearance.Wearables;
@@ -2194,8 +2187,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2194 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName); 2187 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName);
2195 } // foreach outfit 2188 } // foreach outfit
2196 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); 2189 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
2197 AvatarData avatarData2 = new AvatarData(avatarAppearance); 2190 scene.AvatarService.SetAppearance(ID, avatarAppearance);
2198 scene.AvatarService.SetAvatar(ID, avatarData2);
2199 } 2191 }
2200 catch (Exception e) 2192 catch (Exception e)
2201 { 2193 {
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index df9d21b..a720db4 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -597,7 +597,7 @@ namespace OpenSim.Client.MXP.ClientStack
597 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 597 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
598 public event DeRezObject OnDeRezObject; 598 public event DeRezObject OnDeRezObject;
599 public event Action<IClientAPI> OnRegionHandShakeReply; 599 public event Action<IClientAPI> OnRegionHandShakeReply;
600 public event GenericCall2 OnRequestWearables; 600 public event GenericCall1 OnRequestWearables;
601 public event GenericCall1 OnCompleteMovementToRegion; 601 public event GenericCall1 OnCompleteMovementToRegion;
602 public event UpdateAgent OnPreAgentUpdate; 602 public event UpdateAgent OnPreAgentUpdate;
603 public event UpdateAgent OnAgentUpdate; 603 public event UpdateAgent OnAgentUpdate;
@@ -874,7 +874,7 @@ namespace OpenSim.Client.MXP.ClientStack
874 OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene; 874 OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene;
875 AvatarAppearance appearance; 875 AvatarAppearance appearance;
876 scene.GetAvatarAppearance(this,out appearance); 876 scene.GetAvatarAppearance(this,out appearance);
877 OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); 877 OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
878 } 878 }
879 879
880 public void Stop() 880 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 26be5d9..1b4c0c5 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 51482a1..1e1dfa8 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
@@ -714,7 +714,7 @@ namespace OpenSim.Framework
714 event TeleportLandmarkRequest OnTeleportLandmarkRequest; 714 event TeleportLandmarkRequest OnTeleportLandmarkRequest;
715 event DeRezObject OnDeRezObject; 715 event DeRezObject OnDeRezObject;
716 event Action<IClientAPI> OnRegionHandShakeReply; 716 event Action<IClientAPI> OnRegionHandShakeReply;
717 event GenericCall2 OnRequestWearables; 717 event GenericCall1 OnRequestWearables;
718 event GenericCall1 OnCompleteMovementToRegion; 718 event GenericCall1 OnCompleteMovementToRegion;
719 event UpdateAgent OnPreAgentUpdate; 719 event UpdateAgent OnPreAgentUpdate;
720 event UpdateAgent OnAgentUpdate; 720 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 e5cf0dc..b532cd4 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;
@@ -5681,11 +5681,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5681 5681
5682 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack) 5682 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
5683 { 5683 {
5684 GenericCall2 handlerRequestWearables = OnRequestWearables; 5684 GenericCall1 handlerRequestWearables = OnRequestWearables;
5685 5685
5686 if (handlerRequestWearables != null) 5686 if (handlerRequestWearables != null)
5687 { 5687 {
5688 handlerRequestWearables(); 5688 handlerRequestWearables(sender);
5689 } 5689 }
5690 5690
5691 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData; 5691 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
@@ -5728,7 +5728,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5728 if (appear.ObjectData.TextureEntry.Length > 1) 5728 if (appear.ObjectData.TextureEntry.Length > 1)
5729 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); 5729 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
5730 5730
5731 handlerSetAppearance(te, visualparams); 5731 handlerSetAppearance(sender, te, visualparams);
5732 } 5732 }
5733 catch (Exception e) 5733 catch (Exception e)
5734 { 5734 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index bf71c07..facf146 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -125,13 +125,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
125 125
126 // Save avatar attachment information 126 // Save avatar attachment information
127 ScenePresence presence; 127 ScenePresence presence;
128 if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 128 if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
129 { 129 {
130 m_log.Info( 130 m_log.Info(
131 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 131 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
132 + ", AttachmentPoint: " + AttachmentPt); 132 + ", AttachmentPoint: " + AttachmentPt);
133 133
134 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 134 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
135 } 135 }
136 } 136 }
137 } 137 }
@@ -399,8 +399,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
399 item = m_scene.InventoryService.GetItem(item); 399 item = m_scene.InventoryService.GetItem(item);
400 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); 400 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
401 401
402 if (m_scene.AvatarFactory != null) 402 if (m_scene.AvatarService != null)
403 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 403 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
404 } 404 }
405 } 405 }
406 406
@@ -422,10 +422,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
422 presence.Appearance.DetachAttachment(itemID); 422 presence.Appearance.DetachAttachment(itemID);
423 423
424 // Save avatar attachment information 424 // Save avatar attachment information
425 if (m_scene.AvatarFactory != null) 425 if (m_scene.AvatarService != null)
426 { 426 {
427 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); 427 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
428 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 428 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
429 } 429 }
430 } 430 }
431 431
@@ -452,9 +452,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
452 452
453 presence.Appearance.DetachAttachment(itemID); 453 presence.Appearance.DetachAttachment(itemID);
454 454
455 if (m_scene.AvatarFactory != null) 455 if (m_scene.AvatarService != null)
456 { 456 {
457 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 457 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
458 } 458 }
459 part.ParentGroup.DetachToGround(); 459 part.ParentGroup.DetachToGround();
460 460
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 db427b4..09f615f 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 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; 82 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
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 c3edeb3..f0f8d55 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -120,7 +120,6 @@ namespace OpenSim.Region.Framework.Scenes
120 120
121 protected IXMLRPC m_xmlrpcModule; 121 protected IXMLRPC m_xmlrpcModule;
122 protected IWorldComm m_worldCommModule; 122 protected IWorldComm m_worldCommModule;
123 protected IAvatarFactory m_AvatarFactory;
124 protected IConfigSource m_config; 123 protected IConfigSource m_config;
125 protected IRegionSerialiserModule m_serialiser; 124 protected IRegionSerialiserModule m_serialiser;
126 protected IDialogModule m_dialogModule; 125 protected IDialogModule m_dialogModule;
@@ -415,11 +414,6 @@ namespace OpenSim.Region.Framework.Scenes
415 414
416 public IAttachmentsModule AttachmentsModule { get; set; } 415 public IAttachmentsModule AttachmentsModule { get; set; }
417 416
418 public IAvatarFactory AvatarFactory
419 {
420 get { return m_AvatarFactory; }
421 }
422
423 public ICapabilitiesModule CapsModule 417 public ICapabilitiesModule CapsModule
424 { 418 {
425 get { return m_capsModule; } 419 get { return m_capsModule; }
@@ -1193,7 +1187,6 @@ namespace OpenSim.Region.Framework.Scenes
1193 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); 1187 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
1194 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1188 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1195 XferManager = RequestModuleInterface<IXfer>(); 1189 XferManager = RequestModuleInterface<IXfer>();
1196 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1197 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); 1190 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1198 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1191 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1199 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1192 m_dialogModule = RequestModuleInterface<IDialogModule>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7bf0a99..8cbf4dc 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -76,7 +76,6 @@ namespace OpenSim.Region.Framework.Scenes
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
78 78
79 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
80// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 79// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
81 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 80 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
82 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 81 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -143,8 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
143 142
144 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 143 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
145 144
146 private bool m_startAnimationSet;
147
148 //private Vector3 m_requestedSitOffset = new Vector3(); 145 //private Vector3 m_requestedSitOffset = new Vector3();
149 146
150 private Vector3 m_LastFinitePos; 147 private Vector3 m_LastFinitePos;
@@ -778,13 +775,14 @@ namespace OpenSim.Region.Framework.Scenes
778 SetDirectionVectors(); 775 SetDirectionVectors();
779 } 776 }
780 777
778/*
781 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 779 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
782 AvatarWearable[] wearables) 780 AvatarWearable[] wearables)
783 : this(client, world, reginfo) 781 : this(client, world, reginfo)
784 { 782 {
785 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 783 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
786 } 784 }
787 785*/
788 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 786 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
789 : this(client, world, reginfo) 787 : this(client, world, reginfo)
790 { 788 {
@@ -798,8 +796,6 @@ namespace OpenSim.Region.Framework.Scenes
798 796
799 public void RegisterToEvents() 797 public void RegisterToEvents()
800 { 798 {
801 m_controllingClient.OnRequestWearables += SendWearables;
802 m_controllingClient.OnSetAppearance += SetAppearance;
803 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 799 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
804 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; 800 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
805 m_controllingClient.OnAgentUpdate += HandleAgentUpdate; 801 m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@@ -1208,7 +1204,7 @@ namespace OpenSim.Region.Framework.Scenes
1208 /// <summary> 1204 /// <summary>
1209 /// Sets avatar height in the phyiscs plugin 1205 /// Sets avatar height in the phyiscs plugin
1210 /// </summary> 1206 /// </summary>
1211 internal void SetHeight(float height) 1207 public void SetHeight(float height)
1212 { 1208 {
1213 m_avHeight = height; 1209 m_avHeight = height;
1214 if (PhysicsActor != null && !IsChildAgent) 1210 if (PhysicsActor != null && !IsChildAgent)
@@ -1272,7 +1268,6 @@ namespace OpenSim.Region.Framework.Scenes
1272 if (friendsModule != null) 1268 if (friendsModule != null)
1273 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1269 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1274 } 1270 }
1275
1276 } 1271 }
1277 1272
1278 /// <summary> 1273 /// <summary>
@@ -2742,9 +2737,12 @@ namespace OpenSim.Region.Framework.Scenes
2742 if (m_appearance.Texture == null) 2737 if (m_appearance.Texture == null)
2743 return; 2738 return;
2744 2739
2745 Vector3 pos = m_pos; 2740 if (IsChildAgent)
2746 pos.Z += m_appearance.HipOffset; 2741 {
2747 2742 m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data");
2743 return;
2744 }
2745
2748 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2746 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
2749 m_scene.StatsReporter.AddAgentUpdates(1); 2747 m_scene.StatsReporter.AddAgentUpdates(1);
2750 } 2748 }
@@ -2787,6 +2785,12 @@ namespace OpenSim.Region.Framework.Scenes
2787 m_perfMonMS = Util.EnvironmentTickCount(); 2785 m_perfMonMS = Util.EnvironmentTickCount();
2788 2786
2789 // only send update from root agents to other clients; children are only "listening posts" 2787 // only send update from root agents to other clients; children are only "listening posts"
2788 if (IsChildAgent)
2789 {
2790 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2791 return;
2792 }
2793
2790 int count = 0; 2794 int count = 0;
2791 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2795 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2792 { 2796 {
@@ -2810,29 +2814,20 @@ namespace OpenSim.Region.Framework.Scenes
2810 // the inventory arrives 2814 // the inventory arrives
2811 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2815 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2812 2816
2813 Vector3 pos = m_pos;
2814 pos.Z += m_appearance.HipOffset;
2815
2816 m_controllingClient.SendAvatarDataImmediate(this); 2817 m_controllingClient.SendAvatarDataImmediate(this);
2818 m_controllingClient.SendAppearance(m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
2817 2819
2818 SendInitialFullUpdateToAllClients(); 2820 SendInitialFullUpdateToAllClients();
2819 } 2821 }
2820 2822
2821 /// <summary> 2823 /// <summary>
2822 /// Tell the client for this scene presence what items it should be wearing now
2823 /// </summary>
2824 public void SendWearables()
2825 {
2826 m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name);
2827
2828 ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2829 }
2830
2831 /// <summary>
2832 /// 2824 ///
2833 /// </summary> 2825 /// </summary>
2834 public void SendAppearanceToAllOtherAgents() 2826 public void SendAppearanceToAllOtherAgents()
2835 { 2827 {
2828// DEBUG ON
2829 m_log.WarnFormat("[SP] Send appearance from {0} to all other agents",m_uuid);
2830// DEBUG OFF
2836 m_perfMonMS = Util.EnvironmentTickCount(); 2831 m_perfMonMS = Util.EnvironmentTickCount();
2837 2832
2838 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2833 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
@@ -2852,96 +2847,13 @@ namespace OpenSim.Region.Framework.Scenes
2852 /// <param name="avatar"></param> 2847 /// <param name="avatar"></param>
2853 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2848 public void SendAppearanceToOtherAgent(ScenePresence avatar)
2854 { 2849 {
2850// DEBUG ON
2851 m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2852// DEBUG OFF
2855 avatar.ControllingClient.SendAppearance( 2853 avatar.ControllingClient.SendAppearance(
2856 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2854 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
2857 } 2855 }
2858 2856
2859 /// <summary>
2860 /// Set appearance data (textureentry and slider settings) received from the client
2861 /// </summary>
2862 /// <param name="texture"></param>
2863 /// <param name="visualParam"></param>
2864 public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
2865 {
2866 lock (m_syncRoot)
2867 {
2868// MT: Commented this because it's no longer needed.
2869// It used to be that the avatar height was calculated from the visual
2870// params, so any call to this method could change the physical actor's
2871// height. Now the height is supplied in the agent circuit data and never
2872// changes here. So, we can leave physics alone.
2873//
2874// if (m_physicsActor != null)
2875// {
2876// if (!IsChildAgent)
2877// {
2878// // This may seem like it's redundant, remove the avatar from the physics scene
2879// // just to add it back again, but it saves us from having to update
2880// // 3 variables 10 times a second.
2881// bool flyingTemp = m_physicsActor.Flying;
2882// RemoveFromPhysicalScene();
2883// //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
2884//
2885// //PhysicsActor = null;
2886//
2887// AddToPhysicalScene(flyingTemp);
2888// }
2889// }
2890
2891 #region Bake Cache Check
2892
2893 if (textureEntry != null)
2894 {
2895 for (int i = 0; i < BAKE_INDICES.Length; i++)
2896 {
2897 int j = BAKE_INDICES[i];
2898 Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
2899
2900 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
2901 {
2902 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
2903 {
2904 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
2905 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
2906 }
2907 }
2908 }
2909
2910 }
2911
2912
2913 #endregion Bake Cache Check
2914
2915 m_appearance.SetAppearance(textureEntry, visualParams);
2916 if (m_appearance.AvatarHeight > 0)
2917 SetHeight(m_appearance.AvatarHeight);
2918
2919 // This is not needed, because only the transient data changed
2920 //AvatarData adata = new AvatarData(m_appearance);
2921 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2922
2923 SendAppearanceToAllOtherAgents();
2924 if (!m_startAnimationSet)
2925 {
2926 Animator.UpdateMovementAnimations();
2927 m_startAnimationSet = true;
2928 }
2929
2930 Vector3 pos = m_pos;
2931 pos.Z += m_appearance.HipOffset;
2932
2933 m_controllingClient.SendAvatarDataImmediate(this);
2934 }
2935 }
2936
2937 public void SetWearable(int wearableId, AvatarWearable wearable)
2938 {
2939 m_appearance.SetWearable(wearableId, wearable);
2940 AvatarData adata = new AvatarData(m_appearance);
2941 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2942 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2943 }
2944
2945 // Because appearance setting is in a module, we actually need 2857 // Because appearance setting is in a module, we actually need
2946 // to give it access to our appearance directly, otherwise we 2858 // to give it access to our appearance directly, otherwise we
2947 // get a synchronization issue. 2859 // get a synchronization issue.
@@ -3335,6 +3247,8 @@ namespace OpenSim.Region.Framework.Scenes
3335 3247
3336 public void CopyTo(AgentData cAgent) 3248 public void CopyTo(AgentData cAgent)
3337 { 3249 {
3250 cAgent.CallbackURI = m_callbackURI;
3251
3338 cAgent.AgentID = UUID; 3252 cAgent.AgentID = UUID;
3339 cAgent.RegionID = Scene.RegionInfo.RegionID; 3253 cAgent.RegionID = Scene.RegionInfo.RegionID;
3340 3254
@@ -3374,6 +3288,9 @@ namespace OpenSim.Region.Framework.Scenes
3374 3288
3375 cAgent.AlwaysRun = m_setAlwaysRun; 3289 cAgent.AlwaysRun = m_setAlwaysRun;
3376 3290
3291 cAgent.Appearance = new AvatarAppearance(m_appearance);
3292
3293/*
3377 try 3294 try
3378 { 3295 {
3379 // We might not pass the Wearables in all cases... 3296 // We might not pass the Wearables in all cases...
@@ -3413,14 +3330,14 @@ namespace OpenSim.Region.Framework.Scenes
3413 { 3330 {
3414 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); 3331 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3415 int i = 0; 3332 int i = 0;
3416 AttachmentData[] attachs = new AttachmentData[attPoints.Count]; 3333 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3417 foreach (int point in attPoints) 3334 foreach (int point in attPoints)
3418 { 3335 {
3419 attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); 3336 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3420 } 3337 }
3421 cAgent.Attachments = attachs; 3338 cAgent.Attachments = attachs;
3422 } 3339 }
3423 3340*/
3424 lock (scriptedcontrols) 3341 lock (scriptedcontrols)
3425 { 3342 {
3426 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 3343 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3447,6 +3364,9 @@ namespace OpenSim.Region.Framework.Scenes
3447 3364
3448 public void CopyFrom(AgentData cAgent) 3365 public void CopyFrom(AgentData cAgent)
3449 { 3366 {
3367// DEBUG ON
3368 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3369// DEBUG OFF
3450 m_originRegionID = cAgent.RegionID; 3370 m_originRegionID = cAgent.RegionID;
3451 3371
3452 m_callbackURI = cAgent.CallbackURI; 3372 m_callbackURI = cAgent.CallbackURI;
@@ -3473,6 +3393,9 @@ namespace OpenSim.Region.Framework.Scenes
3473 m_godLevel = cAgent.GodLevel; 3393 m_godLevel = cAgent.GodLevel;
3474 m_setAlwaysRun = cAgent.AlwaysRun; 3394 m_setAlwaysRun = cAgent.AlwaysRun;
3475 3395
3396 m_appearance = new AvatarAppearance(cAgent.Appearance);
3397
3398/*
3476 uint i = 0; 3399 uint i = 0;
3477 try 3400 try
3478 { 3401 {
@@ -3485,15 +3408,17 @@ namespace OpenSim.Region.Framework.Scenes
3485 UUID assetId = cAgent.Wearables[n + 1]; 3408 UUID assetId = cAgent.Wearables[n + 1];
3486 wears[i++] = new AvatarWearable(itemId, assetId); 3409 wears[i++] = new AvatarWearable(itemId, assetId);
3487 } 3410 }
3488 m_appearance.Wearables = wears; 3411 // m_appearance.Wearables = wears;
3489 Primitive.TextureEntry te; 3412 Primitive.TextureEntry textures = null;
3490 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) 3413 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3491 te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); 3414 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3492 else 3415
3493 te = AvatarAppearance.GetDefaultTexture(); 3416 byte[] visuals = null;
3494 if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) 3417
3495 cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); 3418 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3496 m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); 3419 visuals = (byte[])cAgent.VisualParams.Clone();
3420
3421 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3497 } 3422 }
3498 catch (Exception e) 3423 catch (Exception e)
3499 { 3424 {
@@ -3506,14 +3431,14 @@ namespace OpenSim.Region.Framework.Scenes
3506 if (cAgent.Attachments != null) 3431 if (cAgent.Attachments != null)
3507 { 3432 {
3508 m_appearance.ClearAttachments(); 3433 m_appearance.ClearAttachments();
3509 foreach (AttachmentData att in cAgent.Attachments) 3434 foreach (AvatarAttachment att in cAgent.Attachments)
3510 { 3435 {
3511 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); 3436 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3512 } 3437 }
3513 } 3438 }
3514 } 3439 }
3515 catch { } 3440 catch { }
3516 3441*/
3517 try 3442 try
3518 { 3443 {
3519 lock (scriptedcontrols) 3444 lock (scriptedcontrols)
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 72e5ebd..96c3d8e 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;
@@ -909,7 +909,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
909 Scene scene = (Scene)Scene; 909 Scene scene = (Scene)Scene;
910 AvatarAppearance appearance; 910 AvatarAppearance appearance;
911 scene.GetAvatarAppearance(this, out appearance); 911 scene.GetAvatarAppearance(this, out appearance);
912 OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); 912 OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
913 } 913 }
914 914
915 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) 915 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
index d8f7a84..3f1bd54 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
@@ -32,7 +32,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
32 32
33namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 33namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
34{ 34{
35 class ExtensionHandler : IExtension 35 class ExtensionHandler : IExtension
36 { 36 {
37 private readonly Dictionary<Type, object> m_instances; 37 private readonly Dictionary<Type, object> m_instances;
38 38
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index f47e71c..df60709 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -291,7 +291,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
291 291
292 public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) 292 public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID)
293 { 293 {
294
295 m_log.Info("[MRM] Created MRM Instance"); 294 m_log.Info("[MRM] Created MRM Instance");
296 295
297 IWorld world; 296 IWorld world;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 3cbe391..737ca1b 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/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index b86fb6f..a67404f 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Net; 31using System.Net;
31using System.Reflection; 32using System.Reflection;
32using System.Xml; 33using System.Xml;
@@ -154,6 +155,11 @@ namespace OpenSim.Services.GridService
154 // From the command line link-region 155 // From the command line link-region
155 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 156 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
156 { 157 {
158 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
159 }
160
161 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
162 {
157 reason = string.Empty; 163 reason = string.Empty;
158 string host = "127.0.0.1"; 164 string host = "127.0.0.1";
159 string portstr; 165 string portstr;
@@ -189,7 +195,7 @@ namespace OpenSim.Services.GridService
189 //} 195 //}
190 196
191 GridRegion regInfo; 197 GridRegion regInfo;
192 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason); 198 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
193 if (success) 199 if (success)
194 { 200 {
195 regInfo.RegionName = mapName; 201 regInfo.RegionName = mapName;
@@ -202,7 +208,8 @@ namespace OpenSim.Services.GridService
202 208
203 // From the command line and the 2 above 209 // From the command line and the 2 above
204 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, 210 public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
205 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) 211 string externalRegionName, uint externalPort, string externalHostName, UUID ownerID,
212 out GridRegion regInfo, out string reason)
206 { 213 {
207 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); 214 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc);
208 215
@@ -214,12 +221,22 @@ namespace OpenSim.Services.GridService
214 regInfo.RegionLocX = xloc; 221 regInfo.RegionLocX = xloc;
215 regInfo.RegionLocY = yloc; 222 regInfo.RegionLocY = yloc;
216 regInfo.ScopeID = scopeID; 223 regInfo.ScopeID = scopeID;
224 regInfo.EstateOwner = ownerID;
217 225
218 // Big HACK for Simian Grid !!! 226 // Big HACK for Simian Grid !!!
219 // We need to clean up all URLs used in OpenSim !!! 227 // We need to clean up all URLs used in OpenSim !!!
220 if (externalHostName.Contains("/")) 228 if (externalHostName.Contains("/"))
221 regInfo.ServerURI = externalHostName; 229 regInfo.ServerURI = externalHostName;
222 230
231 // Check for free coordinates
232 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
233 if (region != null)
234 {
235 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", regInfo.RegionLocX, regInfo.RegionLocY, region.RegionName, region.RegionID);
236 reason = "Coordinates are already in use";
237 return false;
238 }
239
223 try 240 try
224 { 241 {
225 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); 242 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
@@ -241,11 +258,11 @@ namespace OpenSim.Services.GridService
241 258
242 if (regionID != UUID.Zero) 259 if (regionID != UUID.Zero)
243 { 260 {
244 GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); 261 region = m_GridService.GetRegionByUUID(scopeID, regionID);
245 if (r != null) 262 if (region != null)
246 { 263 {
247 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 264 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
248 regInfo = r; 265 regInfo = region;
249 return true; 266 return true;
250 } 267 }
251 268
@@ -355,17 +372,8 @@ namespace OpenSim.Services.GridService
355 { 372 {
356 // Check for regions which are not linked regions 373 // Check for regions which are not linked regions
357 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); 374 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
358 // would like to use .Except, but doesn't seem to exist 375 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
359 //IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); 376 if (availableRegions.Count() == 0)
360 List<GridRegion> availableRegions = regions.FindAll(delegate(GridRegion region)
361 {
362 // Ewww! n^2
363 if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good.
364 return true;
365
366 return false;
367 });
368 if (availableRegions.Count == 0)
369 return false; 377 return false;
370 } 378 }
371 379
@@ -529,7 +537,7 @@ namespace OpenSim.Services.GridService
529 xloc = xloc * (int)Constants.RegionSize; 537 xloc = xloc * (int)Constants.RegionSize;
530 yloc = yloc * (int)Constants.RegionSize; 538 yloc = yloc * (int)Constants.RegionSize;
531 string reason = string.Empty; 539 string reason = string.Empty;
532 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) 540 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
533 { 541 {
534 if (cmdparams.Length >= 5) 542 if (cmdparams.Length >= 5)
535 { 543 {
@@ -631,8 +639,7 @@ namespace OpenSim.Services.GridService
631 xloc = xloc * (int)Constants.RegionSize; 639 xloc = xloc * (int)Constants.RegionSize;
632 yloc = yloc * (int)Constants.RegionSize; 640 yloc = yloc * (int)Constants.RegionSize;
633 string reason = string.Empty; 641 string reason = string.Empty;
634 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, 642 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
635 externalHostName, out regInfo, out reason))
636 { 643 {
637 regInfo.RegionName = config.GetString("localName", ""); 644 regInfo.RegionName = config.GetString("localName", "");
638 } 645 }
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 6c66414..1d3c412 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -336,10 +336,10 @@ namespace OpenSim.Services.LLLoginService
336 // 336 //
337 // Get the avatar 337 // Get the avatar
338 // 338 //
339 AvatarData avatar = null; 339 AvatarAppearance avatar = null;
340 if (m_AvatarService != null) 340 if (m_AvatarService != null)
341 { 341 {
342 avatar = m_AvatarService.GetAvatar(account.PrincipalID); 342 avatar = m_AvatarService.GetAppearance(account.PrincipalID);
343 } 343 }
344 344
345 // 345 //
@@ -607,7 +607,7 @@ namespace OpenSim.Services.LLLoginService
607 } 607 }
608 } 608 }
609 609
610 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar, 610 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
611 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, 611 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
612 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest) 612 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest)
613 { 613 {
@@ -703,14 +703,14 @@ namespace OpenSim.Services.LLLoginService
703 } 703 }
704 704
705 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 705 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
706 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 706 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
707 string ipaddress, string viewer, string channel, string mac, string id0) 707 string ipaddress, string viewer, string channel, string mac, string id0)
708 { 708 {
709 AgentCircuitData aCircuit = new AgentCircuitData(); 709 AgentCircuitData aCircuit = new AgentCircuitData();
710 710
711 aCircuit.AgentID = account.PrincipalID; 711 aCircuit.AgentID = account.PrincipalID;
712 if (avatar != null) 712 if (avatar != null)
713 aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); 713 aCircuit.Appearance = new AvatarAppearance(avatar);
714 else 714 else
715 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID); 715 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID);
716 716
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 6324146..4e600b5 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;