OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
ChildAgentDataUpdate.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
32 using log4net;
33 using OpenMetaverse;
34 using OpenMetaverse.StructuredData;
35 
36 namespace OpenSim.Framework
37 {
38  // Soon to be dismissed
39  [Serializable]
40  public class ChildAgentDataUpdate
41  {
42  public Guid ActiveGroupID;
43  public Guid AgentID;
44  public bool alwaysrun;
45  public float AVHeight;
46  public Vector3 cameraPosition;
47  public float drawdistance;
48  public float godlevel;
49  public uint GroupAccess;
50  public Vector3 Position;
51  public ulong regionHandle;
52  public byte[] throttles;
53  public Vector3 Velocity;
54 
56  {
57  }
58  }
59 
60  public interface IAgentData
61  {
62  UUID AgentID { get; set; }
63 
64  OSDMap Pack(EntityTransferContext ctx);
65  void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx);
66  }
67 
71  public class AgentPosition : IAgentData
72  {
73  private UUID m_id;
74  public UUID AgentID
75  {
76  get { return m_id; }
77  set { m_id = value; }
78  }
79 
80  public ulong RegionHandle;
81  public uint CircuitCode;
82  public UUID SessionID;
83 
84  public float Far;
85  public Vector3 Position;
86  public Vector3 Velocity;
87  public Vector3 Center;
88  public Vector3 Size;
89  public Vector3 AtAxis;
90  public Vector3 LeftAxis;
91  public Vector3 UpAxis;
92  public bool ChangedGrid;
93 
94  // This probably shouldn't be here
95  public byte[] Throttles;
96 
97  public Dictionary<ulong, string> ChildrenCapSeeds = null;
98 
100  {
101  OSDMap args = new OSDMap();
102  args["message_type"] = OSD.FromString("AgentPosition");
103 
104  args["region_handle"] = OSD.FromString(RegionHandle.ToString());
105  args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
106  args["agent_uuid"] = OSD.FromUUID(AgentID);
107  args["session_uuid"] = OSD.FromUUID(SessionID);
108 
109  args["position"] = OSD.FromString(Position.ToString());
110  args["velocity"] = OSD.FromString(Velocity.ToString());
111  args["center"] = OSD.FromString(Center.ToString());
112  args["size"] = OSD.FromString(Size.ToString());
113  args["at_axis"] = OSD.FromString(AtAxis.ToString());
114  args["left_axis"] = OSD.FromString(LeftAxis.ToString());
115  args["up_axis"] = OSD.FromString(UpAxis.ToString());
116 
117  args["far"] = OSD.FromReal(Far);
118  args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
119 
120  if ((Throttles != null) && (Throttles.Length > 0))
121  args["throttles"] = OSD.FromBinary(Throttles);
122 
123  if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
124  {
125  OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
126  foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
127  {
128  OSDMap pair = new OSDMap();
129  pair["handle"] = OSD.FromString(kvp.Key.ToString());
130  pair["seed"] = OSD.FromString(kvp.Value);
131  childrenSeeds.Add(pair);
132  }
133  args["children_seeds"] = childrenSeeds;
134  }
135 
136  return args;
137  }
138 
139  public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
140  {
141  if (args.ContainsKey("region_handle"))
142  UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
143 
144  if (args["circuit_code"] != null)
145  UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
146 
147  if (args["agent_uuid"] != null)
148  AgentID = args["agent_uuid"].AsUUID();
149 
150  if (args["session_uuid"] != null)
151  SessionID = args["session_uuid"].AsUUID();
152 
153  if (args["position"] != null)
154  Vector3.TryParse(args["position"].AsString(), out Position);
155 
156  if (args["velocity"] != null)
157  Vector3.TryParse(args["velocity"].AsString(), out Velocity);
158 
159  if (args["center"] != null)
160  Vector3.TryParse(args["center"].AsString(), out Center);
161 
162  if (args["size"] != null)
163  Vector3.TryParse(args["size"].AsString(), out Size);
164 
165  if (args["at_axis"] != null)
166  Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
167 
168  if (args["left_axis"] != null)
169  Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis);
170 
171  if (args["up_axis"] != null)
172  Vector3.TryParse(args["up_axis"].AsString(), out UpAxis);
173 
174  if (args["changed_grid"] != null)
175  ChangedGrid = args["changed_grid"].AsBoolean();
176 
177  if (args["far"] != null)
178  Far = (float)(args["far"].AsReal());
179 
180  if (args["throttles"] != null)
181  Throttles = args["throttles"].AsBinary();
182 
183  if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
184  (args["children_seeds"].Type == OSDType.Array))
185  {
186  OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
187  ChildrenCapSeeds = new Dictionary<ulong, string>();
188  foreach (OSD o in childrenSeeds)
189  {
190  if (o.Type == OSDType.Map)
191  {
192  ulong handle = 0;
193  string seed = "";
194  OSDMap pair = (OSDMap)o;
195  if (pair["handle"] != null)
196  if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
197  continue;
198  if (pair["seed"] != null)
199  seed = pair["seed"].AsString();
200  if (!ChildrenCapSeeds.ContainsKey(handle))
201  ChildrenCapSeeds.Add(handle, seed);
202  }
203  }
204  }
205 
206  }
207 
212  public void CopyFrom(ChildAgentDataUpdate cAgent, UUID sid)
213  {
214  AgentID = new UUID(cAgent.AgentID);
215  SessionID = sid;
216 
217  // next: ???
218  Size = new Vector3();
219  Size.Z = cAgent.AVHeight;
220 
221  Center = cAgent.cameraPosition;
222  Far = cAgent.drawdistance;
223  Position = cAgent.Position;
224  RegionHandle = cAgent.regionHandle;
225  Throttles = cAgent.throttles;
226  Velocity = cAgent.Velocity;
227  }
228  }
229 
230  public class AgentGroupData
231  {
232  public UUID GroupID;
233  public ulong GroupPowers;
234  public bool AcceptNotices;
235 
236  public AgentGroupData(UUID id, ulong powers, bool notices)
237  {
238  GroupID = id;
239  GroupPowers = powers;
240  AcceptNotices = notices;
241  }
242 
243  public AgentGroupData(OSDMap args)
244  {
245  UnpackUpdateMessage(args);
246  }
247 
249  {
250  OSDMap groupdata = new OSDMap();
251  groupdata["group_id"] = OSD.FromUUID(GroupID);
252  groupdata["group_powers"] = OSD.FromString(GroupPowers.ToString());
253  groupdata["accept_notices"] = OSD.FromBoolean(AcceptNotices);
254 
255  return groupdata;
256  }
257 
258  public void UnpackUpdateMessage(OSDMap args)
259  {
260  if (args["group_id"] != null)
261  GroupID = args["group_id"].AsUUID();
262  if (args["group_powers"] != null)
263  UInt64.TryParse((string)args["group_powers"].AsString(), out GroupPowers);
264  if (args["accept_notices"] != null)
265  AcceptNotices = args["accept_notices"].AsBoolean();
266  }
267  }
268 
269  public class ControllerData
270  {
271  public UUID ObjectID;
272  public UUID ItemID;
273  public uint IgnoreControls;
274  public uint EventControls;
275 
276  public ControllerData(UUID obj, UUID item, uint ignore, uint ev)
277  {
278  ObjectID = obj;
279  ItemID = item;
280  IgnoreControls = ignore;
281  EventControls = ev;
282  }
283 
284  public ControllerData(OSDMap args)
285  {
286  UnpackUpdateMessage(args);
287  }
288 
290  {
291  OSDMap controldata = new OSDMap();
292  controldata["object"] = OSD.FromUUID(ObjectID);
293  controldata["item"] = OSD.FromUUID(ItemID);
294  controldata["ignore"] = OSD.FromInteger(IgnoreControls);
295  controldata["event"] = OSD.FromInteger(EventControls);
296 
297  return controldata;
298  }
299 
300 
301  public void UnpackUpdateMessage(OSDMap args)
302  {
303  if (args["object"] != null)
304  ObjectID = args["object"].AsUUID();
305  if (args["item"] != null)
306  ItemID = args["item"].AsUUID();
307  if (args["ignore"] != null)
308  IgnoreControls = (uint)args["ignore"].AsInteger();
309  if (args["event"] != null)
310  EventControls = (uint)args["event"].AsInteger();
311  }
312  }
313 
314  public class AgentData : IAgentData
315  {
316  private UUID m_id;
317  public UUID AgentID
318  {
319  get { return m_id; }
320  set { m_id = value; }
321  }
322  public UUID RegionID;
323  public uint CircuitCode;
324  public UUID SessionID;
325 
326  public Vector3 Position;
327  public Vector3 Velocity;
328  public Vector3 Center;
329  public Vector3 Size;
330  public Vector3 AtAxis;
331  public Vector3 LeftAxis;
332  public Vector3 UpAxis;
333 
340 
341  public float Far;
342  public float Aspect;
343  //public int[] Throttles;
344  public byte[] Throttles;
345 
346  public uint LocomotionState;
347  public Quaternion HeadRotation;
348  public Quaternion BodyRotation;
349  public uint ControlFlags;
350  public float EnergyLevel;
351  public Byte GodLevel;
352  public bool AlwaysRun;
353  public UUID PreyAgent;
354  public Byte AgentAccess;
355  public UUID ActiveGroupID;
356 
358  public Dictionary<ulong, string> ChildrenCapSeeds = null;
359  public Animation[] Anims;
360  public Animation DefaultAnim = null;
361  public Animation AnimState = null;
362  public Byte MotionState = 0;
363 
364  public UUID GranterID;
365  public UUID ParentPart;
366  public Vector3 SitOffset;
367 
368  // Appearance
370 
371 // DEBUG ON
372  private static readonly ILog m_log =
373  LogManager.GetLogger(
374  MethodBase.GetCurrentMethod().DeclaringType);
375 // DEBUG OFF
376 
377 /*
378  public byte[] AgentTextures;
379  public byte[] VisualParams;
380  public UUID[] Wearables;
381  public AvatarAttachment[] Attachments;
382 */
383  // Scripted
385 
386  public string CallbackURI;
387 
388  // These two must have the same Count
389  public List<ISceneObject> AttachmentObjects;
390  public List<string> AttachmentObjectStates;
391 
392  public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
393 
394  public virtual OSDMap Pack(EntityTransferContext ctx)
395  {
396  int wearablesCount = -1;
397 
398 // m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
399 
400  OSDMap args = new OSDMap();
401  args["message_type"] = OSD.FromString("AgentData");
402 
403  args["region_id"] = OSD.FromString(RegionID.ToString());
404  args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
405  args["agent_uuid"] = OSD.FromUUID(AgentID);
406  args["session_uuid"] = OSD.FromUUID(SessionID);
407 
408  args["position"] = OSD.FromString(Position.ToString());
409  args["velocity"] = OSD.FromString(Velocity.ToString());
410  args["center"] = OSD.FromString(Center.ToString());
411  args["size"] = OSD.FromString(Size.ToString());
412  args["at_axis"] = OSD.FromString(AtAxis.ToString());
413  args["left_axis"] = OSD.FromString(LeftAxis.ToString());
414  args["up_axis"] = OSD.FromString(UpAxis.ToString());
415 
416  //backwards compatibility
417  args["changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
418  args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
419  args["far"] = OSD.FromReal(Far);
420  args["aspect"] = OSD.FromReal(Aspect);
421 
422  if ((Throttles != null) && (Throttles.Length > 0))
423  args["throttles"] = OSD.FromBinary(Throttles);
424 
425  args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
426  args["head_rotation"] = OSD.FromString(HeadRotation.ToString());
427  args["body_rotation"] = OSD.FromString(BodyRotation.ToString());
428  args["control_flags"] = OSD.FromString(ControlFlags.ToString());
429 
430  args["energy_level"] = OSD.FromReal(EnergyLevel);
431  args["god_level"] = OSD.FromString(GodLevel.ToString());
432  args["always_run"] = OSD.FromBoolean(AlwaysRun);
433  args["prey_agent"] = OSD.FromUUID(PreyAgent);
434  args["agent_access"] = OSD.FromString(AgentAccess.ToString());
435 
436  args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
437 
438  if ((Groups != null) && (Groups.Length > 0))
439  {
440  OSDArray groups = new OSDArray(Groups.Length);
441  foreach (AgentGroupData agd in Groups)
442  groups.Add(agd.PackUpdateMessage());
443  args["groups"] = groups;
444  }
445 
446  if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
447  {
448  OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
449  foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
450  {
451  OSDMap pair = new OSDMap();
452  pair["handle"] = OSD.FromString(kvp.Key.ToString());
453  pair["seed"] = OSD.FromString(kvp.Value);
454  childrenSeeds.Add(pair);
455  }
456  args["children_seeds"] = childrenSeeds;
457  }
458 
459  if ((Anims != null) && (Anims.Length > 0))
460  {
461  OSDArray anims = new OSDArray(Anims.Length);
462  foreach (Animation aanim in Anims)
463  anims.Add(aanim.PackUpdateMessage());
464  args["animations"] = anims;
465  }
466 
467  if (DefaultAnim != null)
468  {
469  args["default_animation"] = DefaultAnim.PackUpdateMessage();
470  }
471 
472  if (AnimState != null)
473  {
474  args["animation_state"] = AnimState.PackUpdateMessage();
475  }
476 
477  if (MovementAnimationOverRides.Count > 0)
478  {
479  OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count);
480  {
481  foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides)
482  {
483  OSDMap ao = new OSDMap(2);
484  ao["state"] = OSD.FromString(kvp.Key);
485  ao["uuid"] = OSD.FromUUID(kvp.Value);
486  AOs.Add(ao);
487  }
488  }
489  args["movementAO"] = AOs;
490  }
491 
492  if (MotionState != 0)
493  {
494  args["motion_state"] = OSD.FromInteger(MotionState);
495  }
496 
497  if (Appearance != null)
498  args["packed_appearance"] = Appearance.Pack(ctx);
499 
500  //if ((AgentTextures != null) && (AgentTextures.Length > 0))
501  //{
502  // OSDArray textures = new OSDArray(AgentTextures.Length);
503  // foreach (UUID uuid in AgentTextures)
504  // textures.Add(OSD.FromUUID(uuid));
505  // args["agent_textures"] = textures;
506  //}
507 
508  // The code to pack textures, visuals, wearables and attachments
509  // should be removed; packed appearance contains the full appearance
510  // This is retained for backward compatibility only
511 
512 /* then lets remove
513  if (Appearance.Texture != null)
514  {
515  byte[] rawtextures = Appearance.Texture.GetBytes();
516  args["texture_entry"] = OSD.FromBinary(rawtextures);
517  }
518 
519  if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
520  args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
521 
522  // We might not pass this in all cases...
523  if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
524  {
525  OSDArray wears = new OSDArray(Appearance.Wearables.Length);
526  foreach (AvatarWearable awear in Appearance.Wearables)
527  wears.Add(awear.Pack());
528 
529  args["wearables"] = wears;
530  }
531 
532  List<AvatarAttachment> attachments = Appearance.GetAttachments();
533  if ((attachments != null) && (attachments.Count > 0))
534  {
535  OSDArray attachs = new OSDArray(attachments.Count);
536  foreach (AvatarAttachment att in attachments)
537  attachs.Add(att.Pack());
538  args["attachments"] = attachs;
539  }
540  // End of code to remove
541 */
542  if ((Controllers != null) && (Controllers.Length > 0))
543  {
544  OSDArray controls = new OSDArray(Controllers.Length);
545  foreach (ControllerData ctl in Controllers)
546  controls.Add(ctl.PackUpdateMessage());
547  args["controllers"] = controls;
548  }
549 
550  if ((CallbackURI != null) && (!CallbackURI.Equals("")))
551  args["callback_uri"] = OSD.FromString(CallbackURI);
552 
553  // Attachment objects for fatpack messages
554  if (AttachmentObjects != null)
555  {
556  int i = 0;
557  OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
558  foreach (ISceneObject so in AttachmentObjects)
559  {
560  OSDMap info = new OSDMap(4);
561  info["sog"] = OSD.FromString(so.ToXml2());
562  info["extra"] = OSD.FromString(so.ExtraToXmlString());
563  info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
564  try
565  {
566  info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
567  }
568  catch (IndexOutOfRangeException)
569  {
570  m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list.");
571  }
572 
573  attObjs.Add(info);
574  }
575  args["attach_objects"] = attObjs;
576  }
577 
578  args["parent_part"] = OSD.FromUUID(ParentPart);
579  args["sit_offset"] = OSD.FromString(SitOffset.ToString());
580 
581  return args;
582  }
583 
589  public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
590  {
591  //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
592 
593  if (args.ContainsKey("region_id"))
594  UUID.TryParse(args["region_id"].AsString(), out RegionID);
595 
596  if (args["circuit_code"] != null)
597  UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
598 
599  if (args["agent_uuid"] != null)
600  AgentID = args["agent_uuid"].AsUUID();
601 
602  if (args["session_uuid"] != null)
603  SessionID = args["session_uuid"].AsUUID();
604 
605  if (args["position"] != null)
606  Vector3.TryParse(args["position"].AsString(), out Position);
607 
608  if (args["velocity"] != null)
609  Vector3.TryParse(args["velocity"].AsString(), out Velocity);
610 
611  if (args["center"] != null)
612  Vector3.TryParse(args["center"].AsString(), out Center);
613 
614  if (args["size"] != null)
615  Vector3.TryParse(args["size"].AsString(), out Size);
616 
617  if (args["at_axis"] != null)
618  Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
619 
620  if (args["left_axis"] != null)
621  Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
622 
623  if (args["up_axis"] != null)
624  Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
625 
626  if (args.ContainsKey("wait_for_root") && args["wait_for_root"] != null)
627  SenderWantsToWaitForRoot = args["wait_for_root"].AsBoolean();
628 
629  if (args["far"] != null)
630  Far = (float)(args["far"].AsReal());
631 
632  if (args["aspect"] != null)
633  Aspect = (float)args["aspect"].AsReal();
634 
635  if (args["throttles"] != null)
636  Throttles = args["throttles"].AsBinary();
637 
638  if (args["locomotion_state"] != null)
639  UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);
640 
641  if (args["head_rotation"] != null)
642  Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);
643 
644  if (args["body_rotation"] != null)
645  Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);
646 
647  if (args["control_flags"] != null)
648  UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);
649 
650  if (args["energy_level"] != null)
651  EnergyLevel = (float)(args["energy_level"].AsReal());
652 
653  if (args["god_level"] != null)
654  Byte.TryParse(args["god_level"].AsString(), out GodLevel);
655 
656  if (args["always_run"] != null)
657  AlwaysRun = args["always_run"].AsBoolean();
658 
659  if (args["prey_agent"] != null)
660  PreyAgent = args["prey_agent"].AsUUID();
661 
662  if (args["agent_access"] != null)
663  Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
664 
665  if (args["active_group_id"] != null)
666  ActiveGroupID = args["active_group_id"].AsUUID();
667 
668  if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
669  {
670  OSDArray groups = (OSDArray)(args["groups"]);
671  Groups = new AgentGroupData[groups.Count];
672  int i = 0;
673  foreach (OSD o in groups)
674  {
675  if (o.Type == OSDType.Map)
676  {
677  Groups[i++] = new AgentGroupData((OSDMap)o);
678  }
679  }
680  }
681 
682  if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
683  (args["children_seeds"].Type == OSDType.Array))
684  {
685  OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
686  ChildrenCapSeeds = new Dictionary<ulong, string>();
687  foreach (OSD o in childrenSeeds)
688  {
689  if (o.Type == OSDType.Map)
690  {
691  ulong handle = 0;
692  string seed = "";
693  OSDMap pair = (OSDMap)o;
694  if (pair["handle"] != null)
695  if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
696  continue;
697  if (pair["seed"] != null)
698  seed = pair["seed"].AsString();
699  if (!ChildrenCapSeeds.ContainsKey(handle))
700  ChildrenCapSeeds.Add(handle, seed);
701  }
702  }
703  }
704 
705  if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
706  {
707  OSDArray anims = (OSDArray)(args["animations"]);
708  Anims = new Animation[anims.Count];
709  int i = 0;
710  foreach (OSD o in anims)
711  {
712  if (o.Type == OSDType.Map)
713  {
714  Anims[i++] = new Animation((OSDMap)o);
715  }
716  }
717  }
718 
719  if (args["default_animation"] != null)
720  {
721  try
722  {
723  DefaultAnim = new Animation((OSDMap)args["default_animation"]);
724  }
725  catch
726  {
727  DefaultAnim = null;
728  }
729  }
730 
731  if (args["animation_state"] != null)
732  {
733  try
734  {
735  AnimState = new Animation((OSDMap)args["animation_state"]);
736  }
737  catch
738  {
739  AnimState = null;
740  }
741  }
742 
743  MovementAnimationOverRides.Clear();
744 
745  if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array)
746  {
747  OSDArray AOs = (OSDArray)(args["movementAO"]);
748  int count = AOs.Count;
749 
750  for (int i = 0; i < count; i++)
751  {
752  OSDMap ao = (OSDMap)AOs[i];
753  if (ao["state"] != null && ao["uuid"] != null)
754  {
755  string state = ao["state"].AsString();
756  UUID id = ao["uuid"].AsUUID();
757  MovementAnimationOverRides[state] = id;
758  }
759  }
760  }
761 
762  if (args.ContainsKey("motion_state"))
763  MotionState = (byte)args["motion_state"].AsInteger();
764 
765  //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
766  //{
767  // OSDArray textures = (OSDArray)(args["agent_textures"]);
768  // AgentTextures = new UUID[textures.Count];
769  // int i = 0;
770  // foreach (OSD o in textures)
771  // AgentTextures[i++] = o.AsUUID();
772  //}
773 
774 
775  // packed_appearence should contain all appearance information
776  if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
777  {
778  m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance");
779  Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
780  }
781  else
782  {
783  // if missing try the old pack method
784  m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method");
785 
786  Appearance = new AvatarAppearance();
787 
788  // The code to unpack textures, visuals, wearables and attachments
789  // should be removed; packed appearance contains the full appearance
790  // This is retained for backward compatibility only
791  if (args["texture_entry"] != null)
792  {
793  byte[] rawtextures = args["texture_entry"].AsBinary();
794  Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
795  Appearance.SetTextureEntries(textures);
796  }
797 
798  if (args["visual_params"] != null)
799  Appearance.SetVisualParams(args["visual_params"].AsBinary());
800 
801  if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
802  {
803  OSDArray wears = (OSDArray)(args["wearables"]);
804 
805  for (int i = 0; i < wears.Count / 2; i++)
806  {
807  AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
808  Appearance.SetWearable(i, awear);
809  }
810  }
811 
812  if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
813  {
814  OSDArray attachs = (OSDArray)(args["attachments"]);
815  foreach (OSD o in attachs)
816  {
817  if (o.Type == OSDType.Map)
818  {
819  // We know all of these must end up as attachments so we
820  // append rather than replace to ensure multiple attachments
821  // per point continues to work
822  // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
823  Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
824  }
825  }
826  }
827  // end of code to remove
828  }
829 /* moved above
830  if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
831  Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
832  else
833  m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
834 */
835  if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
836  {
837  OSDArray controls = (OSDArray)(args["controllers"]);
838  Controllers = new ControllerData[controls.Count];
839  int i = 0;
840  foreach (OSD o in controls)
841  {
842  if (o.Type == OSDType.Map)
843  {
844  Controllers[i++] = new ControllerData((OSDMap)o);
845  }
846  }
847  }
848 
849  if (args["callback_uri"] != null)
850  CallbackURI = args["callback_uri"].AsString();
851 
852  // Attachment objects
853  if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array)
854  {
855  OSDArray attObjs = (OSDArray)(args["attach_objects"]);
856  AttachmentObjects = new List<ISceneObject>();
857  AttachmentObjectStates = new List<string>();
858  foreach (OSD o in attObjs)
859  {
860  if (o.Type == OSDType.Map)
861  {
862  OSDMap info = (OSDMap)o;
863  ISceneObject so = scene.DeserializeObject(info["sog"].AsString());
864  so.ExtraFromXmlString(info["extra"].AsString());
865  so.HasGroupChanged = info["modified"].AsBoolean();
866  AttachmentObjects.Add(so);
867  AttachmentObjectStates.Add(info["state"].AsString());
868  }
869  }
870  }
871 
872  if (args["parent_part"] != null)
873  ParentPart = args["parent_part"].AsUUID();
874  if (args["sit_offset"] != null)
875  Vector3.TryParse(args["sit_offset"].AsString(), out SitOffset);
876  }
877 
878  public AgentData()
879  {
880  }
881 
882  public AgentData(Hashtable hash)
883  {
884  //UnpackUpdateMessage(hash);
885  }
886 
887  public void Dump()
888  {
889  System.Console.WriteLine("------------ AgentData ------------");
890  System.Console.WriteLine("UUID: " + AgentID);
891  System.Console.WriteLine("Region: " + RegionID);
892  System.Console.WriteLine("Position: " + Position);
893  }
894  }
895 
897  {
898  public override OSDMap Pack(EntityTransferContext ctx)
899  {
900  return base.Pack(ctx);
901  }
902 
903  public override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
904  {
905  base.Unpack(map, scene, ctx);
906  }
907  }
908 }
OSDMap Pack(EntityTransferContext ctx)
OpenMetaverse.StructuredData.OSDArray OSDArray
bool SenderWantsToWaitForRoot
Signal on a V2 teleport that Scene.IncomingChildAgentDataUpdate(AgentData ad) should wait for the sce...
Contains the Avatar's Appearance and methods to manipulate the appearance.
Information about an Animation
Definition: Animation.cs:38
OpenMetaverse.StructuredData.OSDMap OSDMap
override OSDMap Pack(EntityTransferContext ctx)
AgentGroupData(UUID id, ulong powers, bool notices)
void CopyFrom(ChildAgentDataUpdate cAgent, UUID sid)
Soon to be decommissioned
List< ISceneObject > AttachmentObjects
override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
Deserialization of agent data. Avoiding reflection makes it painful to write, but that's the price! ...
virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
Deserialization of agent data. Avoiding reflection makes it painful to write, but that's the price! ...
OpenMetaverse.StructuredData.OSD OSD
Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
virtual OSDMap Pack(EntityTransferContext ctx)
OpenSim.Framework.Animation Animation
ControllerData(UUID obj, UUID item, uint ignore, uint ev)
void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)