aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Region/Environment/Scenes/ScenePresence.cs
parent*Trunk compiles now (diff)
downloadopensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs1246
1 files changed, 623 insertions, 623 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index b619b59..ae49d9f 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1,623 +1,623 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.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 System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using Axiom.Math; 31using Axiom.Math;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Physics.Manager; 37using OpenSim.Physics.Manager;
38 38
39namespace OpenSim.Region.Environment.Scenes 39namespace OpenSim.Region.Environment.Scenes
40{ 40{
41 public partial class ScenePresence : Entity 41 public partial class ScenePresence : Entity
42 { 42 {
43 public static bool PhysicsEngineFlying = false; 43 public static bool PhysicsEngineFlying = false;
44 public static AvatarAnimations Animations; 44 public static AvatarAnimations Animations;
45 public static byte[] DefaultTexture; 45 public static byte[] DefaultTexture;
46 public string firstname; 46 public string firstname;
47 public string lastname; 47 public string lastname;
48 public IClientAPI ControllingClient; 48 public IClientAPI ControllingClient;
49 public LLUUID current_anim; 49 public LLUUID current_anim;
50 public int anim_seq; 50 public int anim_seq;
51 private bool updateflag = false; 51 private bool updateflag = false;
52 private byte movementflag = 0; 52 private byte movementflag = 0;
53 private List<NewForce> forcesList = new List<NewForce>(); 53 private List<NewForce> forcesList = new List<NewForce>();
54 private short _updateCount = 0; 54 private short _updateCount = 0;
55 private Quaternion bodyRot; 55 private Quaternion bodyRot;
56 private LLObject.TextureEntry avatarAppearanceTexture = null; 56 private LLObject.TextureEntry avatarAppearanceTexture = null;
57 private byte[] visualParams; 57 private byte[] visualParams;
58 private AvatarWearable[] Wearables; 58 private AvatarWearable[] Wearables;
59 private ulong m_regionHandle; 59 private ulong m_regionHandle;
60 60
61 public bool childAgent = false; 61 public bool childAgent = false;
62 public bool IsRestrictedToRegion = false; 62 public bool IsRestrictedToRegion = false;
63 63
64 private bool newForce = false; 64 private bool newForce = false;
65 private bool newAvatar = false; 65 private bool newAvatar = false;
66 private IScenePresenceBody m_body; 66 private IScenePresenceBody m_body;
67 67
68 protected RegionInfo m_regionInfo; 68 protected RegionInfo m_regionInfo;
69 69
70 private Vector3[] Dir_Vectors = new Vector3[6]; 70 private Vector3[] Dir_Vectors = new Vector3[6];
71 private enum Dir_ControlFlags 71 private enum Dir_ControlFlags
72 { 72 {
73 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, 73 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
74 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG, 74 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG,
75 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS, 75 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS,
76 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG, 76 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG,
77 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, 77 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
78 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG 78 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
79 } 79 }
80 /// <summary> 80 /// <summary>
81 /// Position at which a significant movement was made 81 /// Position at which a significant movement was made
82 /// </summary> 82 /// </summary>
83 private LLVector3 posLastSignificantMove = new LLVector3(); 83 private LLVector3 posLastSignificantMove = new LLVector3();
84 84
85 public delegate void SignificantClientMovement(IClientAPI remote_client); 85 public delegate void SignificantClientMovement(IClientAPI remote_client);
86 public event SignificantClientMovement OnSignificantClientMovement; 86 public event SignificantClientMovement OnSignificantClientMovement;
87 87
88 #region Properties 88 #region Properties
89 /// <summary> 89 /// <summary>
90 /// 90 ///
91 /// </summary> 91 /// </summary>
92 public PhysicsActor PhysActor 92 public PhysicsActor PhysActor
93 { 93 {
94 set 94 set
95 { 95 {
96 this._physActor = value; 96 this._physActor = value;
97 } 97 }
98 get 98 get
99 { 99 {
100 return _physActor; 100 return _physActor;
101 } 101 }
102 } 102 }
103 103
104 public ulong RegionHandle 104 public ulong RegionHandle
105 { 105 {
106 get { return m_regionHandle; } 106 get { return m_regionHandle; }
107 } 107 }
108 108
109 #endregion 109 #endregion
110 110
111 #region Constructor(s) 111 #region Constructor(s)
112 /// <summary> 112 /// <summary>
113 /// 113 ///
114 /// </summary> 114 /// </summary>
115 /// <param name="theClient"></param> 115 /// <param name="theClient"></param>
116 /// <param name="world"></param> 116 /// <param name="world"></param>
117 /// <param name="clientThreads"></param> 117 /// <param name="clientThreads"></param>
118 /// <param name="regionDat"></param> 118 /// <param name="regionDat"></param>
119 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) 119 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo)
120 { 120 {
121 121
122 m_world = world; 122 m_world = world;
123 this.uuid = theClient.AgentId; 123 this.uuid = theClient.AgentId;
124 124
125 m_regionInfo = reginfo; 125 m_regionInfo = reginfo;
126 m_regionHandle = reginfo.RegionHandle; 126 m_regionHandle = reginfo.RegionHandle;
127 MainLog.Instance.Verbose("Avatar.cs "); 127 MainLog.Instance.Verbose("Avatar.cs ");
128 ControllingClient = theClient; 128 ControllingClient = theClient;
129 this.firstname = ControllingClient.FirstName; 129 this.firstname = ControllingClient.FirstName;
130 this.lastname = ControllingClient.LastName; 130 this.lastname = ControllingClient.LastName;
131 m_localId = m_world.NextLocalId; 131 m_localId = m_world.NextLocalId;
132 Pos = ControllingClient.StartPos; 132 Pos = ControllingClient.StartPos;
133 visualParams = new byte[218]; 133 visualParams = new byte[218];
134 for (int i = 0; i < 218; i++) 134 for (int i = 0; i < 218; i++)
135 { 135 {
136 visualParams[i] = 100; 136 visualParams[i] = 100;
137 } 137 }
138 138
139 Wearables = AvatarWearable.DefaultWearables; 139 Wearables = AvatarWearable.DefaultWearables;
140 Animations = new ScenePresence.AvatarAnimations(); 140 Animations = new ScenePresence.AvatarAnimations();
141 Animations.LoadAnims(); 141 Animations.LoadAnims();
142 142
143 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 143 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
144 144
145 //register for events 145 //register for events
146 ControllingClient.OnRequestWearables += this.SendOurAppearance; 146 ControllingClient.OnRequestWearables += this.SendOurAppearance;
147 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); 147 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
148 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; 148 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement;
149 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; 149 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData;
150 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; 150 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate;
151 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); 151 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
152 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 152 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
153 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 153 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
154 154
155 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD 155 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
156 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK 156 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
157 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT 157 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
158 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT 158 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
159 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP 159 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
160 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN 160 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
161 161
162 } 162 }
163 #endregion 163 #endregion
164 164
165 #region Status Methods 165 #region Status Methods
166 /// <summary> 166 /// <summary>
167 /// Not Used, most likely can be deleted 167 /// Not Used, most likely can be deleted
168 /// </summary> 168 /// </summary>
169 /// <param name="status"></param> 169 /// <param name="status"></param>
170 public void ChildStatusChange(bool status) 170 public void ChildStatusChange(bool status)
171 { 171 {
172 this.childAgent = status; 172 this.childAgent = status;
173 173
174 if (this.childAgent == true) 174 if (this.childAgent == true)
175 { 175 {
176 this.Velocity = new LLVector3(0, 0, 0); 176 this.Velocity = new LLVector3(0, 0, 0);
177 this.Pos = new LLVector3(128, 128, 70); 177 this.Pos = new LLVector3(128, 128, 70);
178 178
179 } 179 }
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// 183 ///
184 /// </summary> 184 /// </summary>
185 /// <param name="pos"></param> 185 /// <param name="pos"></param>
186 public void MakeAvatar(LLVector3 pos) 186 public void MakeAvatar(LLVector3 pos)
187 { 187 {
188 //this.childAvatar = false; 188 //this.childAvatar = false;
189 this.Pos = pos; 189 this.Pos = pos;
190 this.newAvatar = true; 190 this.newAvatar = true;
191 this.childAgent = false; 191 this.childAgent = false;
192 } 192 }
193 193
194 protected void MakeChildAgent() 194 protected void MakeChildAgent()
195 { 195 {
196 this.Velocity = new LLVector3(0, 0, 0); 196 this.Velocity = new LLVector3(0, 0, 0);
197 this.Pos = new LLVector3(128, 128, 70); 197 this.Pos = new LLVector3(128, 128, 70);
198 this.childAgent = true; 198 this.childAgent = true;
199 } 199 }
200 200
201 /// <summary> 201 /// <summary>
202 /// 202 ///
203 /// </summary> 203 /// </summary>
204 /// <param name="pos"></param> 204 /// <param name="pos"></param>
205 public void Teleport(LLVector3 pos) 205 public void Teleport(LLVector3 pos)
206 { 206 {
207 this.Pos = pos; 207 this.Pos = pos;
208 this.SendTerseUpdateToALLClients(); 208 this.SendTerseUpdateToALLClients();
209 } 209 }
210 210
211 /// <summary> 211 /// <summary>
212 /// 212 ///
213 /// </summary> 213 /// </summary>
214 public void StopMovement() 214 public void StopMovement()
215 { 215 {
216 216
217 } 217 }
218 #endregion 218 #endregion
219 219
220 #region Event Handlers 220 #region Event Handlers
221 /// <summary> 221 /// <summary>
222 /// 222 ///
223 /// </summary> 223 /// </summary>
224 /// <param name="texture"></param> 224 /// <param name="texture"></param>
225 /// <param name="visualParam"></param> 225 /// <param name="visualParam"></param>
226 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) 226 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
227 { 227 {
228 228
229 } 229 }
230 230
231 /// <summary> 231 /// <summary>
232 /// Complete Avatar's movement into the region 232 /// Complete Avatar's movement into the region
233 /// </summary> 233 /// </summary>
234 public void CompleteMovement() 234 public void CompleteMovement()
235 { 235 {
236 LLVector3 look = this.Velocity; 236 LLVector3 look = this.Velocity;
237 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 237 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
238 { 238 {
239 look = new LLVector3(0.99f, 0.042f, 0); 239 look = new LLVector3(0.99f, 0.042f, 0);
240 } 240 }
241 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); 241 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look);
242 if (this.childAgent) 242 if (this.childAgent)
243 { 243 {
244 this.childAgent = false; 244 this.childAgent = false;
245 } 245 }
246 } 246 }
247 247
248 /// <summary> 248 /// <summary>
249 /// 249 ///
250 /// </summary> 250 /// </summary>
251 /// <param name="pack"></param> 251 /// <param name="pack"></param>
252 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 252 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
253 { 253 {
254 int i = 0; 254 int i = 0;
255 bool update_movementflag = false; 255 bool update_movementflag = false;
256 bool update_rotation = false; 256 bool update_rotation = false;
257 bool DCFlagKeyPressed = false; 257 bool DCFlagKeyPressed = false;
258 Vector3 agent_control_v3 = new Vector3(0, 0, 0); 258 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
259 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 259 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
260 260
261 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); 261 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
262 262
263 if (q != this.bodyRot) 263 if (q != this.bodyRot)
264 { 264 {
265 this.bodyRot = q; 265 this.bodyRot = q;
266 update_rotation = true; 266 update_rotation = true;
267 } 267 }
268 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) 268 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags)))
269 { 269 {
270 if ((flags & (uint)DCF) != 0) 270 if ((flags & (uint)DCF) != 0)
271 { 271 {
272 DCFlagKeyPressed = true; 272 DCFlagKeyPressed = true;
273 agent_control_v3 += Dir_Vectors[i]; 273 agent_control_v3 += Dir_Vectors[i];
274 if ((movementflag & (uint)DCF) == 0) 274 if ((movementflag & (uint)DCF) == 0)
275 { 275 {
276 movementflag += (byte)(uint)DCF; 276 movementflag += (byte)(uint)DCF;
277 update_movementflag = true; 277 update_movementflag = true;
278 } 278 }
279 } 279 }
280 else 280 else
281 { 281 {
282 if ((movementflag & (uint)DCF) != 0) 282 if ((movementflag & (uint)DCF) != 0)
283 { 283 {
284 movementflag -= (byte)(uint)DCF; 284 movementflag -= (byte)(uint)DCF;
285 update_movementflag = true; 285 update_movementflag = true;
286 286
287 } 287 }
288 } 288 }
289 i++; 289 i++;
290 } 290 }
291 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) 291 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
292 { 292 {
293 this.AddNewMovement(agent_control_v3, q); 293 this.AddNewMovement(agent_control_v3, q);
294 } 294 }
295 UpdateMovementAnimations(update_movementflag); 295 UpdateMovementAnimations(update_movementflag);
296 } 296 }
297 297
298 protected void UpdateMovementAnimations(bool update_movementflag) 298 protected void UpdateMovementAnimations(bool update_movementflag)
299 { 299 {
300 if (update_movementflag) 300 if (update_movementflag)
301 { 301 {
302 if (movementflag != 0) 302 if (movementflag != 0)
303 { 303 {
304 if (this._physActor.Flying) 304 if (this._physActor.Flying)
305 { 305 {
306 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); 306 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1);
307 } 307 }
308 else 308 else
309 { 309 {
310 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); 310 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1);
311 } 311 }
312 } 312 }
313 else 313 else
314 { 314 {
315 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); 315 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1);
316 } 316 }
317 } 317 }
318 318
319 } 319 }
320 320
321 321
322 protected void AddNewMovement(Vector3 vec, Quaternion rotation) 322 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
323 { 323 {
324 NewForce newVelocity = new NewForce(); 324 NewForce newVelocity = new NewForce();
325 Vector3 direc = rotation * vec; 325 Vector3 direc = rotation * vec;
326 direc.Normalize(); 326 direc.Normalize();
327 327
328 direc = direc * ((0.03f) * 128f); 328 direc = direc * ((0.03f) * 128f);
329 if (this._physActor.Flying) 329 if (this._physActor.Flying)
330 direc *= 4; 330 direc *= 4;
331 331
332 newVelocity.X = direc.x; 332 newVelocity.X = direc.x;
333 newVelocity.Y = direc.y; 333 newVelocity.Y = direc.y;
334 newVelocity.Z = direc.z; 334 newVelocity.Z = direc.z;
335 this.forcesList.Add(newVelocity); 335 this.forcesList.Add(newVelocity);
336 } 336 }
337 337
338 #endregion 338 #endregion
339 339
340 #region Overridden Methods 340 #region Overridden Methods
341 /// <summary> 341 /// <summary>
342 /// 342 ///
343 /// </summary> 343 /// </summary>
344 public override void LandRenegerated() 344 public override void LandRenegerated()
345 { 345 {
346 346
347 } 347 }
348 348
349 /// <summary> 349 /// <summary>
350 /// 350 ///
351 /// </summary> 351 /// </summary>
352 public override void update() 352 public override void update()
353 { 353 {
354 if (this.childAgent == false) 354 if (this.childAgent == false)
355 { 355 {
356 if (this.newForce) 356 if (this.newForce)
357 { 357 {
358 this.SendTerseUpdateToALLClients(); 358 this.SendTerseUpdateToALLClients();
359 _updateCount = 0; 359 _updateCount = 0;
360 } 360 }
361 else if (movementflag != 0) 361 else if (movementflag != 0)
362 { 362 {
363 _updateCount++; 363 _updateCount++;
364 if (_updateCount > 3) 364 if (_updateCount > 3)
365 { 365 {
366 this.SendTerseUpdateToALLClients(); 366 this.SendTerseUpdateToALLClients();
367 _updateCount = 0; 367 _updateCount = 0;
368 } 368 }
369 } 369 }
370 370
371 this.CheckForSignificantMovement(); 371 this.CheckForSignificantMovement();
372 this.CheckForBorderCrossing(); 372 this.CheckForBorderCrossing();
373 373
374 } 374 }
375 } 375 }
376 #endregion 376 #endregion
377 377
378 #region Update Client(s) 378 #region Update Client(s)
379 /// <summary> 379 /// <summary>
380 /// 380 ///
381 /// </summary> 381 /// </summary>
382 /// <param name="RemoteClient"></param> 382 /// <param name="RemoteClient"></param>
383 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 383 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
384 { 384 {
385 LLVector3 pos = this.Pos; 385 LLVector3 pos = this.Pos;
386 LLVector3 vel = this.Velocity; 386 LLVector3 vel = this.Velocity;
387 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); 387 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
388 } 388 }
389 389
390 /// <summary> 390 /// <summary>
391 /// 391 ///
392 /// </summary> 392 /// </summary>
393 public void SendTerseUpdateToALLClients() 393 public void SendTerseUpdateToALLClients()
394 { 394 {
395 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 395 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
396 for (int i = 0; i < avatars.Count; i++) 396 for (int i = 0; i < avatars.Count; i++)
397 { 397 {
398 this.SendTerseUpdateToClient(avatars[i].ControllingClient); 398 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
399 } 399 }
400 } 400 }
401 401
402 /// <summary> 402 /// <summary>
403 /// 403 ///
404 /// </summary> 404 /// </summary>
405 /// <param name="remoteAvatar"></param> 405 /// <param name="remoteAvatar"></param>
406 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 406 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
407 { 407 {
408 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); 408 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
409 } 409 }
410 410
411 public void SendFullUpdateToALLClients() 411 public void SendFullUpdateToALLClients()
412 { 412 {
413 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 413 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
414 foreach (ScenePresence avatar in this.m_world.RequestAvatarList()) 414 foreach (ScenePresence avatar in this.m_world.RequestAvatarList())
415 { 415 {
416 this.SendFullUpdateToOtherClient(avatar); 416 this.SendFullUpdateToOtherClient(avatar);
417 avatar.SendFullUpdateToOtherClient(this); 417 avatar.SendFullUpdateToOtherClient(this);
418 } 418 }
419 } 419 }
420 420
421 /// <summary> 421 /// <summary>
422 /// 422 ///
423 /// </summary> 423 /// </summary>
424 public void SendInitialData() 424 public void SendInitialData()
425 { 425 {
426 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); 426 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
427 if (this.newAvatar) 427 if (this.newAvatar)
428 { 428 {
429 this.m_world.InformClientOfNeighbours(this.ControllingClient); 429 this.m_world.InformClientOfNeighbours(this.ControllingClient);
430 this.newAvatar = false; 430 this.newAvatar = false;
431 } 431 }
432 } 432 }
433 433
434 /// <summary> 434 /// <summary>
435 /// 435 ///
436 /// </summary> 436 /// </summary>
437 /// <param name="OurClient"></param> 437 /// <param name="OurClient"></param>
438 public void SendOurAppearance(IClientAPI OurClient) 438 public void SendOurAppearance(IClientAPI OurClient)
439 { 439 {
440 this.ControllingClient.SendWearables(this.Wearables); 440 this.ControllingClient.SendWearables(this.Wearables);
441 this.SendFullUpdateToALLClients(); 441 this.SendFullUpdateToALLClients();
442 this.m_world.SendAllSceneObjectsToClient(this.ControllingClient); 442 this.m_world.SendAllSceneObjectsToClient(this.ControllingClient);
443 } 443 }
444 444
445 /// <summary> 445 /// <summary>
446 /// 446 ///
447 /// </summary> 447 /// </summary>
448 /// <param name="avatarInfo"></param> 448 /// <param name="avatarInfo"></param>
449 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) 449 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
450 { 450 {
451 451
452 } 452 }
453 453
454 /// <summary> 454 /// <summary>
455 /// 455 ///
456 /// </summary> 456 /// </summary>
457 /// <param name="animID"></param> 457 /// <param name="animID"></param>
458 /// <param name="seq"></param> 458 /// <param name="seq"></param>
459 public void SendAnimPack(LLUUID animID, int seq) 459 public void SendAnimPack(LLUUID animID, int seq)
460 { 460 {
461 this.current_anim = animID; 461 this.current_anim = animID;
462 this.anim_seq = seq; 462 this.anim_seq = seq;
463 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 463 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
464 for (int i = 0; i < avatars.Count; i++) 464 for (int i = 0; i < avatars.Count; i++)
465 { 465 {
466 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); 466 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId);
467 } 467 }
468 } 468 }
469 469
470 /// <summary> 470 /// <summary>
471 /// 471 ///
472 /// </summary> 472 /// </summary>
473 public void SendAnimPack() 473 public void SendAnimPack()
474 { 474 {
475 this.SendAnimPack(this.current_anim, this.anim_seq); 475 this.SendAnimPack(this.current_anim, this.anim_seq);
476 } 476 }
477 #endregion 477 #endregion
478 478
479 #region Significant Movement Method 479 #region Significant Movement Method
480 480
481 protected void CheckForSignificantMovement() 481 protected void CheckForSignificantMovement()
482 { 482 {
483 if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0) 483 if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0)
484 { 484 {
485 this.posLastSignificantMove = this.Pos; 485 this.posLastSignificantMove = this.Pos;
486 if (OnSignificantClientMovement != null) 486 if (OnSignificantClientMovement != null)
487 { 487 {
488 OnSignificantClientMovement(this.ControllingClient); 488 OnSignificantClientMovement(this.ControllingClient);
489 } 489 }
490 } 490 }
491 } 491 }
492 #endregion 492 #endregion
493 #region Border Crossing Methods 493 #region Border Crossing Methods
494 /// <summary> 494 /// <summary>
495 /// 495 ///
496 /// </summary> 496 /// </summary>
497 protected void CheckForBorderCrossing() 497 protected void CheckForBorderCrossing()
498 { 498 {
499 LLVector3 pos2 = this.Pos; 499 LLVector3 pos2 = this.Pos;
500 LLVector3 vel = this.Velocity; 500 LLVector3 vel = this.Velocity;
501 501
502 float timeStep = 0.2f; 502 float timeStep = 0.2f;
503 pos2.X = pos2.X + (vel.X * timeStep); 503 pos2.X = pos2.X + (vel.X * timeStep);
504 pos2.Y = pos2.Y + (vel.Y * timeStep); 504 pos2.Y = pos2.Y + (vel.Y * timeStep);
505 pos2.Z = pos2.Z + (vel.Z * timeStep); 505 pos2.Z = pos2.Z + (vel.Z * timeStep);
506 506
507 if ((pos2.X < 0) || (pos2.X > 256)) 507 if ((pos2.X < 0) || (pos2.X > 256))
508 { 508 {
509 this.CrossToNewRegion(); 509 this.CrossToNewRegion();
510 } 510 }
511 511
512 if ((pos2.Y < 0) || (pos2.Y > 256)) 512 if ((pos2.Y < 0) || (pos2.Y > 256))
513 { 513 {
514 this.CrossToNewRegion(); 514 this.CrossToNewRegion();
515 } 515 }
516 } 516 }
517 517
518 /// <summary> 518 /// <summary>
519 /// 519 ///
520 /// </summary> 520 /// </summary>
521 protected void CrossToNewRegion() 521 protected void CrossToNewRegion()
522 { 522 {
523 LLVector3 pos = this.Pos; 523 LLVector3 pos = this.Pos;
524 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); 524 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
525 uint neighbourx = this.m_regionInfo.RegionLocX; 525 uint neighbourx = this.m_regionInfo.RegionLocX;
526 uint neighboury = this.m_regionInfo.RegionLocY; 526 uint neighboury = this.m_regionInfo.RegionLocY;
527 527
528 if (pos.X < 2) 528 if (pos.X < 2)
529 { 529 {
530 neighbourx -= 1; 530 neighbourx -= 1;
531 newpos.X = 254; 531 newpos.X = 254;
532 } 532 }
533 if (pos.X > 253) 533 if (pos.X > 253)
534 { 534 {
535 neighbourx += 1; 535 neighbourx += 1;
536 newpos.X = 1; 536 newpos.X = 1;
537 } 537 }
538 if (pos.Y < 2) 538 if (pos.Y < 2)
539 { 539 {
540 neighboury -= 1; 540 neighboury -= 1;
541 newpos.Y = 254; 541 newpos.Y = 254;
542 } 542 }
543 if (pos.Y > 253) 543 if (pos.Y > 253)
544 { 544 {
545 neighboury += 1; 545 neighboury += 1;
546 newpos.Y = 1; 546 newpos.Y = 1;
547 } 547 }
548 548
549 LLVector3 vel = this.m_velocity; 549 LLVector3 vel = this.m_velocity;
550 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); 550 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
551 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); 551 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
552 if (neighbourRegion != null) 552 if (neighbourRegion != null)
553 { 553 {
554 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); 554 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
555 if (res) 555 if (res)
556 { 556 {
557 this.MakeChildAgent(); 557 this.MakeChildAgent();
558 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint); 558 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint);
559 } 559 }
560 } 560 }
561 } 561 }
562 #endregion 562 #endregion
563 563
564 /// <summary> 564 /// <summary>
565 /// 565 ///
566 /// </summary> 566 /// </summary>
567 public static void LoadAnims() 567 public static void LoadAnims()
568 { 568 {
569 569
570 } 570 }
571 571
572 /// <summary> 572 /// <summary>
573 /// 573 ///
574 /// </summary> 574 /// </summary>
575 public override void updateMovement() 575 public override void updateMovement()
576 { 576 {
577 newForce = false; 577 newForce = false;
578 lock (this.forcesList) 578 lock (this.forcesList)
579 { 579 {
580 if (this.forcesList.Count > 0) 580 if (this.forcesList.Count > 0)
581 { 581 {
582 for (int i = 0; i < this.forcesList.Count; i++) 582 for (int i = 0; i < this.forcesList.Count; i++)
583 { 583 {
584 NewForce force = this.forcesList[i]; 584 NewForce force = this.forcesList[i];
585 585
586 this.updateflag = true; 586 this.updateflag = true;
587 this.Velocity = new LLVector3(force.X, force.Y, force.Z); 587 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
588 this.newForce = true; 588 this.newForce = true;
589 } 589 }
590 for (int i = 0; i < this.forcesList.Count; i++) 590 for (int i = 0; i < this.forcesList.Count; i++)
591 { 591 {
592 this.forcesList.RemoveAt(0); 592 this.forcesList.RemoveAt(0);
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 597
598 public static void LoadTextureFile(string name) 598 public static void LoadTextureFile(string name)
599 { 599 {
600 FileInfo fInfo = new FileInfo(name); 600 FileInfo fInfo = new FileInfo(name);
601 long numBytes = fInfo.Length; 601 long numBytes = fInfo.Length;
602 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 602 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
603 BinaryReader br = new BinaryReader(fStream); 603 BinaryReader br = new BinaryReader(fStream);
604 byte[] data1 = br.ReadBytes((int)numBytes); 604 byte[] data1 = br.ReadBytes((int)numBytes);
605 br.Close(); 605 br.Close();
606 fStream.Close(); 606 fStream.Close();
607 DefaultTexture = data1; 607 DefaultTexture = data1;
608 } 608 }
609 609
610 public class NewForce 610 public class NewForce
611 { 611 {
612 public float X; 612 public float X;
613 public float Y; 613 public float Y;
614 public float Z; 614 public float Z;
615 615
616 public NewForce() 616 public NewForce()
617 { 617 {
618 618
619 } 619 }
620 } 620 }
621 } 621 }
622 622
623} 623}