From 6e368c4b590529fc64828d06dfb410a646efef85 Mon Sep 17 00:00:00 2001
From: diva
Date: Wed, 1 Apr 2009 19:50:09 +0000
Subject: 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.
---
OpenSim/Framework/Animation.cs | 94 +++++++++++++++
OpenSim/Framework/ChildAgentDataUpdate.cs | 193 +++++++++++-------------------
2 files changed, 162 insertions(+), 125 deletions(-)
create mode 100644 OpenSim/Framework/Animation.cs
(limited to 'OpenSim/Framework')
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 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+
+namespace OpenSim.Framework
+{
+ [Serializable]
+ public class Animation
+ {
+ private UUID animID;
+ public UUID AnimID
+ {
+ get { return animID; }
+ set { animID = value; }
+ }
+
+ private int sequenceNum;
+ public int SequenceNum
+ {
+ get { return sequenceNum; }
+ set { sequenceNum = value; }
+ }
+
+ private UUID objectID;
+ public UUID ObjectID
+ {
+ get { return objectID; }
+ set { objectID = value; }
+ }
+
+ public Animation()
+ {
+ }
+
+ public Animation(UUID animID, int sequenceNum, UUID objectID)
+ {
+ this.animID = animID;
+ this.sequenceNum = sequenceNum;
+ this.objectID = objectID;
+ }
+
+ public Animation(OSDMap args)
+ {
+ UnpackUpdateMessage(args);
+ }
+
+ public OSDMap PackUpdateMessage()
+ {
+ OSDMap anim = new OSDMap();
+ anim["animation"] = OSD.FromUUID(animID);
+ anim["object_id"] = OSD.FromUUID(objectID);
+ anim["seq_num"] = OSD.FromInteger(sequenceNum);
+ return anim;
+ }
+
+ public void UnpackUpdateMessage(OSDMap args)
+ {
+ if (args["animation"] != null)
+ animID = args["animation"].AsUUID();
+ if (args["object_id"] != null)
+ objectID = args["object_id"].AsUUID();
+ if (args["seq_num"] != null)
+ sequenceNum = args["seq_num"].AsInteger();
+ }
+
+ }
+}
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
public ChildAgentDataUpdate()
{
}
-
- //public ChildAgentDataUpdate(AgentData agent)
- //{
- // ActiveGroupID = agent.ActiveGroupID.Guid;
- // AgentID = agent.AgentID.Guid;
- // alwaysrun = agent.AlwaysRun;
- // AVHeight = agent.Size.Z;
- // cameraPosition = new sLLVector3(agent.Center);
- // drawdistance = agent.Far;
- // godlevel = (float)agent.GodLevel;
- // if (agent.Groups.Length > 0)
- // GroupAccess = (uint)agent.Groups[0].GroupPowers;
- // Position = new sLLVector3(agent.Position);
- // regionHandle = agent.RegionHandle;
- // throttles = agent.Throttles;
- // Velocity = new sLLVector3(agent.Velocity);
- //}
-
- //public ChildAgentDataUpdate(AgentPosition agent)
- //{
- // AgentID = agent.AgentID.Guid;
- // AVHeight = agent.Size.Z;
- // cameraPosition = new sLLVector3(agent.Center);
- // drawdistance = agent.Far;
- // Position = new sLLVector3(agent.Position);
- // regionHandle = agent.RegionHandle;
- // throttles = agent.Throttles;
- // Velocity = new sLLVector3(agent.Velocity);
- //}
}
- /*
public interface IAgentData
{
UUID AgentID { get; set; }
- OSDMap PackUpdateMessage();
- void UnpackUpdateMessage(OSDMap map);
+ OSDMap Pack();
+ void Unpack(OSDMap map);
}
///
@@ -123,7 +93,7 @@ namespace OpenSim.Framework
public byte[] Throttles;
- public OSDMap PackUpdateMessage()
+ public OSDMap Pack()
{
OSDMap args = new OSDMap();
args["message_type"] = OSD.FromString("AgentPosition");
@@ -150,7 +120,7 @@ namespace OpenSim.Framework
return args;
}
- public void UnpackUpdateMessage(OSDMap args)
+ public void Unpack(OSDMap args)
{
if (args.ContainsKey("region_handle"))
UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -256,33 +226,6 @@ namespace OpenSim.Framework
}
}
- public class AgentAnimationData
- {
- public UUID Animation;
- public UUID ObjectID;
-
- public AgentAnimationData(OSDMap args)
- {
- UnpackUpdateMessage(args);
- }
-
- public OSDMap PackUpdateMessage()
- {
- OSDMap anim = new OSDMap();
- anim["animation"] = OSD.FromUUID(Animation);
- anim["object_id"] = OSD.FromUUID(ObjectID);
- return anim;
- }
-
- public void UnpackUpdateMessage(OSDMap args)
- {
- if (args["animation"] != null)
- Animation = args["animation"].AsUUID();
- if (args["object_id"] != null)
- ObjectID = args["object_id"].AsUUID();
- }
- }
-
public class AgentData : IAgentData
{
private UUID m_id;
@@ -318,20 +261,21 @@ namespace OpenSim.Framework
public bool AlwaysRun;
public UUID PreyAgent;
public Byte AgentAccess;
- public UUID[] AgentTextures;
public UUID ActiveGroupID;
public AgentGroupData[] Groups;
- public AgentAnimationData[] Anims;
+ public Animation[] Anims;
public UUID GranterID;
- public Dictionary NVPairs;
+ // Appearance
+ public byte[] AgentTextures;
public byte[] VisualParams;
+ public UUID[] Wearables;
public string CallbackURI;
- public OSDMap PackUpdateMessage()
+ public virtual OSDMap Pack()
{
OSDMap args = new OSDMap();
args["message_type"] = OSD.FromString("AgentData");
@@ -367,14 +311,6 @@ namespace OpenSim.Framework
args["prey_agent"] = OSD.FromUUID(PreyAgent);
args["agent_access"] = OSD.FromString(AgentAccess.ToString());
- if ((AgentTextures != null) && (AgentTextures.Length > 0))
- {
- OSDArray textures = new OSDArray(AgentTextures.Length);
- foreach (UUID uuid in AgentTextures)
- textures.Add(OSD.FromUUID(uuid));
- args["agent_textures"] = textures;
- }
-
args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
if ((Groups != null) && (Groups.Length > 0))
@@ -388,15 +324,34 @@ namespace OpenSim.Framework
if ((Anims != null) && (Anims.Length > 0))
{
OSDArray anims = new OSDArray(Anims.Length);
- foreach (AgentAnimationData aanim in Anims)
+ foreach (Animation aanim in Anims)
anims.Add(aanim.PackUpdateMessage());
args["animations"] = anims;
}
+ //if ((AgentTextures != null) && (AgentTextures.Length > 0))
+ //{
+ // OSDArray textures = new OSDArray(AgentTextures.Length);
+ // foreach (UUID uuid in AgentTextures)
+ // textures.Add(OSD.FromUUID(uuid));
+ // args["agent_textures"] = textures;
+ //}
+
+ if ((AgentTextures != null) && (AgentTextures.Length > 0))
+ args["texture_entry"] = OSD.FromBinary(AgentTextures);
+
if ((VisualParams != null) && (VisualParams.Length > 0))
args["visual_params"] = OSD.FromBinary(VisualParams);
- // Last few fields are still missing: granter and NVPais
+ // We might not pass this in all cases...
+ if ((Wearables != null) && (Wearables.Length > 0))
+ {
+ OSDArray wears = new OSDArray(Wearables.Length);
+ foreach (UUID uuid in Wearables)
+ wears.Add(OSD.FromUUID(uuid));
+ args["wearables"] = wears;
+ }
+
if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI);
@@ -409,7 +364,7 @@ namespace OpenSim.Framework
/// Avoiding reflection makes it painful to write, but that's the price!
///
///
- public void UnpackUpdateMessage(OSDMap args)
+ public virtual void Unpack(OSDMap args)
{
if (args.ContainsKey("region_handle"))
UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -483,15 +438,6 @@ namespace OpenSim.Framework
if (args["agent_access"] != null)
Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
- if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
- {
- OSDArray textures = (OSDArray)(args["agent_textures"]);
- AgentTextures = new UUID[textures.Count];
- int i = 0;
- foreach (OSD o in textures)
- AgentTextures[i++] = o.AsUUID();
- }
-
if (args["active_group_id"] != null)
ActiveGroupID = args["active_group_id"].AsUUID();
@@ -512,20 +458,41 @@ namespace OpenSim.Framework
if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
{
OSDArray anims = (OSDArray)(args["animations"]);
- Anims = new AgentAnimationData[anims.Count];
+ Anims = new Animation[anims.Count];
int i = 0;
foreach (OSD o in anims)
{
if (o.Type == OSDType.Map)
{
- Anims[i++] = new AgentAnimationData((OSDMap)o);
+ Anims[i++] = new Animation((OSDMap)o);
}
}
}
+ //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
+ //{
+ // OSDArray textures = (OSDArray)(args["agent_textures"]);
+ // AgentTextures = new UUID[textures.Count];
+ // int i = 0;
+ // foreach (OSD o in textures)
+ // AgentTextures[i++] = o.AsUUID();
+ //}
+
+ if (args["texture_entry"] != null)
+ AgentTextures = args["texture_entry"].AsBinary();
+
if (args["visual_params"] != null)
VisualParams = args["visual_params"].AsBinary();
+ if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
+ {
+ OSDArray wears = (OSDArray)(args["wearables"]);
+ Wearables = new UUID[wears.Count];
+ int i = 0;
+ foreach (OSD o in wears)
+ Wearables[i++] = o.AsUUID();
+ }
+
if (args["callback_uri"] != null)
CallbackURI = args["callback_uri"].AsString();
}
@@ -539,49 +506,25 @@ namespace OpenSim.Framework
//UnpackUpdateMessage(hash);
}
- ///
- /// Soon to be decommissioned
- ///
- ///
- public void CopyFrom(ChildAgentDataUpdate cAgent)
+ public void Dump()
{
- ActiveGroupID = new UUID(cAgent.ActiveGroupID);
-
- AgentID = new UUID(cAgent.AgentID);
-
- AlwaysRun = cAgent.alwaysrun;
-
- // next: ???
- Size = new Vector3();
- Size.Z = cAgent.AVHeight;
-
- Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
-
- Far = cAgent.drawdistance;
-
- // downcasting ???
- GodLevel = (byte)(cAgent.godlevel);
+ System.Console.WriteLine("------------ AgentData ------------");
+ System.Console.WriteLine("UUID: " + AgentID);
+ System.Console.WriteLine("Region: " + RegionHandle);
+ System.Console.WriteLine("Position: " + Position);
+ }
+ }
- Groups = new AgentGroupData[1];
- Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true);
-
- Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z);
-
- RegionHandle = cAgent.regionHandle;
-
- Throttles = cAgent.throttles;
-
- Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
+ public class CompleteAgentData : AgentData
+ {
+ public override OSDMap Pack()
+ {
+ return base.Pack();
}
- public void Dump()
+ public override void Unpack(OSDMap map)
{
- m_log.Info("------------ AgentData ------------");
- m_log.Info("UUID: " + AgentID);
- m_log.Info("Region: " + RegionHandle);
- m_log.Info("Position: " + Position);
+ base.Unpack(map);
}
}
- */
-
}
--
cgit v1.1