aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Animation.cs (renamed from OpenSim/Region/Framework/Scenes/Animation.cs)188
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs193
-rw-r--r--OpenSim/Region/Framework/Scenes/AnimationSet.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs513
4 files changed, 163 insertions, 732 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation.cs b/OpenSim/Framework/Animation.cs
index 1e697bd..cda8387 100644
--- a/OpenSim/Region/Framework/Scenes/Animation.cs
+++ b/OpenSim/Framework/Animation.cs
@@ -1,94 +1,94 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenMetaverse.StructuredData; 30using OpenMetaverse.StructuredData;
31 31
32namespace OpenSim.Region.Framework.Scenes 32namespace OpenSim.Framework
33{ 33{
34 [Serializable] 34 [Serializable]
35 public class Animation 35 public class Animation
36 { 36 {
37 private UUID animID; 37 private UUID animID;
38 public UUID AnimID 38 public UUID AnimID
39 { 39 {
40 get { return animID; } 40 get { return animID; }
41 set { animID = value; } 41 set { animID = value; }
42 } 42 }
43 43
44 private int sequenceNum; 44 private int sequenceNum;
45 public int SequenceNum 45 public int SequenceNum
46 { 46 {
47 get { return sequenceNum; } 47 get { return sequenceNum; }
48 set { sequenceNum = value; } 48 set { sequenceNum = value; }
49 } 49 }
50 50
51 private UUID objectID; 51 private UUID objectID;
52 public UUID ObjectID 52 public UUID ObjectID
53 { 53 {
54 get { return objectID; } 54 get { return objectID; }
55 set { objectID = value; } 55 set { objectID = value; }
56 } 56 }
57 57
58 public Animation() 58 public Animation()
59 { 59 {
60 } 60 }
61 61
62 public Animation(UUID animID, int sequenceNum, UUID objectID) 62 public Animation(UUID animID, int sequenceNum, UUID objectID)
63 { 63 {
64 this.animID = animID; 64 this.animID = animID;
65 this.sequenceNum = sequenceNum; 65 this.sequenceNum = sequenceNum;
66 this.objectID = objectID; 66 this.objectID = objectID;
67 } 67 }
68 68
69 public Animation(OSDMap args) 69 public Animation(OSDMap args)
70 { 70 {
71 UnpackUpdateMessage(args); 71 UnpackUpdateMessage(args);
72 } 72 }
73 73
74 public OSDMap PackUpdateMessage() 74 public OSDMap PackUpdateMessage()
75 { 75 {
76 OSDMap anim = new OSDMap(); 76 OSDMap anim = new OSDMap();
77 anim["animation"] = OSD.FromUUID(animID); 77 anim["animation"] = OSD.FromUUID(animID);
78 anim["object_id"] = OSD.FromUUID(objectID); 78 anim["object_id"] = OSD.FromUUID(objectID);
79 anim["seq_num"] = OSD.FromInteger(sequenceNum); 79 anim["seq_num"] = OSD.FromInteger(sequenceNum);
80 return anim; 80 return anim;
81 } 81 }
82 82
83 public void UnpackUpdateMessage(OSDMap args) 83 public void UnpackUpdateMessage(OSDMap args)
84 { 84 {
85 if (args["animation"] != null) 85 if (args["animation"] != null)
86 animID = args["animation"].AsUUID(); 86 animID = args["animation"].AsUUID();
87 if (args["object_id"] != null) 87 if (args["object_id"] != null)
88 objectID = args["object_id"].AsUUID(); 88 objectID = args["object_id"].AsUUID();
89 if (args["seq_num"] != null) 89 if (args["seq_num"] != null)
90 sequenceNum = args["seq_num"].AsInteger(); 90 sequenceNum = args["seq_num"].AsInteger();
91 } 91 }
92 92
93 } 93 }
94} 94}
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 0060fef..6730b95 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -53,44 +53,14 @@ namespace OpenSim.Framework
53 public ChildAgentDataUpdate() 53 public ChildAgentDataUpdate()
54 { 54 {
55 } 55 }
56
57 //public ChildAgentDataUpdate(AgentData agent)
58 //{
59 // ActiveGroupID = agent.ActiveGroupID.Guid;
60 // AgentID = agent.AgentID.Guid;
61 // alwaysrun = agent.AlwaysRun;
62 // AVHeight = agent.Size.Z;
63 // cameraPosition = new sLLVector3(agent.Center);
64 // drawdistance = agent.Far;
65 // godlevel = (float)agent.GodLevel;
66 // if (agent.Groups.Length > 0)
67 // GroupAccess = (uint)agent.Groups[0].GroupPowers;
68 // Position = new sLLVector3(agent.Position);
69 // regionHandle = agent.RegionHandle;
70 // throttles = agent.Throttles;
71 // Velocity = new sLLVector3(agent.Velocity);
72 //}
73
74 //public ChildAgentDataUpdate(AgentPosition agent)
75 //{
76 // AgentID = agent.AgentID.Guid;
77 // AVHeight = agent.Size.Z;
78 // cameraPosition = new sLLVector3(agent.Center);
79 // drawdistance = agent.Far;
80 // Position = new sLLVector3(agent.Position);
81 // regionHandle = agent.RegionHandle;
82 // throttles = agent.Throttles;
83 // Velocity = new sLLVector3(agent.Velocity);
84 //}
85 } 56 }
86 57
87 /*
88 public interface IAgentData 58 public interface IAgentData
89 { 59 {
90 UUID AgentID { get; set; } 60 UUID AgentID { get; set; }
91 61
92 OSDMap PackUpdateMessage(); 62 OSDMap Pack();
93 void UnpackUpdateMessage(OSDMap map); 63 void Unpack(OSDMap map);
94 } 64 }
95 65
96 /// <summary> 66 /// <summary>
@@ -123,7 +93,7 @@ namespace OpenSim.Framework
123 public byte[] Throttles; 93 public byte[] Throttles;
124 94
125 95
126 public OSDMap PackUpdateMessage() 96 public OSDMap Pack()
127 { 97 {
128 OSDMap args = new OSDMap(); 98 OSDMap args = new OSDMap();
129 args["message_type"] = OSD.FromString("AgentPosition"); 99 args["message_type"] = OSD.FromString("AgentPosition");
@@ -150,7 +120,7 @@ namespace OpenSim.Framework
150 return args; 120 return args;
151 } 121 }
152 122
153 public void UnpackUpdateMessage(OSDMap args) 123 public void Unpack(OSDMap args)
154 { 124 {
155 if (args.ContainsKey("region_handle")) 125 if (args.ContainsKey("region_handle"))
156 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); 126 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -256,33 +226,6 @@ namespace OpenSim.Framework
256 } 226 }
257 } 227 }
258 228
259 public class AgentAnimationData
260 {
261 public UUID Animation;
262 public UUID ObjectID;
263
264 public AgentAnimationData(OSDMap args)
265 {
266 UnpackUpdateMessage(args);
267 }
268
269 public OSDMap PackUpdateMessage()
270 {
271 OSDMap anim = new OSDMap();
272 anim["animation"] = OSD.FromUUID(Animation);
273 anim["object_id"] = OSD.FromUUID(ObjectID);
274 return anim;
275 }
276
277 public void UnpackUpdateMessage(OSDMap args)
278 {
279 if (args["animation"] != null)
280 Animation = args["animation"].AsUUID();
281 if (args["object_id"] != null)
282 ObjectID = args["object_id"].AsUUID();
283 }
284 }
285
286 public class AgentData : IAgentData 229 public class AgentData : IAgentData
287 { 230 {
288 private UUID m_id; 231 private UUID m_id;
@@ -318,20 +261,21 @@ namespace OpenSim.Framework
318 public bool AlwaysRun; 261 public bool AlwaysRun;
319 public UUID PreyAgent; 262 public UUID PreyAgent;
320 public Byte AgentAccess; 263 public Byte AgentAccess;
321 public UUID[] AgentTextures;
322 public UUID ActiveGroupID; 264 public UUID ActiveGroupID;
323 265
324 public AgentGroupData[] Groups; 266 public AgentGroupData[] Groups;
325 public AgentAnimationData[] Anims; 267 public Animation[] Anims;
326 268
327 public UUID GranterID; 269 public UUID GranterID;
328 public Dictionary<string, string> NVPairs;
329 270
271 // Appearance
272 public byte[] AgentTextures;
330 public byte[] VisualParams; 273 public byte[] VisualParams;
274 public UUID[] Wearables;
331 275
332 public string CallbackURI; 276 public string CallbackURI;
333 277
334 public OSDMap PackUpdateMessage() 278 public virtual OSDMap Pack()
335 { 279 {
336 OSDMap args = new OSDMap(); 280 OSDMap args = new OSDMap();
337 args["message_type"] = OSD.FromString("AgentData"); 281 args["message_type"] = OSD.FromString("AgentData");
@@ -367,14 +311,6 @@ namespace OpenSim.Framework
367 args["prey_agent"] = OSD.FromUUID(PreyAgent); 311 args["prey_agent"] = OSD.FromUUID(PreyAgent);
368 args["agent_access"] = OSD.FromString(AgentAccess.ToString()); 312 args["agent_access"] = OSD.FromString(AgentAccess.ToString());
369 313
370 if ((AgentTextures != null) && (AgentTextures.Length > 0))
371 {
372 OSDArray textures = new OSDArray(AgentTextures.Length);
373 foreach (UUID uuid in AgentTextures)
374 textures.Add(OSD.FromUUID(uuid));
375 args["agent_textures"] = textures;
376 }
377
378 args["active_group_id"] = OSD.FromUUID(ActiveGroupID); 314 args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
379 315
380 if ((Groups != null) && (Groups.Length > 0)) 316 if ((Groups != null) && (Groups.Length > 0))
@@ -388,15 +324,34 @@ namespace OpenSim.Framework
388 if ((Anims != null) && (Anims.Length > 0)) 324 if ((Anims != null) && (Anims.Length > 0))
389 { 325 {
390 OSDArray anims = new OSDArray(Anims.Length); 326 OSDArray anims = new OSDArray(Anims.Length);
391 foreach (AgentAnimationData aanim in Anims) 327 foreach (Animation aanim in Anims)
392 anims.Add(aanim.PackUpdateMessage()); 328 anims.Add(aanim.PackUpdateMessage());
393 args["animations"] = anims; 329 args["animations"] = anims;
394 } 330 }
395 331
332 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
333 //{
334 // OSDArray textures = new OSDArray(AgentTextures.Length);
335 // foreach (UUID uuid in AgentTextures)
336 // textures.Add(OSD.FromUUID(uuid));
337 // args["agent_textures"] = textures;
338 //}
339
340 if ((AgentTextures != null) && (AgentTextures.Length > 0))
341 args["texture_entry"] = OSD.FromBinary(AgentTextures);
342
396 if ((VisualParams != null) && (VisualParams.Length > 0)) 343 if ((VisualParams != null) && (VisualParams.Length > 0))
397 args["visual_params"] = OSD.FromBinary(VisualParams); 344 args["visual_params"] = OSD.FromBinary(VisualParams);
398 345
399 // Last few fields are still missing: granter and NVPais 346 // We might not pass this in all cases...
347 if ((Wearables != null) && (Wearables.Length > 0))
348 {
349 OSDArray wears = new OSDArray(Wearables.Length);
350 foreach (UUID uuid in Wearables)
351 wears.Add(OSD.FromUUID(uuid));
352 args["wearables"] = wears;
353 }
354
400 355
401 if ((CallbackURI != null) && (!CallbackURI.Equals(""))) 356 if ((CallbackURI != null) && (!CallbackURI.Equals("")))
402 args["callback_uri"] = OSD.FromString(CallbackURI); 357 args["callback_uri"] = OSD.FromString(CallbackURI);
@@ -409,7 +364,7 @@ namespace OpenSim.Framework
409 /// Avoiding reflection makes it painful to write, but that's the price! 364 /// Avoiding reflection makes it painful to write, but that's the price!
410 /// </summary> 365 /// </summary>
411 /// <param name="hash"></param> 366 /// <param name="hash"></param>
412 public void UnpackUpdateMessage(OSDMap args) 367 public virtual void Unpack(OSDMap args)
413 { 368 {
414 if (args.ContainsKey("region_handle")) 369 if (args.ContainsKey("region_handle"))
415 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); 370 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -483,15 +438,6 @@ namespace OpenSim.Framework
483 if (args["agent_access"] != null) 438 if (args["agent_access"] != null)
484 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); 439 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
485 440
486 if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
487 {
488 OSDArray textures = (OSDArray)(args["agent_textures"]);
489 AgentTextures = new UUID[textures.Count];
490 int i = 0;
491 foreach (OSD o in textures)
492 AgentTextures[i++] = o.AsUUID();
493 }
494
495 if (args["active_group_id"] != null) 441 if (args["active_group_id"] != null)
496 ActiveGroupID = args["active_group_id"].AsUUID(); 442 ActiveGroupID = args["active_group_id"].AsUUID();
497 443
@@ -512,20 +458,41 @@ namespace OpenSim.Framework
512 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) 458 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
513 { 459 {
514 OSDArray anims = (OSDArray)(args["animations"]); 460 OSDArray anims = (OSDArray)(args["animations"]);
515 Anims = new AgentAnimationData[anims.Count]; 461 Anims = new Animation[anims.Count];
516 int i = 0; 462 int i = 0;
517 foreach (OSD o in anims) 463 foreach (OSD o in anims)
518 { 464 {
519 if (o.Type == OSDType.Map) 465 if (o.Type == OSDType.Map)
520 { 466 {
521 Anims[i++] = new AgentAnimationData((OSDMap)o); 467 Anims[i++] = new Animation((OSDMap)o);
522 } 468 }
523 } 469 }
524 } 470 }
525 471
472 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
473 //{
474 // OSDArray textures = (OSDArray)(args["agent_textures"]);
475 // AgentTextures = new UUID[textures.Count];
476 // int i = 0;
477 // foreach (OSD o in textures)
478 // AgentTextures[i++] = o.AsUUID();
479 //}
480
481 if (args["texture_entry"] != null)
482 AgentTextures = args["texture_entry"].AsBinary();
483
526 if (args["visual_params"] != null) 484 if (args["visual_params"] != null)
527 VisualParams = args["visual_params"].AsBinary(); 485 VisualParams = args["visual_params"].AsBinary();
528 486
487 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
488 {
489 OSDArray wears = (OSDArray)(args["wearables"]);
490 Wearables = new UUID[wears.Count];
491 int i = 0;
492 foreach (OSD o in wears)
493 Wearables[i++] = o.AsUUID();
494 }
495
529 if (args["callback_uri"] != null) 496 if (args["callback_uri"] != null)
530 CallbackURI = args["callback_uri"].AsString(); 497 CallbackURI = args["callback_uri"].AsString();
531 } 498 }
@@ -539,49 +506,25 @@ namespace OpenSim.Framework
539 //UnpackUpdateMessage(hash); 506 //UnpackUpdateMessage(hash);
540 } 507 }
541 508
542 /// <summary> 509 public void Dump()
543 /// Soon to be decommissioned
544 /// </summary>
545 /// <param name="cAgent"></param>
546 public void CopyFrom(ChildAgentDataUpdate cAgent)
547 { 510 {
548 ActiveGroupID = new UUID(cAgent.ActiveGroupID); 511 System.Console.WriteLine("------------ AgentData ------------");
549 512 System.Console.WriteLine("UUID: " + AgentID);
550 AgentID = new UUID(cAgent.AgentID); 513 System.Console.WriteLine("Region: " + RegionHandle);
551 514 System.Console.WriteLine("Position: " + Position);
552 AlwaysRun = cAgent.alwaysrun; 515 }
553 516 }
554 // next: ???
555 Size = new Vector3();
556 Size.Z = cAgent.AVHeight;
557
558 Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
559
560 Far = cAgent.drawdistance;
561
562 // downcasting ???
563 GodLevel = (byte)(cAgent.godlevel);
564 517
565 Groups = new AgentGroupData[1]; 518 public class CompleteAgentData : AgentData
566 Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true); 519 {
567 520 public override OSDMap Pack()
568 Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z); 521 {
569 522 return base.Pack();
570 RegionHandle = cAgent.regionHandle;
571
572 Throttles = cAgent.throttles;
573
574 Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
575 } 523 }
576 524
577 public void Dump() 525 public override void Unpack(OSDMap map)
578 { 526 {
579 m_log.Info("------------ AgentData ------------"); 527 base.Unpack(map);
580 m_log.Info("UUID: " + AgentID);
581 m_log.Info("Region: " + RegionHandle);
582 m_log.Info("Position: " + Position);
583 } 528 }
584 } 529 }
585 */
586
587} 530}
diff --git a/OpenSim/Region/Framework/Scenes/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/AnimationSet.cs
index 8e25954..b9521d6 100644
--- a/OpenSim/Region/Framework/Scenes/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/AnimationSet.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Framework;
30using OpenMetaverse; 31using OpenMetaverse;
31 32
32namespace OpenSim.Region.Framework.Scenes 33namespace OpenSim.Region.Framework.Scenes
diff --git a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs b/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs
deleted file mode 100644
index 7e6e52a..0000000
--- a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs
+++ /dev/null
@@ -1,513 +0,0 @@
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 OpenSim 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenSim.Framework;
32using OpenMetaverse;
33using OpenMetaverse.StructuredData;
34using log4net;
35using System.Reflection;
36
37namespace OpenSim.Region.Framework.Scenes
38{
39 public interface IAgentData
40 {
41 UUID AgentID { get; set; }
42
43 OSDMap Pack();
44 void Unpack(OSDMap map);
45 }
46
47 /// <summary>
48 /// Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
49 /// </summary>
50 public class AgentPosition : IAgentData
51 {
52 private UUID m_id;
53 public UUID AgentID
54 {
55 get { return m_id; }
56 set { m_id = value; }
57 }
58
59 public ulong RegionHandle;
60 public uint CircuitCode;
61 public UUID SessionID;
62
63 public float Far;
64 public Vector3 Position;
65 public Vector3 Velocity;
66 public Vector3 Center;
67 public Vector3 Size;
68 public Vector3 AtAxis;
69 public Vector3 LeftAxis;
70 public Vector3 UpAxis;
71 public bool ChangedGrid;
72
73 // This probably shouldn't be here
74 public byte[] Throttles;
75
76
77 public OSDMap Pack()
78 {
79 OSDMap args = new OSDMap();
80 args["message_type"] = OSD.FromString("AgentPosition");
81
82 args["region_handle"] = OSD.FromString(RegionHandle.ToString());
83 args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
84 args["agent_uuid"] = OSD.FromUUID(AgentID);
85 args["session_uuid"] = OSD.FromUUID(SessionID);
86
87 args["position"] = OSD.FromString(Position.ToString());
88 args["velocity"] = OSD.FromString(Velocity.ToString());
89 args["center"] = OSD.FromString(Center.ToString());
90 args["size"] = OSD.FromString(Size.ToString());
91 args["at_axis"] = OSD.FromString(AtAxis.ToString());
92 args["left_axis"] = OSD.FromString(LeftAxis.ToString());
93 args["up_axis"] = OSD.FromString(UpAxis.ToString());
94
95 args["far"] = OSD.FromReal(Far);
96 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
97
98 if ((Throttles != null) && (Throttles.Length > 0))
99 args["throttles"] = OSD.FromBinary(Throttles);
100
101 return args;
102 }
103
104 public void Unpack(OSDMap args)
105 {
106 if (args.ContainsKey("region_handle"))
107 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
108
109 if (args["circuit_code"] != null)
110 UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
111
112 if (args["agent_uuid"] != null)
113 AgentID = args["agent_uuid"].AsUUID();
114
115 if (args["session_uuid"] != null)
116 SessionID = args["session_uuid"].AsUUID();
117
118 if (args["position"] != null)
119 Vector3.TryParse(args["position"].AsString(), out Position);
120
121 if (args["velocity"] != null)
122 Vector3.TryParse(args["velocity"].AsString(), out Velocity);
123
124 if (args["center"] != null)
125 Vector3.TryParse(args["center"].AsString(), out Center);
126
127 if (args["size"] != null)
128 Vector3.TryParse(args["size"].AsString(), out Size);
129
130 if (args["at_axis"] != null)
131 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
132
133 if (args["left_axis"] != null)
134 Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
135
136 if (args["up_axis"] != null)
137 Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
138
139 if (args["changed_grid"] != null)
140 ChangedGrid = args["changed_grid"].AsBoolean();
141
142 if (args["far"] != null)
143 Far = (float)(args["far"].AsReal());
144
145 if (args["throttles"] != null)
146 Throttles = args["throttles"].AsBinary();
147 }
148
149 /// <summary>
150 /// Soon to be decommissioned
151 /// </summary>
152 /// <param name="cAgent"></param>
153 public void CopyFrom(ChildAgentDataUpdate cAgent)
154 {
155 AgentID = new UUID(cAgent.AgentID);
156
157 // next: ???
158 Size = new Vector3();
159 Size.Z = cAgent.AVHeight;
160
161 Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
162 Far = cAgent.drawdistance;
163 Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z);
164 RegionHandle = cAgent.regionHandle;
165 Throttles = cAgent.throttles;
166 Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
167 }
168
169 }
170
171 public class AgentGroupData
172 {
173 public UUID GroupID;
174 public ulong GroupPowers;
175 public bool AcceptNotices;
176
177 public AgentGroupData(UUID id, ulong powers, bool notices)
178 {
179 GroupID = id;
180 GroupPowers = powers;
181 AcceptNotices = notices;
182 }
183
184 public AgentGroupData(OSDMap args)
185 {
186 UnpackUpdateMessage(args);
187 }
188
189 public OSDMap PackUpdateMessage()
190 {
191 OSDMap groupdata = new OSDMap();
192 groupdata["group_id"] = OSD.FromUUID(GroupID);
193 groupdata["group_powers"] = OSD.FromString(GroupPowers.ToString());
194 groupdata["accept_notices"] = OSD.FromBoolean(AcceptNotices);
195
196 return groupdata;
197 }
198
199 public void UnpackUpdateMessage(OSDMap args)
200 {
201 if (args["group_id"] != null)
202 GroupID = args["group_id"].AsUUID();
203 if (args["group_powers"] != null)
204 UInt64.TryParse((string)args["group_powers"].AsString(), out GroupPowers);
205 if (args["accept_notices"] != null)
206 AcceptNotices = args["accept_notices"].AsBoolean();
207 }
208 }
209
210 public class AgentData : IAgentData
211 {
212 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
213 private UUID m_id;
214 public UUID AgentID
215 {
216 get { return m_id; }
217 set { m_id = value; }
218 }
219 public ulong RegionHandle;
220 public uint CircuitCode;
221 public UUID SessionID;
222
223 public Vector3 Position;
224 public Vector3 Velocity;
225 public Vector3 Center;
226 public Vector3 Size;
227 public Vector3 AtAxis;
228 public Vector3 LeftAxis;
229 public Vector3 UpAxis;
230 public bool ChangedGrid;
231
232 public float Far;
233 public float Aspect;
234 //public int[] Throttles;
235 public byte[] Throttles;
236
237 public uint LocomotionState;
238 public Quaternion HeadRotation;
239 public Quaternion BodyRotation;
240 public uint ControlFlags;
241 public float EnergyLevel;
242 public Byte GodLevel;
243 public bool AlwaysRun;
244 public UUID PreyAgent;
245 public Byte AgentAccess;
246 public UUID ActiveGroupID;
247
248 public AgentGroupData[] Groups;
249 public Animation[] Anims;
250
251 public UUID GranterID;
252
253 // Appearance
254 public byte[] AgentTextures;
255 public byte[] VisualParams;
256 public UUID[] Wearables;
257
258 public string CallbackURI;
259
260 public virtual OSDMap Pack()
261 {
262 OSDMap args = new OSDMap();
263 args["message_type"] = OSD.FromString("AgentData");
264
265 args["region_handle"] = OSD.FromString(RegionHandle.ToString());
266 args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
267 args["agent_uuid"] = OSD.FromUUID(AgentID);
268 args["session_uuid"] = OSD.FromUUID(SessionID);
269
270 args["position"] = OSD.FromString(Position.ToString());
271 args["velocity"] = OSD.FromString(Velocity.ToString());
272 args["center"] = OSD.FromString(Center.ToString());
273 args["size"] = OSD.FromString(Size.ToString());
274 args["at_axis"] = OSD.FromString(AtAxis.ToString());
275 args["left_axis"] = OSD.FromString(LeftAxis.ToString());
276 args["up_axis"] = OSD.FromString(UpAxis.ToString());
277
278 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
279 args["far"] = OSD.FromReal(Far);
280 args["aspect"] = OSD.FromReal(Aspect);
281
282 if ((Throttles != null) && (Throttles.Length > 0))
283 args["throttles"] = OSD.FromBinary(Throttles);
284
285 args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
286 args["head_rotation"] = OSD.FromString(HeadRotation.ToString());
287 args["body_rotation"] = OSD.FromString(BodyRotation.ToString());
288 args["control_flags"] = OSD.FromString(ControlFlags.ToString());
289
290 args["energy_level"] = OSD.FromReal(EnergyLevel);
291 args["god_level"] = OSD.FromString(GodLevel.ToString());
292 args["always_run"] = OSD.FromBoolean(AlwaysRun);
293 args["prey_agent"] = OSD.FromUUID(PreyAgent);
294 args["agent_access"] = OSD.FromString(AgentAccess.ToString());
295
296 args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
297
298 if ((Groups != null) && (Groups.Length > 0))
299 {
300 OSDArray groups = new OSDArray(Groups.Length);
301 foreach (AgentGroupData agd in Groups)
302 groups.Add(agd.PackUpdateMessage());
303 args["groups"] = groups;
304 }
305
306 if ((Anims != null) && (Anims.Length > 0))
307 {
308 OSDArray anims = new OSDArray(Anims.Length);
309 foreach (Animation aanim in Anims)
310 anims.Add(aanim.PackUpdateMessage());
311 args["animations"] = anims;
312 }
313
314 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
315 //{
316 // OSDArray textures = new OSDArray(AgentTextures.Length);
317 // foreach (UUID uuid in AgentTextures)
318 // textures.Add(OSD.FromUUID(uuid));
319 // args["agent_textures"] = textures;
320 //}
321
322 if ((AgentTextures != null) && (AgentTextures.Length > 0))
323 args["texture_entry"] = OSD.FromBinary(AgentTextures);
324
325 if ((VisualParams != null) && (VisualParams.Length > 0))
326 args["visual_params"] = OSD.FromBinary(VisualParams);
327
328 // We might not pass this in all cases...
329 if ((Wearables != null) && (Wearables.Length > 0))
330 {
331 OSDArray wears = new OSDArray(Wearables.Length);
332 foreach (UUID uuid in Wearables)
333 wears.Add(OSD.FromUUID(uuid));
334 args["wearables"] = wears;
335 }
336
337
338 if ((CallbackURI != null) && (!CallbackURI.Equals("")))
339 args["callback_uri"] = OSD.FromString(CallbackURI);
340
341 return args;
342 }
343
344 /// <summary>
345 /// Deserialization of agent data.
346 /// Avoiding reflection makes it painful to write, but that's the price!
347 /// </summary>
348 /// <param name="hash"></param>
349 public virtual void Unpack(OSDMap args)
350 {
351 if (args.ContainsKey("region_handle"))
352 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
353
354 if (args["circuit_code"] != null)
355 UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
356
357 if (args["agent_uuid"] != null)
358 AgentID = args["agent_uuid"].AsUUID();
359
360 if (args["session_uuid"] != null)
361 SessionID = args["session_uuid"].AsUUID();
362
363 if (args["position"] != null)
364 Vector3.TryParse(args["position"].AsString(), out Position);
365
366 if (args["velocity"] != null)
367 Vector3.TryParse(args["velocity"].AsString(), out Velocity);
368
369 if (args["center"] != null)
370 Vector3.TryParse(args["center"].AsString(), out Center);
371
372 if (args["size"] != null)
373 Vector3.TryParse(args["size"].AsString(), out Size);
374
375 if (args["at_axis"] != null)
376 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
377
378 if (args["left_axis"] != null)
379 Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
380
381 if (args["up_axis"] != null)
382 Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
383
384 if (args["changed_grid"] != null)
385 ChangedGrid = args["changed_grid"].AsBoolean();
386
387 if (args["far"] != null)
388 Far = (float)(args["far"].AsReal());
389
390 if (args["aspect"] != null)
391 Aspect = (float)args["aspect"].AsReal();
392
393 if (args["throttles"] != null)
394 Throttles = args["throttles"].AsBinary();
395
396 if (args["locomotion_state"] != null)
397 UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);
398
399 if (args["head_rotation"] != null)
400 Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);
401
402 if (args["body_rotation"] != null)
403 Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);
404
405 if (args["control_flags"] != null)
406 UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);
407
408 if (args["energy_level"] != null)
409 EnergyLevel = (float)(args["energy_level"].AsReal());
410
411 if (args["god_level"] != null)
412 Byte.TryParse(args["god_level"].AsString(), out GodLevel);
413
414 if (args["always_run"] != null)
415 AlwaysRun = args["always_run"].AsBoolean();
416
417 if (args["prey_agent"] != null)
418 PreyAgent = args["prey_agent"].AsUUID();
419
420 if (args["agent_access"] != null)
421 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
422
423 if (args["active_group_id"] != null)
424 ActiveGroupID = args["active_group_id"].AsUUID();
425
426 if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
427 {
428 OSDArray groups = (OSDArray)(args["groups"]);
429 Groups = new AgentGroupData[groups.Count];
430 int i = 0;
431 foreach (OSD o in groups)
432 {
433 if (o.Type == OSDType.Map)
434 {
435 Groups[i++] = new AgentGroupData((OSDMap)o);
436 }
437 }
438 }
439
440 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
441 {
442 OSDArray anims = (OSDArray)(args["animations"]);
443 Anims = new Animation[anims.Count];
444 int i = 0;
445 foreach (OSD o in anims)
446 {
447 if (o.Type == OSDType.Map)
448 {
449 Anims[i++] = new Animation((OSDMap)o);
450 }
451 }
452 }
453
454 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
455 //{
456 // OSDArray textures = (OSDArray)(args["agent_textures"]);
457 // AgentTextures = new UUID[textures.Count];
458 // int i = 0;
459 // foreach (OSD o in textures)
460 // AgentTextures[i++] = o.AsUUID();
461 //}
462
463 if (args["texture_entry"] != null)
464 AgentTextures = args["texture_entry"].AsBinary();
465
466 if (args["visual_params"] != null)
467 VisualParams = args["visual_params"].AsBinary();
468
469 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
470 {
471 OSDArray wears = (OSDArray)(args["wearables"]);
472 Wearables = new UUID[wears.Count];
473 int i = 0;
474 foreach (OSD o in wears)
475 Wearables[i++] = o.AsUUID();
476 }
477
478 if (args["callback_uri"] != null)
479 CallbackURI = args["callback_uri"].AsString();
480 }
481
482 public AgentData()
483 {
484 }
485
486 public AgentData(Hashtable hash)
487 {
488 //UnpackUpdateMessage(hash);
489 }
490
491 public void Dump()
492 {
493 m_log.Info("------------ AgentData ------------");
494 m_log.Info("UUID: " + AgentID);
495 m_log.Info("Region: " + RegionHandle);
496 m_log.Info("Position: " + Position);
497 }
498 }
499
500 public class CompleteAgentData : AgentData
501 {
502 public override OSDMap Pack()
503 {
504 return base.Pack();
505 }
506
507 public override void Unpack(OSDMap map)
508 {
509 base.Unpack(map);
510 }
511 }
512
513}