diff options
author | diva | 2009-04-01 19:50:09 +0000 |
---|---|---|
committer | diva | 2009-04-01 19:50:09 +0000 |
commit | 6e368c4b590529fc64828d06dfb410a646efef85 (patch) | |
tree | 55ffc599b522f1d77823ae5afec18175593cf1d2 /OpenSim/Framework | |
parent | * Upped trunk version number to 0.6.4 as we just tagged 0.6.4-release (diff) | |
download | opensim-SC_OLD-6e368c4b590529fc64828d06dfb410a646efef85.zip opensim-SC_OLD-6e368c4b590529fc64828d06dfb410a646efef85.tar.gz opensim-SC_OLD-6e368c4b590529fc64828d06dfb410a646efef85.tar.bz2 opensim-SC_OLD-6e368c4b590529fc64828d06dfb410a646efef85.tar.xz |
Refactoring, no functional changes. Moved ChildAgentDataUpdate data structures from OpenSim.Region.Framework.Scenes back to OpenSim.Framework, so they can be referenced more broadly. This involved having to move the small Animation data structure to OpenSim.Framework too.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Animation.cs | 94 | ||||
-rw-r--r-- | OpenSim/Framework/ChildAgentDataUpdate.cs | 193 |
2 files changed, 162 insertions, 125 deletions
diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs new file mode 100644 index 0000000..cda8387 --- /dev/null +++ b/OpenSim/Framework/Animation.cs | |||
@@ -0,0 +1,94 @@ | |||
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 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenMetaverse.StructuredData; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | [Serializable] | ||
35 | public class Animation | ||
36 | { | ||
37 | private UUID animID; | ||
38 | public UUID AnimID | ||
39 | { | ||
40 | get { return animID; } | ||
41 | set { animID = value; } | ||
42 | } | ||
43 | |||
44 | private int sequenceNum; | ||
45 | public int SequenceNum | ||
46 | { | ||
47 | get { return sequenceNum; } | ||
48 | set { sequenceNum = value; } | ||
49 | } | ||
50 | |||
51 | private UUID objectID; | ||
52 | public UUID ObjectID | ||
53 | { | ||
54 | get { return objectID; } | ||
55 | set { objectID = value; } | ||
56 | } | ||
57 | |||
58 | public Animation() | ||
59 | { | ||
60 | } | ||
61 | |||
62 | public Animation(UUID animID, int sequenceNum, UUID objectID) | ||
63 | { | ||
64 | this.animID = animID; | ||
65 | this.sequenceNum = sequenceNum; | ||
66 | this.objectID = objectID; | ||
67 | } | ||
68 | |||
69 | public Animation(OSDMap args) | ||
70 | { | ||
71 | UnpackUpdateMessage(args); | ||
72 | } | ||
73 | |||
74 | public OSDMap PackUpdateMessage() | ||
75 | { | ||
76 | OSDMap anim = new OSDMap(); | ||
77 | anim["animation"] = OSD.FromUUID(animID); | ||
78 | anim["object_id"] = OSD.FromUUID(objectID); | ||
79 | anim["seq_num"] = OSD.FromInteger(sequenceNum); | ||
80 | return anim; | ||
81 | } | ||
82 | |||
83 | public void UnpackUpdateMessage(OSDMap args) | ||
84 | { | ||
85 | if (args["animation"] != null) | ||
86 | animID = args["animation"].AsUUID(); | ||
87 | if (args["object_id"] != null) | ||
88 | objectID = args["object_id"].AsUUID(); | ||
89 | if (args["seq_num"] != null) | ||
90 | sequenceNum = args["seq_num"].AsInteger(); | ||
91 | } | ||
92 | |||
93 | } | ||
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 | } |