aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authoropensim mirror account2010-10-29 13:20:04 -0700
committeropensim mirror account2010-10-29 13:20:04 -0700
commit8d8a795b28c3955df309a4f8cfd3b092489cb15f (patch)
tree672d0d8327d521dfefb44dc5d7d1d49ed8642ee0 /OpenSim/Framework
parentMerge branch 'master' of /var/git/opensim/ (diff)
parentMerge branch 'dev-appearance' (diff)
downloadopensim-SC-8d8a795b28c3955df309a4f8cfd3b092489cb15f.zip
opensim-SC-8d8a795b28c3955df309a4f8cfd3b092489cb15f.tar.gz
opensim-SC-8d8a795b28c3955df309a4f8cfd3b092489cb15f.tar.bz2
opensim-SC-8d8a795b28c3955df309a4f8cfd3b092489cb15f.tar.xz
Merge branch 'master' of /var/git/opensim/
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs61
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs794
-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
8 files changed, 579 insertions, 454 deletions
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 829ad79..55646dd 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -26,163 +26,40 @@
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{
35 // A special dictionary for avatar appearance
36 public struct LayerItem
37 {
38 public UUID ItemID;
39 public UUID AssetID;
40
41 public LayerItem(UUID itemID, UUID assetID)
42 {
43 ItemID = itemID;
44 AssetID = assetID;
45 }
46 }
47
48 public class Layer
49 {
50 protected int m_layerType;
51 protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>();
52 protected List<UUID> m_ids = new List<UUID>();
53
54 public Layer(int type)
55 {
56 m_layerType = type;
57 }
58
59 public int LayerType
60 {
61 get { return m_layerType; }
62 }
63
64 public int Count
65 {
66 get { return m_ids.Count; }
67 }
68
69 public void Add(UUID itemID, UUID assetID)
70 {
71 if (m_items.ContainsKey(itemID))
72 return;
73 if (m_ids.Count >= 5)
74 return;
75
76 m_ids.Add(itemID);
77 m_items[itemID] = assetID;
78 }
79
80 public void Wear(UUID itemID, UUID assetID)
81 {
82 Clear();
83 Add(itemID, assetID);
84 }
85
86 public void Clear()
87 {
88 m_ids.Clear();
89 m_items.Clear();
90 }
91
92 public void RemoveItem(UUID itemID)
93 {
94 if (m_items.ContainsKey(itemID))
95 {
96 m_ids.Remove(itemID);
97 m_items.Remove(itemID);
98 }
99 }
100
101 public void RemoveAsset(UUID assetID)
102 {
103 UUID itemID = UUID.Zero;
104
105 foreach (KeyValuePair<UUID, UUID> kvp in m_items)
106 {
107 if (kvp.Value == assetID)
108 {
109 itemID = kvp.Key;
110 break;
111 }
112 }
113
114 if (itemID != UUID.Zero)
115 {
116 m_ids.Remove(itemID);
117 m_items.Remove(itemID);
118 }
119 }
120
121 public LayerItem this [int idx]
122 {
123 get
124 {
125 if (idx >= m_ids.Count || idx < 0)
126 return new LayerItem(UUID.Zero, UUID.Zero);
127
128 return new LayerItem(m_ids[idx], m_items[m_ids[idx]]);
129 }
130 }
131 }
132
133 public enum AppearanceLayer
134 {
135 BODY = 0,
136 SKIN = 1,
137 HAIR = 2,
138 EYES = 3,
139 SHIRT = 4,
140 PANTS = 5,
141 SHOES = 6,
142 SOCKS = 7,
143 JACKET = 8,
144 GLOVES = 9,
145 UNDERSHIRT = 10,
146 UNDERPANTS = 11,
147 SKIRT = 12,
148 ALPHA = 13,
149 TATTOO = 14,
150
151 MAX_WEARABLES = 15
152 }
153
154 /// <summary> 38 /// <summary>
155 /// Contains the Avatar's Appearance and methods to manipulate the appearance. 39 /// Contains the Avatar's Appearance and methods to manipulate the appearance.
156 /// </summary> 40 /// </summary>
157 public class AvatarAppearance 41 public class AvatarAppearance
158 { 42 {
159 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
160
161 private static UUID BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
162 private static UUID BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
163 private static UUID SKIN_ASSET = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb");
164 private static UUID SKIN_ITEM = new UUID("77c41e39-38f9-f75a-024e-585989bfabc9");
165 private static UUID SHIRT_ASSET = new UUID("00000000-38f9-1111-024e-222222111110");
166 private static UUID SHIRT_ITEM = new UUID("77c41e39-38f9-f75a-0000-585989bf0000");
167 private static UUID PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120");
168 private static UUID PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111");
169 private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66");
170 private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66");
171 private static UUID ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594");
172 private static UUID TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007");
173 private static UUID ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8");
174 private static UUID TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1");
175 44
176 public readonly static int VISUALPARAM_COUNT = 218; 45 public readonly static int VISUALPARAM_COUNT = 218;
177 46
47 public readonly static int TEXTURE_COUNT = 21;
48
178 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;
179 57
180 public virtual UUID Owner 58 public virtual UUID Owner
181 { 59 {
182 get { return m_owner; } 60 get { return m_owner; }
183 set { m_owner = value; } 61 set { m_owner = value; }
184 } 62 }
185 protected int m_serial = 1;
186 63
187 public virtual int Serial 64 public virtual int Serial
188 { 65 {
@@ -190,15 +67,17 @@ namespace OpenSim.Framework
190 set { m_serial = value; } 67 set { m_serial = value; }
191 } 68 }
192 69
193 protected byte[] m_visualparams;
194
195 public virtual byte[] VisualParams 70 public virtual byte[] VisualParams
196 { 71 {
197 get { return m_visualparams; } 72 get { return m_visualparams; }
198 set { m_visualparams = value; } 73 set { m_visualparams = value; }
199 } 74 }
200 75
201 protected AvatarWearable[] m_wearables; 76 public virtual Primitive.TextureEntry Texture
77 {
78 get { return m_texture; }
79 set { m_texture = value; }
80 }
202 81
203 public virtual AvatarWearable[] Wearables 82 public virtual AvatarWearable[] Wearables
204 { 83 {
@@ -206,183 +85,141 @@ namespace OpenSim.Framework
206 set { m_wearables = value; } 85 set { m_wearables = value; }
207 } 86 }
208 87
88 public virtual Dictionary<int, AvatarAttachment> Attachments
89 {
90 get { return m_attachments; }
91 }
92
209 public virtual UUID BodyItem { 93 public virtual UUID BodyItem {
210 get { return m_wearables[(int)AppearanceLayer.BODY].ItemID; } 94 get { return m_wearables[AvatarWearable.BODY].ItemID; }
211 set { m_wearables[(int)AppearanceLayer.BODY].ItemID = value; } 95 set { m_wearables[AvatarWearable.BODY].ItemID = value; }
212 } 96 }
213 97
214 public virtual UUID BodyAsset { 98 public virtual UUID BodyAsset {
215 get { return m_wearables[(int)AppearanceLayer.BODY].AssetID; } 99 get { return m_wearables[AvatarWearable.BODY].AssetID; }
216 set { m_wearables[(int)AppearanceLayer.BODY].AssetID = value; } 100 set { m_wearables[AvatarWearable.BODY].AssetID = value; }
217 } 101 }
218 102
219 public virtual UUID SkinItem { 103 public virtual UUID SkinItem {
220 get { return m_wearables[(int)AppearanceLayer.SKIN].ItemID; } 104 get { return m_wearables[AvatarWearable.SKIN].ItemID; }
221 set { m_wearables[(int)AppearanceLayer.SKIN].ItemID = value; } 105 set { m_wearables[AvatarWearable.SKIN].ItemID = value; }
222 } 106 }
223 107
224 public virtual UUID SkinAsset { 108 public virtual UUID SkinAsset {
225 get { return m_wearables[(int)AppearanceLayer.SKIN].AssetID; } 109 get { return m_wearables[AvatarWearable.SKIN].AssetID; }
226 set { m_wearables[(int)AppearanceLayer.SKIN].AssetID = value; } 110 set { m_wearables[AvatarWearable.SKIN].AssetID = value; }
227 } 111 }
228 112
229 public virtual UUID HairItem { 113 public virtual UUID HairItem {
230 get { return m_wearables[(int)AppearanceLayer.HAIR].ItemID; } 114 get { return m_wearables[AvatarWearable.HAIR].ItemID; }
231 set { m_wearables[(int)AppearanceLayer.HAIR].ItemID = value; } 115 set { m_wearables[AvatarWearable.HAIR].ItemID = value; }
232 } 116 }
233 117
234 public virtual UUID HairAsset { 118 public virtual UUID HairAsset {
235 get { return m_wearables[(int)AppearanceLayer.HAIR].AssetID; } 119 get { return m_wearables[AvatarWearable.HAIR].AssetID; }
236 set { m_wearables[(int)AppearanceLayer.HAIR].AssetID = value; } 120 set { m_wearables[AvatarWearable.HAIR].AssetID = value; }
237 } 121 }
238 122
239 public virtual UUID EyesItem { 123 public virtual UUID EyesItem {
240 get { return m_wearables[(int)AppearanceLayer.EYES].ItemID; } 124 get { return m_wearables[AvatarWearable.EYES].ItemID; }
241 set { m_wearables[(int)AppearanceLayer.EYES].ItemID = value; } 125 set { m_wearables[AvatarWearable.EYES].ItemID = value; }
242 } 126 }
243 127
244 public virtual UUID EyesAsset { 128 public virtual UUID EyesAsset {
245 get { return m_wearables[(int)AppearanceLayer.EYES].AssetID; } 129 get { return m_wearables[AvatarWearable.EYES].AssetID; }
246 set { m_wearables[(int)AppearanceLayer.EYES].AssetID = value; } 130 set { m_wearables[AvatarWearable.EYES].AssetID = value; }
247 } 131 }
248 132
249 public virtual UUID ShirtItem { 133 public virtual UUID ShirtItem {
250 get { return m_wearables[(int)AppearanceLayer.SHIRT].ItemID; } 134 get { return m_wearables[AvatarWearable.SHIRT].ItemID; }
251 set { m_wearables[(int)AppearanceLayer.SHIRT].ItemID = value; } 135 set { m_wearables[AvatarWearable.SHIRT].ItemID = value; }
252 } 136 }
253 137
254 public virtual UUID ShirtAsset { 138 public virtual UUID ShirtAsset {
255 get { return m_wearables[(int)AppearanceLayer.SHIRT].AssetID; } 139 get { return m_wearables[AvatarWearable.SHIRT].AssetID; }
256 set { m_wearables[(int)AppearanceLayer.SHIRT].AssetID = value; } 140 set { m_wearables[AvatarWearable.SHIRT].AssetID = value; }
257 } 141 }
258 142
259 public virtual UUID PantsItem { 143 public virtual UUID PantsItem {
260 get { return m_wearables[(int)AppearanceLayer.PANTS].ItemID; } 144 get { return m_wearables[AvatarWearable.PANTS].ItemID; }
261 set { m_wearables[(int)AppearanceLayer.PANTS].ItemID = value; } 145 set { m_wearables[AvatarWearable.PANTS].ItemID = value; }
262 } 146 }
263 147
264 public virtual UUID PantsAsset { 148 public virtual UUID PantsAsset {
265 get { return m_wearables[(int)AppearanceLayer.PANTS].AssetID; } 149 get { return m_wearables[AvatarWearable.PANTS].AssetID; }
266 set { m_wearables[(int)AppearanceLayer.PANTS].AssetID = value; } 150 set { m_wearables[AvatarWearable.PANTS].AssetID = value; }
267 } 151 }
268 152
269 public virtual UUID ShoesItem { 153 public virtual UUID ShoesItem {
270 get { return m_wearables[(int)AppearanceLayer.SHOES].ItemID; } 154 get { return m_wearables[AvatarWearable.SHOES].ItemID; }
271 set { m_wearables[(int)AppearanceLayer.SHOES].ItemID = value; } 155 set { m_wearables[AvatarWearable.SHOES].ItemID = value; }
272 } 156 }
273 157
274 public virtual UUID ShoesAsset { 158 public virtual UUID ShoesAsset {
275 get { return m_wearables[(int)AppearanceLayer.SHOES].AssetID; } 159 get { return m_wearables[AvatarWearable.SHOES].AssetID; }
276 set { m_wearables[(int)AppearanceLayer.SHOES].AssetID = value; } 160 set { m_wearables[AvatarWearable.SHOES].AssetID = value; }
277 } 161 }
278 162
279 public virtual UUID SocksItem { 163 public virtual UUID SocksItem {
280 get { return m_wearables[(int)AppearanceLayer.SOCKS].ItemID; } 164 get { return m_wearables[AvatarWearable.SOCKS].ItemID; }
281 set { m_wearables[(int)AppearanceLayer.SOCKS].ItemID = value; } 165 set { m_wearables[AvatarWearable.SOCKS].ItemID = value; }
282 } 166 }
283 167
284 public virtual UUID SocksAsset { 168 public virtual UUID SocksAsset {
285 get { return m_wearables[(int)AppearanceLayer.SOCKS].AssetID; } 169 get { return m_wearables[AvatarWearable.SOCKS].AssetID; }
286 set { m_wearables[(int)AppearanceLayer.SOCKS].AssetID = value; } 170 set { m_wearables[AvatarWearable.SOCKS].AssetID = value; }
287 } 171 }
288 172
289 public virtual UUID JacketItem { 173 public virtual UUID JacketItem {
290 get { return m_wearables[(int)AppearanceLayer.JACKET].ItemID; } 174 get { return m_wearables[AvatarWearable.JACKET].ItemID; }
291 set { m_wearables[(int)AppearanceLayer.JACKET].ItemID = value; } 175 set { m_wearables[AvatarWearable.JACKET].ItemID = value; }
292 } 176 }
293 177
294 public virtual UUID JacketAsset { 178 public virtual UUID JacketAsset {
295 get { return m_wearables[(int)AppearanceLayer.JACKET].AssetID; } 179 get { return m_wearables[AvatarWearable.JACKET].AssetID; }
296 set { m_wearables[(int)AppearanceLayer.JACKET].AssetID = value; } 180 set { m_wearables[AvatarWearable.JACKET].AssetID = value; }
297 } 181 }
298 182
299 public virtual UUID GlovesItem { 183 public virtual UUID GlovesItem {
300 get { return m_wearables[(int)AppearanceLayer.GLOVES].ItemID; } 184 get { return m_wearables[AvatarWearable.GLOVES].ItemID; }
301 set { m_wearables[(int)AppearanceLayer.GLOVES].ItemID = value; } 185 set { m_wearables[AvatarWearable.GLOVES].ItemID = value; }
302 } 186 }
303 187
304 public virtual UUID GlovesAsset { 188 public virtual UUID GlovesAsset {
305 get { return m_wearables[(int)AppearanceLayer.GLOVES].AssetID; } 189 get { return m_wearables[AvatarWearable.GLOVES].AssetID; }
306 set { m_wearables[(int)AppearanceLayer.GLOVES].AssetID = value; } 190 set { m_wearables[AvatarWearable.GLOVES].AssetID = value; }
307 } 191 }
308 192
309 public virtual UUID UnderShirtItem { 193 public virtual UUID UnderShirtItem {
310 get { return m_wearables[(int)AppearanceLayer.UNDERSHIRT].ItemID; } 194 get { return m_wearables[AvatarWearable.UNDERSHIRT].ItemID; }
311 set { m_wearables[(int)AppearanceLayer.UNDERSHIRT].ItemID = value; } 195 set { m_wearables[AvatarWearable.UNDERSHIRT].ItemID = value; }
312 } 196 }
313 197
314 public virtual UUID UnderShirtAsset { 198 public virtual UUID UnderShirtAsset {
315 get { return m_wearables[(int)AppearanceLayer.UNDERSHIRT].AssetID; } 199 get { return m_wearables[AvatarWearable.UNDERSHIRT].AssetID; }
316 set { m_wearables[(int)AppearanceLayer.UNDERSHIRT].AssetID = value; } 200 set { m_wearables[AvatarWearable.UNDERSHIRT].AssetID = value; }
317 } 201 }
318 202
319 public virtual UUID UnderPantsItem { 203 public virtual UUID UnderPantsItem {
320 get { return m_wearables[(int)AppearanceLayer.UNDERPANTS].ItemID; } 204 get { return m_wearables[AvatarWearable.UNDERPANTS].ItemID; }
321 set { m_wearables[(int)AppearanceLayer.UNDERPANTS].ItemID = value; } 205 set { m_wearables[AvatarWearable.UNDERPANTS].ItemID = value; }
322 } 206 }
323 207
324 public virtual UUID UnderPantsAsset { 208 public virtual UUID UnderPantsAsset {
325 get { return m_wearables[(int)AppearanceLayer.UNDERPANTS].AssetID; } 209 get { return m_wearables[AvatarWearable.UNDERPANTS].AssetID; }
326 set { m_wearables[(int)AppearanceLayer.UNDERPANTS].AssetID = value; } 210 set { m_wearables[AvatarWearable.UNDERPANTS].AssetID = value; }
327 } 211 }
328 212
329 public virtual UUID SkirtItem { 213 public virtual UUID SkirtItem {
330 get { return m_wearables[(int)AppearanceLayer.SKIRT].ItemID; } 214 get { return m_wearables[AvatarWearable.SKIRT].ItemID; }
331 set { m_wearables[(int)AppearanceLayer.SKIRT].ItemID = value; } 215 set { m_wearables[AvatarWearable.SKIRT].ItemID = value; }
332 } 216 }
333 217
334 public virtual UUID SkirtAsset { 218 public virtual UUID SkirtAsset {
335 get { return m_wearables[(int)AppearanceLayer.SKIRT].AssetID; } 219 get { return m_wearables[AvatarWearable.SKIRT].AssetID; }
336 set { m_wearables[(int)AppearanceLayer.SKIRT].AssetID = value; } 220 set { m_wearables[AvatarWearable.SKIRT].AssetID = value; }
337 }
338
339 public virtual void SetDefaultWearables()
340 {
341 m_wearables[(int)AppearanceLayer.BODY].AssetID = BODY_ASSET;
342 m_wearables[(int)AppearanceLayer.BODY].ItemID = BODY_ITEM;
343 m_wearables[(int)AppearanceLayer.SKIN].AssetID = SKIN_ASSET;
344 m_wearables[(int)AppearanceLayer.SKIN].ItemID = SKIN_ITEM;
345 m_wearables[(int)AppearanceLayer.HAIR].AssetID = HAIR_ASSET;
346 m_wearables[(int)AppearanceLayer.HAIR].ItemID = HAIR_ITEM;
347 m_wearables[(int)AppearanceLayer.SHIRT].AssetID = SHIRT_ASSET;
348 m_wearables[(int)AppearanceLayer.SHIRT].ItemID = SHIRT_ITEM;
349 m_wearables[(int)AppearanceLayer.PANTS].AssetID = PANTS_ASSET;
350 m_wearables[(int)AppearanceLayer.PANTS].ItemID = PANTS_ITEM;
351 m_wearables[(int)AppearanceLayer.ALPHA].AssetID = ALPHA_ASSET;
352 m_wearables[(int)AppearanceLayer.ALPHA].ItemID = ALPHA_ITEM;
353 m_wearables[(int)AppearanceLayer.TATTOO].AssetID = TATTOO_ASSET;
354 m_wearables[(int)AppearanceLayer.TATTOO].ItemID = TATTOO_ITEM;
355 }
356
357 public virtual void ClearWearables()
358 {
359 for (int i = 0; i < m_wearables.Length ; i++)
360 {
361 m_wearables[i].AssetID = UUID.Zero;
362 m_wearables[i].ItemID = UUID.Zero;
363 }
364 }
365
366 public virtual void SetDefaultParams(byte[] vparams)
367 {
368 // TODO: Figure out better values then 'fat scientist 150' or 'alien 0'
369 for (int i = 0; i < VISUALPARAM_COUNT; i++)
370 {
371 vparams[i] = 150;
372 }
373 }
374
375 protected Primitive.TextureEntry m_texture;
376
377 public virtual Primitive.TextureEntry Texture
378 {
379 get { return m_texture; }
380 set { m_texture = value; }
381 } 221 }
382 222
383 protected float m_avatarHeight = 0;
384 protected float m_hipOffset = 0;
385
386 public virtual float AvatarHeight 223 public virtual float AvatarHeight
387 { 224 {
388 get { return m_avatarHeight; } 225 get { return m_avatarHeight; }
@@ -398,41 +235,213 @@ namespace OpenSim.Framework
398 235
399 public AvatarAppearance(UUID owner) 236 public AvatarAppearance(UUID owner)
400 { 237 {
401 m_wearables = new AvatarWearable[(int)AppearanceLayer.MAX_WEARABLES]; 238// DEBUG ON
402 for (int i = 0; i < (int)AppearanceLayer.MAX_WEARABLES; i++) 239 m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner);
403 { 240// DEBUG OFF
404 // this makes them all null
405 m_wearables[i] = new AvatarWearable();
406 }
407 m_serial = 0; 241 m_serial = 0;
408 m_owner = owner; 242 m_owner = owner;
409 //BuildVisualParamEnum() 243
410 m_visualparams = new byte[VISUALPARAM_COUNT];
411 // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist
412 SetDefaultParams(m_visualparams);
413 SetDefaultWearables(); 244 SetDefaultWearables();
414 m_texture = GetDefaultTexture(); 245 SetDefaultTexture();
246 SetDefaultParams();
247 SetHeight();
248
249 m_attachments = new Dictionary<int, AvatarAttachment>();
415 } 250 }
416 251
417 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) 252 public AvatarAppearance(UUID avatarID, OSDMap map)
418 { 253 {
254// DEBUG ON
255 m_log.WarnFormat("[AVATAR APPEARANCE] create appearance for {0} from OSDMap",avatarID);
256// DEBUG OFF
419 m_owner = avatarID; 257 m_owner = avatarID;
420 m_serial = 1; 258 Unpack(map);
421 m_wearables = wearables; 259 SetHeight();
422 m_visualparams = visualParams;
423 m_texture = GetDefaultTexture();
424 } 260 }
425 261
426 /// <summary> 262 public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
427 /// Set up appearance textures and avatar parameters, including a height calculation
428 /// </summary>
429 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
430 { 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;
269
270 if (wearables != null)
271 m_wearables = wearables;
272 else
273 SetDefaultWearables();
274
431 if (textureEntry != null) 275 if (textureEntry != null)
432 m_texture = textureEntry; 276 m_texture = textureEntry;
277 else
278 SetDefaultTexture();
279
433 if (visualParams != null) 280 if (visualParams != null)
434 m_visualparams = visualParams; 281 m_visualparams = visualParams;
282 else
283 SetDefaultParams();
284
285 SetHeight();
286
287 m_attachments = new Dictionary<int, AvatarAttachment>();
288 }
289
290 public AvatarAppearance(AvatarAppearance appearance)
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;
299
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()
338 {
339 m_wearables = AvatarWearable.DefaultWearables;
340 }
341
342 protected virtual void SetDefaultParams()
343 {
344 m_visualparams = new byte[VISUALPARAM_COUNT];
345 for (int i = 0; i < VISUALPARAM_COUNT; i++)
346 {
347 m_visualparams[i] = 150;
348 }
349 }
350
351 protected virtual void SetDefaultTexture()
352 {
353 m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
354 // The initialization of these seems to force a rebake regardless of whether it is needed
355 // m_textures.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012");
356 // m_textures.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
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 }
363
364 /// <summary>
365 /// Set up appearance textures.
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++)
379 {
380 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i];
381 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i];
382
383 if (newface == null)
384 {
385 if (oldface == null) continue;
386 }
387 else
388 {
389 if (oldface != null && oldface.TextureID == newface.TextureID) continue;
390 }
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
398 }
399
400 return changed;
401 }
402
403 /// <summary>
404 /// Set up visual parameters for the avatar and refresh the avatar height
405 /// Returns boolean that indicates whether the new entries actually change the
406 /// existing values.
407 /// </summary>
408 public virtual bool SetVisualParams(byte[] visualParams)
409 {
410 if (visualParams == null)
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++)
418 {
419 if (visualParams[i] != m_visualparams[i])
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 }
428 }
429
430 // Reset the height if the visual parameters actually changed
431 if (changed)
432 SetHeight();
435 433
434 return changed;
435 }
436
437 public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
438 {
439 SetTextureEntries(textureEntry);
440 SetVisualParams(visualParams);
441 }
442
443 public virtual void SetHeight()
444 {
436 m_avatarHeight = 1.23077f // Shortest possible avatar height 445 m_avatarHeight = 1.23077f // Shortest possible avatar height
437 + 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
438 + 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
@@ -440,102 +449,63 @@ namespace OpenSim.Framework
440 + 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
441 + 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
442 + 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
443 m_hipOffset = (((1.23077f // Half of avatar 453 m_hipOffset = (((1.23077f // Half of avatar
444 + 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
445 + 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
446 + 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
447 + 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
448 ) / 2) - m_avatarHeight / 2) * 0.31f - 0.0425f; 458 ) / 2) - m_avatarHeight / 2) * 0.31f - 0.0425f;
449
450
451
452 //System.Console.WriteLine(">>>>>>> [APPEARANCE]: Height {0} Hip offset {1}" + m_avatarHeight + " " + m_hipOffset);
453 //m_log.Debug("------------- Set Appearance Texture ---------------");
454 //Primitive.TextureEntryFace[] faces = Texture.FaceTextures;
455 //foreach (Primitive.TextureEntryFace face in faces)
456 //{
457 // if (face != null)
458 // m_log.Debug(" ++ " + face.TextureID);
459 // else
460 // m_log.Debug(" ++ NULL ");
461 //}
462 //m_log.Debug("----------------------------");
463
464 } 459 }
465 460
466 public virtual void SetWearable(int wearableId, AvatarWearable wearable) 461 public virtual void SetWearable(int wearableId, AvatarWearable wearable)
467 { 462 {
468 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);
469 } 467 }
470 468
471 public static Primitive.TextureEntry GetDefaultTexture()
472 {
473 Primitive.TextureEntry textu = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
474 textu.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012");
475 textu.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
476 textu.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID;
477 textu.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
478 textu.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
479 textu.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010");
480 textu.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011");
481 return textu;
482 }
483 469
484 public static byte[] GetDefaultVisualParams() 470// DEBUG ON
471 public override String ToString()
485 { 472 {
486 byte[] visualParams; 473 String s = "";
487 visualParams = new byte[VISUALPARAM_COUNT]; 474 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
488 for (int i = 0; i < VISUALPARAM_COUNT; i++) 475 if (m_texture.FaceTextures[i] != null)
489 { 476 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID);
490 visualParams[i] = 100; 477
491 } 478 foreach (AvatarWearable awear in m_wearables)
492 return visualParams; 479 s += String.Format("Wearable: item={0}, asset={1}\n",awear.ItemID,awear.AssetID);
480
481 s += "Visual Params: ";
482 for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++)
483 s += String.Format("{0},",m_visualparams[j]);
484 s += "\n";
485
486 return s;
493 } 487 }
488// DEBUG OFF
494 489
495 private Dictionary<int, UUID[]> m_attachments = new Dictionary<int, UUID[]>(); 490 public void SetAttachments(AvatarAttachment[] data)
496
497 public void SetAttachments(AttachmentData[] data)
498 { 491 {
499 foreach (AttachmentData a in data) 492 foreach (AvatarAttachment attach in data)
500 { 493 m_attachments[attach.AttachPoint] = new AvatarAttachment(attach);
501 m_attachments[a.AttachPoint] = new UUID[2];
502 m_attachments[a.AttachPoint][0] = a.ItemID;
503 m_attachments[a.AttachPoint][1] = a.AssetID;
504 }
505 } 494 }
506 495
507 public void SetAttachments(Hashtable data) 496 public void SetAttachment(int attachpoint, UUID item, UUID asset)
508 { 497 {
509 m_attachments.Clear(); 498 if (attachpoint == 0)
510
511 if (data == null)
512 return; 499 return;
513 500
514 foreach (DictionaryEntry e in data) 501 if (item == UUID.Zero)
515 { 502 {
516 int attachpoint = Convert.ToInt32(e.Key);
517
518 if (m_attachments.ContainsKey(attachpoint)) 503 if (m_attachments.ContainsKey(attachpoint))
519 continue; 504 m_attachments.Remove(attachpoint);
520 505 return;
521 UUID item;
522 UUID asset;
523
524 Hashtable uuids = (Hashtable) e.Value;
525 UUID.TryParse(uuids["item"].ToString(), out item);
526 UUID.TryParse(uuids["asset"].ToString(), out asset);
527
528 UUID[] attachment = new UUID[2];
529 attachment[0] = item;
530 attachment[1] = asset;
531
532 m_attachments[attachpoint] = attachment;
533 } 506 }
534 }
535 507
536 public Dictionary<int, UUID[]> GetAttachmentDictionary() 508 m_attachments[attachpoint] = new AvatarAttachment(attachpoint,item,asset);
537 {
538 return m_attachments;
539 } 509 }
540 510
541 public Hashtable GetAttachments() 511 public Hashtable GetAttachments()
@@ -545,16 +515,13 @@ namespace OpenSim.Framework
545 515
546 Hashtable ret = new Hashtable(); 516 Hashtable ret = new Hashtable();
547 517
548 foreach (KeyValuePair<int, UUID[]> kvp in m_attachments) 518 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
549 { 519 {
550 int attachpoint = kvp.Key;
551 UUID[] uuids = kvp.Value;
552
553 Hashtable data = new Hashtable(); 520 Hashtable data = new Hashtable();
554 data["item"] = uuids[0].ToString(); 521 data["item"] = kvp.Value.ItemID.ToString();
555 data["asset"] = uuids[1].ToString(); 522 data["asset"] = kvp.Value.AssetID.ToString();
556 523
557 ret[attachpoint] = data; 524 ret[kvp.Key] = data;
558 } 525 }
559 526
560 return ret; 527 return ret;
@@ -570,7 +537,7 @@ namespace OpenSim.Framework
570 if (!m_attachments.ContainsKey(attachpoint)) 537 if (!m_attachments.ContainsKey(attachpoint))
571 return UUID.Zero; 538 return UUID.Zero;
572 539
573 return m_attachments[attachpoint][0]; 540 return m_attachments[attachpoint].ItemID;
574 } 541 }
575 542
576 public UUID GetAttachedAsset(int attachpoint) 543 public UUID GetAttachedAsset(int attachpoint)
@@ -578,33 +545,14 @@ namespace OpenSim.Framework
578 if (!m_attachments.ContainsKey(attachpoint)) 545 if (!m_attachments.ContainsKey(attachpoint))
579 return UUID.Zero; 546 return UUID.Zero;
580 547
581 return m_attachments[attachpoint][1]; 548 return m_attachments[attachpoint].AssetID;
582 }
583
584 public void SetAttachment(int attachpoint, UUID item, UUID asset)
585 {
586 if (attachpoint == 0)
587 return;
588
589 if (item == UUID.Zero)
590 {
591 if (m_attachments.ContainsKey(attachpoint))
592 m_attachments.Remove(attachpoint);
593 return;
594 }
595
596 if (!m_attachments.ContainsKey(attachpoint))
597 m_attachments[attachpoint] = new UUID[2];
598
599 m_attachments[attachpoint][0] = item;
600 m_attachments[attachpoint][1] = asset;
601 } 549 }
602 550
603 public int GetAttachpoint(UUID itemID) 551 public int GetAttachpoint(UUID itemID)
604 { 552 {
605 foreach (KeyValuePair<int, UUID[]> kvp in m_attachments) 553 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
606 { 554 {
607 if (kvp.Value[0] == itemID) 555 if (kvp.Value.ItemID == itemID)
608 { 556 {
609 return kvp.Key; 557 return kvp.Key;
610 } 558 }
@@ -625,42 +573,126 @@ namespace OpenSim.Framework
625 m_attachments.Clear(); 573 m_attachments.Clear();
626 } 574 }
627 575
628 string GetAttachmentsString() 576 /// <summary>
577 /// Create an OSDMap from the appearance data
578 /// </summary>
579 public OSDMap Pack()
629 { 580 {
630 List<string> strings = new List<string>(); 581 OSDMap data = new OSDMap();
631 582
632 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++)
633 { 596 {
634 strings.Add(e.Key.ToString()); 597 if (m_texture.FaceTextures[i] != null)
635 strings.Add(e.Value[0].ToString()); 598 textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID));
636 strings.Add(e.Value[1].ToString()); 599 else
600 textures.Add(OSD.FromUUID(UUID.Zero));
637 } 601 }
602 data["textures"] = textures;
638 603
639 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;
640 } 615 }
641 616
642 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)
643 { 622 {
644 string[] strings = data.Split(new char[] {','}); 623 if ((data != null) && (data["appearance_serial"] != null))
645 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 }
646 644
647 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 }
648 664
649 while (strings.Length - i > 2) 665 // Visual Parameters
650 { 666 SetDefaultParams();
651 int attachpoint = Int32.Parse(strings[i]); 667 if ((data != null) && (data["visualparams"] != null))
652 UUID item = new UUID(strings[i+1]); 668 {
653 UUID asset = new UUID(strings[i+2]); 669 if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
654 i += 3; 670 m_visualparams = data["visualparams"].AsBinary();
671 }
672 else
673 {
674 m_log.Warn("[AVATARAPPEARANCE] failed to unpack visual parameters");
675 }
655 676
656 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)
657 { 680 {
658 m_attachments[attachpoint] = new UUID[2]; 681 OSDArray attachs = (OSDArray)(data["attachments"]);
659 m_attachments[attachpoint][0] = item; 682 for (int i = 0; i < attachs.Count; i++)
660 m_attachments[attachpoint][1] = asset; 683 {
684 AvatarAttachment attach = new AvatarAttachment((OSDMap)attachs[i]);
685 m_attachments[attach.AttachPoint] = attach;
686 }
661 } 687 }
662 } 688 }
689 catch (Exception e)
690 {
691 m_log.ErrorFormat("[AVATARAPPEARANCE] unpack failed badly: {0}",e.Message);
692 }
663 } 693 }
694
695
664 /// <summary> 696 /// <summary>
665 /// Viewer Params Array Element for AgentSetAppearance 697 /// Viewer Params Array Element for AgentSetAppearance
666 /// Generated from LibOMV's Visual Params list 698 /// Generated from LibOMV's Visual Params list
@@ -1424,4 +1456,4 @@ namespace OpenSim.Framework
1424 SKIRT_SKIRT_BLUE = 217 1456 SKIRT_SKIRT_BLUE = 217
1425 } 1457 }
1426 } 1458 }
1427} 1459} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Framework/AvatarAttachment.cs
index c967f30..c68d78d 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs
+++ b/OpenSim/Framework/AvatarAttachment.cs
@@ -25,14 +25,54 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenMetaverse.StructuredData;
30 31
31namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Framework
32{ 33{
33 public interface IAvatarFactory 34 public class AvatarAttachment
34 { 35 {
35 bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance); 36 public int AttachPoint;
36 void UpdateDatabase(UUID userID, AvatarAppearance avatAppearance); 37 public UUID ItemID;
38 public UUID AssetID;
39
40 public AvatarAttachment(AvatarAttachment attach)
41 {
42 AttachPoint = attach.AttachPoint;
43 ItemID = attach.ItemID;
44 AssetID = attach.AssetID;
45 }
46
47 public AvatarAttachment(int point, UUID item, UUID asset)
48 {
49 AttachPoint = point;
50 ItemID = item;
51 AssetID = asset;
52 }
53
54 public AvatarAttachment(OSDMap args)
55 {
56 Unpack(args);
57 }
58
59 public OSDMap Pack()
60 {
61 OSDMap attachdata = new OSDMap();
62 attachdata["point"] = OSD.FromInteger(AttachPoint);
63 attachdata["item"] = OSD.FromUUID(ItemID);
64 attachdata["asset"] = OSD.FromUUID(AssetID);
65
66 return attachdata;
67 }
68
69
70 public void Unpack(OSDMap args)
71 {
72 if (args["point"] != null)
73 AttachPoint = args["point"].AsInteger();
74 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
75 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
76 }
37 } 77 }
38} 78}
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index 30c5172..87098bf 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -26,14 +26,32 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Runtime.Serialization;
30using System.Security.Permissions;
31using OpenMetaverse; 29using OpenMetaverse;
30using OpenMetaverse.StructuredData;
32 31
33namespace OpenSim.Framework 32namespace OpenSim.Framework
34{ 33{
35 public class AvatarWearable 34 public class AvatarWearable
36 { 35 {
36 // these are guessed at by the list here -
37 // http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
38 // correct them over time for when were are wrong.
39 public static readonly int BODY = 0;
40 public static readonly int SKIN = 1;
41 public static readonly int HAIR = 2;
42 public static readonly int EYES = 3;
43 public static readonly int SHIRT = 4;
44 public static readonly int PANTS = 5;
45 public static readonly int SHOES = 6;
46 public static readonly int SOCKS = 7;
47 public static readonly int JACKET = 8;
48 public static readonly int GLOVES = 9;
49 public static readonly int UNDERSHIRT = 10;
50 public static readonly int UNDERPANTS = 11;
51 public static readonly int SKIRT = 12;
52
53 public static readonly int MAX_WEARABLES = 13;
54
37 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); 55 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
38 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); 56 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
39 57
@@ -62,12 +80,32 @@ namespace OpenSim.Framework
62 ItemID = itemId; 80 ItemID = itemId;
63 } 81 }
64 82
83 public AvatarWearable(OSDMap args)
84 {
85 Unpack(args);
86 }
87
88 public OSDMap Pack()
89 {
90 OSDMap weardata = new OSDMap();
91 weardata["item"] = OSD.FromUUID(ItemID);
92 weardata["asset"] = OSD.FromUUID(AssetID);
93
94 return weardata;
95 }
96
97 public void Unpack(OSDMap args)
98 {
99 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
100 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
101 }
102
65 public static AvatarWearable[] DefaultWearables 103 public static AvatarWearable[] DefaultWearables
66 { 104 {
67 get 105 get
68 { 106 {
69 AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these 107 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these
70 for (int i = 0; i < 13; i++) 108 for (int i = 0; i < MAX_WEARABLES; i++)
71 { 109 {
72 defaultWearables[i] = new AvatarWearable(); 110 defaultWearables[i] = new AvatarWearable();
73 } 111 }
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 72283de..6b64e12 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -976,7 +976,9 @@ namespace OpenSim.Framework.Capabilities
976 976
977 public void BakedTextureUploaded(UUID assetID, byte[] data) 977 public void BakedTextureUploaded(UUID assetID, byte[] data)
978 { 978 {
979 m_log.DebugFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); 979// DEBUG ON
980 m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
981// DEBUG OFF
980 AssetBase asset; 982 AssetBase asset;
981 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); 983 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
982 asset.Data = data; 984 asset.Data = data;
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 0dc5dbc..fdebba3 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -225,46 +225,6 @@ namespace OpenSim.Framework
225 } 225 }
226 } 226 }
227 227
228 public class AttachmentData
229 {
230 public int AttachPoint;
231 public UUID ItemID;
232 public UUID AssetID;
233
234 public AttachmentData(int point, UUID item, UUID asset)
235 {
236 AttachPoint = point;
237 ItemID = item;
238 AssetID = asset;
239 }
240
241 public AttachmentData(OSDMap args)
242 {
243 UnpackUpdateMessage(args);
244 }
245
246 public OSDMap PackUpdateMessage()
247 {
248 OSDMap attachdata = new OSDMap();
249 attachdata["point"] = OSD.FromInteger(AttachPoint);
250 attachdata["item"] = OSD.FromUUID(ItemID);
251 attachdata["asset"] = OSD.FromUUID(AssetID);
252
253 return attachdata;
254 }
255
256
257 public void UnpackUpdateMessage(OSDMap args)
258 {
259 if (args["point"] != null)
260 AttachPoint = args["point"].AsInteger();
261 if (args["item"] != null)
262 ItemID = args["item"].AsUUID();
263 if (args["asset"] != null)
264 AssetID = args["asset"].AsUUID();
265 }
266 }
267
268 public class ControllerData 228 public class ControllerData
269 { 229 {
270 public UUID ItemID; 230 public UUID ItemID;
@@ -348,11 +308,14 @@ namespace OpenSim.Framework
348 public UUID GranterID; 308 public UUID GranterID;
349 309
350 // Appearance 310 // Appearance
311 public AvatarAppearance Appearance;
312
313/*
351 public byte[] AgentTextures; 314 public byte[] AgentTextures;
352 public byte[] VisualParams; 315 public byte[] VisualParams;
353 public UUID[] Wearables; 316 public UUID[] Wearables;
354 public AttachmentData[] Attachments; 317 public AvatarAttachment[] Attachments;
355 318*/
356 // Scripted 319 // Scripted
357 public ControllerData[] Controllers; 320 public ControllerData[] Controllers;
358 321
@@ -413,6 +376,9 @@ namespace OpenSim.Framework
413 args["animations"] = anims; 376 args["animations"] = anims;
414 } 377 }
415 378
379 if (Appearance != null)
380 args["packed_appearance"] = Appearance.Pack();
381
416 //if ((AgentTextures != null) && (AgentTextures.Length > 0)) 382 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
417 //{ 383 //{
418 // OSDArray textures = new OSDArray(AgentTextures.Length); 384 // OSDArray textures = new OSDArray(AgentTextures.Length);
@@ -421,7 +387,7 @@ namespace OpenSim.Framework
421 // args["agent_textures"] = textures; 387 // args["agent_textures"] = textures;
422 //} 388 //}
423 389
424 390/*
425 if ((AgentTextures != null) && (AgentTextures.Length > 0)) 391 if ((AgentTextures != null) && (AgentTextures.Length > 0))
426 args["texture_entry"] = OSD.FromBinary(AgentTextures); 392 args["texture_entry"] = OSD.FromBinary(AgentTextures);
427 393
@@ -441,11 +407,11 @@ namespace OpenSim.Framework
441 if ((Attachments != null) && (Attachments.Length > 0)) 407 if ((Attachments != null) && (Attachments.Length > 0))
442 { 408 {
443 OSDArray attachs = new OSDArray(Attachments.Length); 409 OSDArray attachs = new OSDArray(Attachments.Length);
444 foreach (AttachmentData att in Attachments) 410 foreach (AvatarAttachment att in Attachments)
445 attachs.Add(att.PackUpdateMessage()); 411 attachs.Add(att.Pack());
446 args["attachments"] = attachs; 412 args["attachments"] = attachs;
447 } 413 }
448 414*/
449 if ((Controllers != null) && (Controllers.Length > 0)) 415 if ((Controllers != null) && (Controllers.Length > 0))
450 { 416 {
451 OSDArray controls = new OSDArray(Controllers.Length); 417 OSDArray controls = new OSDArray(Controllers.Length);
@@ -581,6 +547,12 @@ namespace OpenSim.Framework
581 // AgentTextures[i++] = o.AsUUID(); 547 // AgentTextures[i++] = o.AsUUID();
582 //} 548 //}
583 549
550 if (args["packed_appearance"] != null)
551 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
552 else
553 Appearance = new AvatarAppearance(AgentID);
554
555/*
584 if (args["texture_entry"] != null) 556 if (args["texture_entry"] != null)
585 AgentTextures = args["texture_entry"].AsBinary(); 557 AgentTextures = args["texture_entry"].AsBinary();
586 558
@@ -599,17 +571,17 @@ namespace OpenSim.Framework
599 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 571 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
600 { 572 {
601 OSDArray attachs = (OSDArray)(args["attachments"]); 573 OSDArray attachs = (OSDArray)(args["attachments"]);
602 Attachments = new AttachmentData[attachs.Count]; 574 Attachments = new AvatarAttachment[attachs.Count];
603 int i = 0; 575 int i = 0;
604 foreach (OSD o in attachs) 576 foreach (OSD o in attachs)
605 { 577 {
606 if (o.Type == OSDType.Map) 578 if (o.Type == OSDType.Map)
607 { 579 {
608 Attachments[i++] = new AttachmentData((OSDMap)o); 580 Attachments[i++] = new AvatarAttachment((OSDMap)o);
609 } 581 }
610 } 582 }
611 } 583 }
612 584*/
613 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 585 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
614 { 586 {
615 OSDArray controls = (OSDArray)(args["controllers"]); 587 OSDArray controls = (OSDArray)(args["controllers"]);
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 94815cd..027f9c5 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
43 43
44 public delegate void TextureRequest(Object sender, TextureRequestArgs e); 44 public delegate void TextureRequest(Object sender, TextureRequestArgs e);
45 45
46 public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e); 46 public delegate void AvatarNowWearing(IClientAPI sender, AvatarWearingArgs e);
47 47
48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im); 48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
49 49
@@ -65,7 +65,7 @@ namespace OpenSim.Framework
65 65
66 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 66 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
67 67
68 public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams); 68 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams);
69 69
70 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 70 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
71 71
@@ -711,7 +711,7 @@ namespace OpenSim.Framework
711 event TeleportLandmarkRequest OnTeleportLandmarkRequest; 711 event TeleportLandmarkRequest OnTeleportLandmarkRequest;
712 event DeRezObject OnDeRezObject; 712 event DeRezObject OnDeRezObject;
713 event Action<IClientAPI> OnRegionHandShakeReply; 713 event Action<IClientAPI> OnRegionHandShakeReply;
714 event GenericCall2 OnRequestWearables; 714 event GenericCall1 OnRequestWearables;
715 event GenericCall1 OnCompleteMovementToRegion; 715 event GenericCall1 OnCompleteMovementToRegion;
716 event UpdateAgent OnPreAgentUpdate; 716 event UpdateAgent OnPreAgentUpdate;
717 event UpdateAgent OnAgentUpdate; 717 event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 2fda6f3..05d8469 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -65,9 +65,7 @@ namespace OpenSim.Framework.Tests
65 SessionId = UUID.Random(); 65 SessionId = UUID.Random();
66 66
67 AvAppearance = new AvatarAppearance(AgentId); 67 AvAppearance = new AvatarAppearance(AgentId);
68 AvAppearance.SetDefaultWearables();
69 VisualParams = new byte[218]; 68 VisualParams = new byte[218];
70 AvAppearance.SetDefaultParams(VisualParams);
71 69
72 //body 70 //body
73 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155; 71 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155;