aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/ChildAgentDataUpdate.cs
diff options
context:
space:
mode:
authordiva2008-12-29 21:10:35 +0000
committerdiva2008-12-29 21:10:35 +0000
commit57518c3624572c13ccd87872d85b0ed5b0f4cdcb (patch)
treec696608ce7003ca3855c76231758c3ecd1affdfe /OpenSim/Framework/ChildAgentDataUpdate.cs
parentFirst commit in a series of commits for Interregion REST comms. This one simp... (diff)
downloadopensim-SC_OLD-57518c3624572c13ccd87872d85b0ed5b0f4cdcb.zip
opensim-SC_OLD-57518c3624572c13ccd87872d85b0ed5b0f4cdcb.tar.gz
opensim-SC_OLD-57518c3624572c13ccd87872d85b0ed5b0f4cdcb.tar.bz2
opensim-SC_OLD-57518c3624572c13ccd87872d85b0ed5b0f4cdcb.tar.xz
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...
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs312
1 files changed, 312 insertions, 0 deletions
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 @@
26 */ 26 */
27 27
28using System; 28using System;
29using OpenMetaverse;
30using System.Collections;
31using System.Collections.Generic;
32
33using OSD = OpenMetaverse.StructuredData.OSD;
34using OSDMap = OpenMetaverse.StructuredData.OSDMap;
35using OSDArray = OpenMetaverse.StructuredData.OSDArray;
36using OSDParser = OpenMetaverse.StructuredData.OSDParser;
29 37
30namespace OpenSim.Framework 38namespace OpenSim.Framework
31{ 39{
40 // Soon to be dismissed
32 [Serializable] 41 [Serializable]
33 public class ChildAgentDataUpdate 42 public class ChildAgentDataUpdate
34 { 43 {
@@ -48,5 +57,308 @@ namespace OpenSim.Framework
48 public ChildAgentDataUpdate() 57 public ChildAgentDataUpdate()
49 { 58 {
50 } 59 }
60
61 public ChildAgentDataUpdate(AgentData agent)
62 {
63 if (agent.ActiveGroupID != null)
64 ActiveGroupID = agent.ActiveGroupID.Guid;
65 if (agent.AgentID != null)
66 AgentID = agent.AgentID.Guid;
67 alwaysrun = agent.AlwaysRun;
68 if (agent.Size != null)
69 AVHeight = agent.Size.Z;
70 if (agent.Center != null)
71 cameraPosition = new sLLVector3(agent.Center);
72 drawdistance = agent.Far;
73 godlevel = (float)agent.GodLevel;
74 if (agent.Groups.Length > 0)
75 GroupAccess = (uint)agent.Groups[0].GroupPowers;
76 if (agent.Position != null)
77 Position = new sLLVector3(agent.Position);
78 regionHandle = agent.RegionHandle;
79 throttles = agent.Throttles;
80 if (agent.Velocity != null)
81 Velocity = new sLLVector3(agent.Velocity);
82 }
83 }
84
85 public class AgentGroupData
86 {
87 public UUID GroupID;
88 public ulong GroupPowers;
89 public bool AcceptNotices;
90
91 public AgentGroupData(UUID id, ulong powers, bool notices)
92 {
93 GroupID = id;
94 GroupPowers = powers;
95 AcceptNotices = notices;
96 }
97 }
98
99 public class AgentAnimationData
100 {
101 public UUID Animation;
102 public UUID ObjectID;
103 }
104
105 public class AgentData
106 {
107 public ulong RegionHandle;
108 public uint CircuitCode;
109
110 public UUID AgentID;
111 public UUID SessionID;
112
113 public Vector3 Position;
114 public Vector3 Velocity;
115 public Vector3 Center;
116 public Vector3 Size;
117 public Vector3 AtAxis;
118 public Vector3 LeftAxis;
119 public Vector3 UpAxis;
120 public bool ChangedGrid;
121
122 public float Far;
123 public float Aspect;
124 //public int[] Throttles;
125 public byte[] Throttles;
126
127 public uint LocomotionState;
128 public Quaternion HeadRotation;
129 public Quaternion BodyRotation;
130 public uint ControlFlags;
131 public float EnergyLevel;
132 public Byte GodLevel;
133 public bool AlwaysRun;
134 public UUID PreyAgent;
135 public Byte AgentAccess;
136 public UUID[] AgentTextures;
137 public UUID ActiveGroupID;
138
139 public AgentGroupData[] Groups;
140 public AgentAnimationData[] Anims;
141
142 public UUID GranterID;
143 public Dictionary<string, string> NVPairs;
144
145 byte[] VisualParams;
146
147
148 public OSDMap PackUpdateMessage()
149 {
150 OSDMap args = new OSDMap();
151 args["region_handle"] = OSD.FromString(RegionHandle.ToString());
152 args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
153 if (AgentID != null)
154 args["agent_uuid"] = OSD.FromUUID(AgentID);
155 if (SessionID != null)
156 args["session_uuid"] = OSD.FromUUID(SessionID);
157
158 if (Position != null)
159 args["position"] = OSD.FromString(Position.ToString());
160
161 if (Velocity != null)
162 args["velocity"] = OSD.FromString(Velocity.ToString());
163 if (Center != null)
164 args["center"] = OSD.FromString(Center.ToString());
165 if (Size != null)
166 args["size"] = OSD.FromString(Size.ToString());
167 if (AtAxis != null)
168 args["at_axis"] = OSD.FromString(AtAxis.ToString());
169 if (LeftAxis != null)
170 args["left_axis"] = OSD.FromString(LeftAxis.ToString());
171 if (UpAxis != null)
172 args["up_axis"] = OSD.FromString(UpAxis.ToString());
173
174 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
175 args["far"] = OSD.FromReal(Far);
176 args["aspect"] = OSD.FromReal(Aspect);
177
178 if ((Throttles != null) && (Throttles.Length > 0))
179 args["throttles"] = OSD.FromBinary(Throttles);
180
181 args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
182 if (HeadRotation != null)
183 args["head_rotation"] = OSD.FromString(HeadRotation.ToString());
184 if (BodyRotation != null)
185 args["body_rotation"] = OSD.FromString(BodyRotation.ToString());
186 args["control_flags"] = OSD.FromString(ControlFlags.ToString());
187
188 args["energy_level"] = OSD.FromReal(EnergyLevel);
189 args["god_level"] = OSD.FromString(GodLevel.ToString());
190 args["always_run"] = OSD.FromBoolean(AlwaysRun);
191 if (PreyAgent != null)
192 args["prey_agent"] = OSD.FromUUID(PreyAgent);
193 args["agent_access"] = OSD.FromString(AgentAccess.ToString());
194
195 if ((AgentTextures != null) && (AgentTextures.Length > 0))
196 {
197 OSDArray textures = new OSDArray(AgentTextures.Length);
198 foreach (UUID uuid in AgentTextures)
199 textures.Add(OSD.FromUUID(uuid));
200 args["agent_textures"] = textures;
201 }
202
203 if (ActiveGroupID != null)
204 args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
205
206 // Last few fields are still missing
207
208 return args;
209 }
210
211 /// <summary>
212 /// Deserialization of agent data.
213 /// Avoiding reflection makes it painful to write, but that's the price!
214 /// </summary>
215 /// <param name="hash"></param>
216 public void UnpackUpdateMessage(OSDMap args)
217 {
218 if (args.ContainsKey("region_handle"))
219 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
220
221 if (args["circuit_code"] != null)
222 UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
223
224 if (args["agent_uuid"] != null)
225 AgentID = args["agent_uuid"].AsUUID();
226
227 if (args["session_uuid"] != null)
228 SessionID = args["session_uuid"].AsUUID();
229
230 if (args["position"] != null)
231 Vector3.TryParse(args["position"].AsString(), out Position);
232
233 if (args["velocity"] != null)
234 Vector3.TryParse(args["velocity"].AsString(), out Velocity);
235
236 if (args["center"] != null)
237 Vector3.TryParse(args["center"].AsString(), out Center);
238
239 if (args["size"] != null)
240 Vector3.TryParse(args["size"].AsString(), out Size);
241
242 if (args["at_axis"] != null)
243 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
244
245 if (args["left_axis"] != null)
246 Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
247
248 if (args["up_axis"] != null)
249 Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
250
251 if (args["changed_grid"] != null)
252 ChangedGrid = args["changed_grid"].AsBoolean();
253
254 if (args["far"] != null)
255 Far = (float)(args["far"].AsReal());
256
257 if (args["aspect"] != null)
258 Aspect = (float)args["aspect"].AsReal();
259
260 if (args["throttles"] != null)
261 Throttles = args["throttles"].AsBinary();
262
263 if (args["locomotion_state"] != null)
264 UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);
265
266 if (args["head_rotation"] != null)
267 Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);
268
269 if (args["body_rotation"] != null)
270 Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);
271
272 if (args["control_flags"] != null)
273 UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);
274
275 if (args["energy_level"] != null)
276 EnergyLevel = (float)(args["energy_level"].AsReal());
277
278 if (args["god_level"] != null)
279 Byte.TryParse(args["god_level"].AsString(), out GodLevel);
280
281 if (args["always_run"] != null)
282 AlwaysRun = args["always_run"].AsBoolean();
283
284 if (args["prey_agent"] != null)
285 PreyAgent = args["prey_agent"].AsUUID();
286
287 if (args["agent_access"] != null)
288 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
289
290 if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OpenMetaverse.StructuredData.OSDType.Array)
291 {
292 OSDArray textures = (OSDArray)(args["agent_textures"]);
293 AgentTextures = new UUID[textures.Count];
294 int i = 0;
295 foreach (OSD o in textures)
296 AgentTextures[i++] = o.AsUUID();
297 }
298
299 if (args["active_group_id"] != null)
300 ActiveGroupID = args["active_group_id"].AsUUID();
301 }
302
303 public AgentData()
304 {
305 }
306
307 public AgentData(Hashtable hash)
308 {
309 //UnpackUpdateMessage(hash);
310 }
311
312 /// <summary>
313 /// Soon to be decommissioned
314 /// </summary>
315 /// <param name="cAgent"></param>
316 public void CopyFrom(ChildAgentDataUpdate cAgent)
317 {
318 if (cAgent.ActiveGroupID != null)
319 ActiveGroupID = new UUID(cAgent.ActiveGroupID);
320
321 if (cAgent.AgentID != null)
322 AgentID = new UUID(cAgent.AgentID);
323
324 AlwaysRun = cAgent.alwaysrun;
325
326 // next: ???
327 Size = new Vector3();
328 Size.Z = cAgent.AVHeight;
329
330 if (cAgent.cameraPosition != null)
331 Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
332
333 Far = cAgent.drawdistance;
334
335 // downcasting ???
336 GodLevel = (byte)(cAgent.godlevel);
337
338 if (cAgent.ActiveGroupID != null)
339 {
340 Groups = new AgentGroupData[1];
341 Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true);
342 }
343
344 if (cAgent.Position != null)
345 Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z);
346
347 RegionHandle = cAgent.regionHandle;
348
349 Throttles = cAgent.throttles;
350
351 if (cAgent.Velocity != null)
352 Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
353 }
354
355 public void Dump()
356 {
357 System.Console.WriteLine("------------ AgentData ------------");
358 System.Console.WriteLine("UUID: " + AgentID);
359 System.Console.WriteLine("Region: " + RegionHandle);
360 System.Console.WriteLine("Position: " + Position);
361 }
51 } 362 }
363
52} 364}