From 57518c3624572c13ccd87872d85b0ed5b0f4cdcb Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 29 Dec 2008 21:10:35 +0000 Subject: Merged the InterregionData that Melanie had placed there onto the existing ChildAgentDataUpdate. This commit involves a change in prebuild.xml, because ChildAgentDataUpdate uses OpenMetaverse.StructuredData. Still no use of this data structure, though. Crossing my fingers that this partial commit will compile ok... --- OpenSim/Framework/ChildAgentDataUpdate.cs | 312 ++++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) (limited to 'OpenSim/Framework/ChildAgentDataUpdate.cs') diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 260d6cf..2730c70 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -26,9 +26,18 @@ */ using System; +using OpenMetaverse; +using System.Collections; +using System.Collections.Generic; + +using OSD = OpenMetaverse.StructuredData.OSD; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; +using OSDArray = OpenMetaverse.StructuredData.OSDArray; +using OSDParser = OpenMetaverse.StructuredData.OSDParser; namespace OpenSim.Framework { + // Soon to be dismissed [Serializable] public class ChildAgentDataUpdate { @@ -48,5 +57,308 @@ namespace OpenSim.Framework public ChildAgentDataUpdate() { } + + public ChildAgentDataUpdate(AgentData agent) + { + if (agent.ActiveGroupID != null) + ActiveGroupID = agent.ActiveGroupID.Guid; + if (agent.AgentID != null) + AgentID = agent.AgentID.Guid; + alwaysrun = agent.AlwaysRun; + if (agent.Size != null) + AVHeight = agent.Size.Z; + if (agent.Center != null) + cameraPosition = new sLLVector3(agent.Center); + drawdistance = agent.Far; + godlevel = (float)agent.GodLevel; + if (agent.Groups.Length > 0) + GroupAccess = (uint)agent.Groups[0].GroupPowers; + if (agent.Position != null) + Position = new sLLVector3(agent.Position); + regionHandle = agent.RegionHandle; + throttles = agent.Throttles; + if (agent.Velocity != null) + Velocity = new sLLVector3(agent.Velocity); + } + } + + public class AgentGroupData + { + public UUID GroupID; + public ulong GroupPowers; + public bool AcceptNotices; + + public AgentGroupData(UUID id, ulong powers, bool notices) + { + GroupID = id; + GroupPowers = powers; + AcceptNotices = notices; + } + } + + public class AgentAnimationData + { + public UUID Animation; + public UUID ObjectID; + } + + public class AgentData + { + public ulong RegionHandle; + public uint CircuitCode; + + public UUID AgentID; + public UUID SessionID; + + public Vector3 Position; + public Vector3 Velocity; + public Vector3 Center; + public Vector3 Size; + public Vector3 AtAxis; + public Vector3 LeftAxis; + public Vector3 UpAxis; + public bool ChangedGrid; + + public float Far; + public float Aspect; + //public int[] Throttles; + public byte[] Throttles; + + public uint LocomotionState; + public Quaternion HeadRotation; + public Quaternion BodyRotation; + public uint ControlFlags; + public float EnergyLevel; + public Byte GodLevel; + public bool AlwaysRun; + public UUID PreyAgent; + public Byte AgentAccess; + public UUID[] AgentTextures; + public UUID ActiveGroupID; + + public AgentGroupData[] Groups; + public AgentAnimationData[] Anims; + + public UUID GranterID; + public Dictionary NVPairs; + + byte[] VisualParams; + + + public OSDMap PackUpdateMessage() + { + OSDMap args = new OSDMap(); + args["region_handle"] = OSD.FromString(RegionHandle.ToString()); + args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); + if (AgentID != null) + args["agent_uuid"] = OSD.FromUUID(AgentID); + if (SessionID != null) + args["session_uuid"] = OSD.FromUUID(SessionID); + + if (Position != null) + args["position"] = OSD.FromString(Position.ToString()); + + if (Velocity != null) + args["velocity"] = OSD.FromString(Velocity.ToString()); + if (Center != null) + args["center"] = OSD.FromString(Center.ToString()); + if (Size != null) + args["size"] = OSD.FromString(Size.ToString()); + if (AtAxis != null) + args["at_axis"] = OSD.FromString(AtAxis.ToString()); + if (LeftAxis != null) + args["left_axis"] = OSD.FromString(LeftAxis.ToString()); + if (UpAxis != null) + args["up_axis"] = OSD.FromString(UpAxis.ToString()); + + args["changed_grid"] = OSD.FromBoolean(ChangedGrid); + args["far"] = OSD.FromReal(Far); + args["aspect"] = OSD.FromReal(Aspect); + + if ((Throttles != null) && (Throttles.Length > 0)) + args["throttles"] = OSD.FromBinary(Throttles); + + args["locomotion_state"] = OSD.FromString(LocomotionState.ToString()); + if (HeadRotation != null) + args["head_rotation"] = OSD.FromString(HeadRotation.ToString()); + if (BodyRotation != null) + args["body_rotation"] = OSD.FromString(BodyRotation.ToString()); + args["control_flags"] = OSD.FromString(ControlFlags.ToString()); + + args["energy_level"] = OSD.FromReal(EnergyLevel); + args["god_level"] = OSD.FromString(GodLevel.ToString()); + args["always_run"] = OSD.FromBoolean(AlwaysRun); + if (PreyAgent != null) + 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; + } + + if (ActiveGroupID != null) + args["active_group_id"] = OSD.FromUUID(ActiveGroupID); + + // Last few fields are still missing + + return args; + } + + /// + /// Deserialization of agent data. + /// Avoiding reflection makes it painful to write, but that's the price! + /// + /// + public void UnpackUpdateMessage(OSDMap args) + { + if (args.ContainsKey("region_handle")) + UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); + + if (args["circuit_code"] != null) + UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); + + if (args["agent_uuid"] != null) + AgentID = args["agent_uuid"].AsUUID(); + + if (args["session_uuid"] != null) + SessionID = args["session_uuid"].AsUUID(); + + if (args["position"] != null) + Vector3.TryParse(args["position"].AsString(), out Position); + + if (args["velocity"] != null) + Vector3.TryParse(args["velocity"].AsString(), out Velocity); + + if (args["center"] != null) + Vector3.TryParse(args["center"].AsString(), out Center); + + if (args["size"] != null) + Vector3.TryParse(args["size"].AsString(), out Size); + + if (args["at_axis"] != null) + Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); + + if (args["left_axis"] != null) + Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); + + if (args["up_axis"] != null) + Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); + + if (args["changed_grid"] != null) + ChangedGrid = args["changed_grid"].AsBoolean(); + + if (args["far"] != null) + Far = (float)(args["far"].AsReal()); + + if (args["aspect"] != null) + Aspect = (float)args["aspect"].AsReal(); + + if (args["throttles"] != null) + Throttles = args["throttles"].AsBinary(); + + if (args["locomotion_state"] != null) + UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); + + if (args["head_rotation"] != null) + Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); + + if (args["body_rotation"] != null) + Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); + + if (args["control_flags"] != null) + UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); + + if (args["energy_level"] != null) + EnergyLevel = (float)(args["energy_level"].AsReal()); + + if (args["god_level"] != null) + Byte.TryParse(args["god_level"].AsString(), out GodLevel); + + if (args["always_run"] != null) + AlwaysRun = args["always_run"].AsBoolean(); + + if (args["prey_agent"] != null) + PreyAgent = args["prey_agent"].AsUUID(); + + if (args["agent_access"] != null) + Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); + + if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OpenMetaverse.StructuredData.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(); + } + + public AgentData() + { + } + + public AgentData(Hashtable hash) + { + //UnpackUpdateMessage(hash); + } + + /// + /// Soon to be decommissioned + /// + /// + public void CopyFrom(ChildAgentDataUpdate cAgent) + { + if (cAgent.ActiveGroupID != null) + ActiveGroupID = new UUID(cAgent.ActiveGroupID); + + if (cAgent.AgentID != null) + AgentID = new UUID(cAgent.AgentID); + + AlwaysRun = cAgent.alwaysrun; + + // next: ??? + Size = new Vector3(); + Size.Z = cAgent.AVHeight; + + if (cAgent.cameraPosition != null) + Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z); + + Far = cAgent.drawdistance; + + // downcasting ??? + GodLevel = (byte)(cAgent.godlevel); + + if (cAgent.ActiveGroupID != null) + { + Groups = new AgentGroupData[1]; + Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true); + } + + if (cAgent.Position != null) + Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z); + + RegionHandle = cAgent.regionHandle; + + Throttles = cAgent.throttles; + + if (cAgent.Velocity != null) + Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z); + } + + public void Dump() + { + System.Console.WriteLine("------------ AgentData ------------"); + System.Console.WriteLine("UUID: " + AgentID); + System.Console.WriteLine("Region: " + RegionHandle); + System.Console.WriteLine("Position: " + Position); + } } + } -- cgit v1.1