aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Animation
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Animation')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs220
1 files changed, 164 insertions, 56 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e9e1845..904a657 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -57,11 +57,17 @@ namespace OpenSim.Region.Framework.Scenes.Animation
57 { 57 {
58 get { return m_movementAnimation; } 58 get { return m_movementAnimation; }
59 } 59 }
60 protected string m_movementAnimation = "DEFAULT"; 60 // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist!
61 61 protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init.
62 private int m_animTickFall; 62 private int m_animTickFall;
63 private int m_animTickJump; 63// private int m_animTickJump;
64 64 public int m_animTickJump; // ScenePresence has to see this to control +Z force
65 public bool m_jumping = false; // Add for jumping
66 public float m_jumpVelocity = 0f; // Add for jumping
67 private int m_landing = 0; // Add for jumping
68 public bool m_falling = false; // Add for falling
69 private float m_fallHeight; // Add for falling
70
65 /// <value> 71 /// <value>
66 /// The scene presence that this animator applies to 72 /// The scene presence that this animator applies to
67 /// </value> 73 /// </value>
@@ -122,7 +128,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
122 128
123 public void ResetAnimations() 129 public void ResetAnimations()
124 { 130 {
131Console.WriteLine("ResetA.............");
125 m_animations.Clear(); 132 m_animations.Clear();
133TrySetMovementAnimation("STAND");
126 } 134 }
127 135
128 /// <summary> 136 /// <summary>
@@ -152,14 +160,14 @@ namespace OpenSim.Region.Framework.Scenes.Animation
152 /// </summary> 160 /// </summary>
153 public string GetMovementAnimation() 161 public string GetMovementAnimation()
154 { 162 {
155 const float FALL_DELAY = 0.33f; 163//Console.WriteLine("GMA-------"); //##
156 const float PREJUMP_DELAY = 0.25f; 164//#@ const float FALL_DELAY = 0.33f;
157 165 const float FALL_DELAY = 800f; //## mS
166//rm for jumping const float PREJUMP_DELAY = 0.25f;
167 const float PREJUMP_DELAY = 200f; // mS add for jumping
168 const float JUMP_PERIOD = 800f; // mS add for jumping
158 #region Inputs 169 #region Inputs
159 if (m_scenePresence.SitGround) 170
160 {
161 return "SIT_GROUND_CONSTRAINED";
162 }
163 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; 171 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
164 PhysicsActor actor = m_scenePresence.PhysicsActor; 172 PhysicsActor actor = m_scenePresence.PhysicsActor;
165 173
@@ -169,11 +177,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
169 Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); 177 Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
170 178
171 // Check control flags 179 // Check control flags
172 bool heldForward = 180 bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS);
173 (((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)); 181 bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
174 bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; 182 bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
175 bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; 183 bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG);
176 bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
177 bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; 184 bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
178 bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; 185 bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
179 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; 186 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
@@ -192,8 +199,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
192 199
193 // Is the avatar trying to move? 200 // Is the avatar trying to move?
194// bool moving = (move != Vector3.Zero); 201// bool moving = (move != Vector3.Zero);
195 bool jumping = m_animTickJump != 0; 202// rm for jumping bool jumping = m_animTickJump != 0;
196
197 #endregion Inputs 203 #endregion Inputs
198 204
199 #region Flying 205 #region Flying
@@ -202,6 +208,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
202 { 208 {
203 m_animTickFall = 0; 209 m_animTickFall = 0;
204 m_animTickJump = 0; 210 m_animTickJump = 0;
211 m_jumping = false; //add for jumping
212 m_falling = true; //add for falling
213 m_jumpVelocity = 0f; //add for jumping
214 actor.Selected = false; //add for jumping flag
215 m_fallHeight = actor.Position.Z; // save latest flying height
205 216
206 if (move.X != 0f || move.Y != 0f) 217 if (move.X != 0f || move.Y != 0f)
207 { 218 {
@@ -213,8 +224,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
213 } 224 }
214 else if (move.Z < 0f) 225 else if (move.Z < 0f)
215 { 226 {
216 if (actor != null && actor.IsColliding) 227 if (actor != null && actor.IsColliding)
228 { //##
229//Console.WriteLine("LAND FLYING"); // ##
217 return "LAND"; 230 return "LAND";
231 } //#
218 else 232 else
219 return "HOVER_DOWN"; 233 return "HOVER_DOWN";
220 } 234 }
@@ -228,48 +242,127 @@ namespace OpenSim.Region.Framework.Scenes.Animation
228 242
229 #region Falling/Floating/Landing 243 #region Falling/Floating/Landing
230 244
231 if (actor == null || !actor.IsColliding) 245// rm for jumping if (actor == null || !actor.IsColliding)
246 if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping
232 { 247 {
233 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 248// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
249 float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS
234 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; 250 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
251//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //##
235 252
236 if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) 253// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f))
254 if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping
255
256 if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping
257 // not falling yet or going up
237 { 258 {
238 // Just started falling 259 // reset start of fall time
239 m_animTickFall = Environment.TickCount; 260 m_animTickFall = Environment.TickCount;
240 } 261 }
241 else if (!jumping && fallElapsed > FALL_DELAY) 262// else if (!jumping && fallElapsed > FALL_DELAY)
263 else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.m_wasFlying)) // add for falling and jumping
242 { 264 {
243 // Falling long enough to trigger the animation 265 // Falling long enough to trigger the animation
266//Console.WriteLine("FALLDOWN"); //##
244 return "FALLDOWN"; 267 return "FALLDOWN";
245 } 268 }
246 else if (m_animTickJump == -1)
247 {
248 m_animTickJump = 0;
249 return "STAND";
250 }
251 269
252 return m_movementAnimation; 270 return m_movementAnimation;
253 } 271 }
254 272
255 #endregion Falling/Floating/Landing 273 #endregion Falling/Floating/Landing
256 274
275
276 #region Jumping // section added for jumping...
277
278 int jumptime;
279 jumptime = Environment.TickCount - m_animTickJump;
280
281
282 if ((move.Z > 0f) && (!m_jumping))
283 {
284//Console.WriteLine("PJ {0}", jumptime); //##
285 // Start jumping, prejump
286 m_animTickFall = 0;
287 m_jumping = true;
288 m_falling = false;
289 actor.Selected = true; // borrowed for jmping flag
290 m_animTickJump = Environment.TickCount;
291 m_jumpVelocity = 0.35f;
292 return "PREJUMP";
293 }
294
295 if(m_jumping)
296 {
297 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
298 {
299//Console.WriteLine("LA {0}", jumptime); //##
300 // end jumping
301 m_jumping = false;
302 m_falling = false;
303 actor.Selected = false; // borrowed for jumping flag
304 m_jumpVelocity = 0f;
305 m_animTickFall = Environment.TickCount;
306 return "LAND";
307 }
308 else if (jumptime > JUMP_PERIOD)
309 {
310//Console.WriteLine("JD {0}", jumptime); //##
311 // jump down
312 m_jumpVelocity = 0f;
313 return "JUMP";
314 }
315 else if (jumptime > PREJUMP_DELAY)
316 {
317//Console.WriteLine("JU {0}", jumptime); //##
318 // jump up
319 m_jumping = true;
320 m_jumpVelocity = 10f;
321 return "JUMP";
322 }
323 }
324
325 #endregion Jumping // end added section
326
257 #region Ground Movement 327 #region Ground Movement
258 328
259 if (m_movementAnimation == "FALLDOWN") 329 if (m_movementAnimation == "FALLDOWN")
260 { 330 {
331 m_falling = false;
261 m_animTickFall = Environment.TickCount; 332 m_animTickFall = Environment.TickCount;
262
263 // TODO: SOFT_LAND support 333 // TODO: SOFT_LAND support
264 return "LAND"; 334 float fallHeight = m_fallHeight - actor.Position.Z;
335//Console.WriteLine("Hit from {0}", fallHeight); //##
336 if (fallHeight > 15.0f) // add for falling
337 return "STANDUP";
338 else if (fallHeight > 8.0f) // add for falling
339 return "SOFT_LAND"; // add for falling
340 else // add for falling
341 return "LAND"; // add for falling
265 } 342 }
266 else if (m_movementAnimation == "LAND") 343// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
344// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
345// rm for landing return "LAND";
346 else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP"))
267 { 347 {
268 float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 348 int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping
269 if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) 349 int limit = 1000; // add for jumping
270 return "LAND"; 350 if(m_movementAnimation == "LAND") limit = 350; // add for jumping
271 } 351 // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client
272 352
353 if ((m_animTickFall != 0) && (landElapsed <= limit)) // add for jumping
354 {
355//Console.WriteLine("Lelapse {0}", m_movementAnimation); //##
356 return m_movementAnimation;
357 }
358 else
359 {
360//Console.WriteLine("end/STAND"); //##
361 m_fallHeight = actor.Position.Z; // save latest flying height
362 return "STAND";
363 }
364 }
365/* This section removed, replaced by jumping section
273 m_animTickFall = 0; 366 m_animTickFall = 0;
274 367
275 if (move.Z > 0.2f) 368 if (move.Z > 0.2f)
@@ -281,7 +374,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
281 m_animTickJump = Environment.TickCount; 374 m_animTickJump = Environment.TickCount;
282 return "PREJUMP"; 375 return "PREJUMP";
283 } 376 }
284 else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) 377 else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f)
285 { 378 {
286 // Start actual jump 379 // Start actual jump
287 if (m_animTickJump == -1) 380 if (m_animTickJump == -1)
@@ -294,24 +387,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation
294 m_animTickJump = -1; 387 m_animTickJump = -1;
295 return "JUMP"; 388 return "JUMP";
296 } 389 }
297 else
298 return "JUMP";
299 } 390 }
300 else 391 else
301 { 392 {
302 // Not jumping 393 // Not jumping
303 m_animTickJump = 0; 394 m_animTickJump = 0;
304 395 */
305 if (move.X != 0f || move.Y != 0f) 396 // next section moved outside paren. and realigned for jumping
306 { 397 if (move.X != 0f || move.Y != 0f)
307 // Walking / crouchwalking / running 398 {
308 if (move.Z < 0) 399 m_fallHeight = actor.Position.Z; // save latest flying height
309 return "CROUCHWALK"; 400 m_falling = false; // Add for falling
310 else if (m_scenePresence.SetAlwaysRun) 401 // Walking / crouchwalking / running
311 return "RUN"; 402 if (move.Z < 0f)
312 else 403 return "CROUCHWALK";
313 return "WALK"; 404 else if (m_scenePresence.SetAlwaysRun)
314 } 405 return "RUN";
315 else 406 else
316 { 407 {
317 // Not walking 408 // Not walking
@@ -322,13 +413,24 @@ namespace OpenSim.Region.Framework.Scenes.Animation
322 else if (heldTurnRight) 413 else if (heldTurnRight)
323 return "TURNRIGHT"; 414 return "TURNRIGHT";
324 else 415 else
325 return "STAND"; 416 return "WALK";
326 } 417 }
327 } 418 }
328 419// rm for jumping else
420 else if (!m_jumping) // add for jumping
421 {
422 m_falling = false; // Add for falling
423 // Not walking
424 if (move.Z < 0f)
425 return "CROUCH";
426 else
427 return "STAND";
428 }
429 // end section realign for jumping
329 #endregion Ground Movement 430 #endregion Ground Movement
330 431
331 //return m_movementAnimation; 432 m_falling = false; // Add for falling
433 return m_movementAnimation;
332 } 434 }
333 435
334 /// <summary> 436 /// <summary>
@@ -337,9 +439,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
337 public void UpdateMovementAnimations() 439 public void UpdateMovementAnimations()
338 { 440 {
339 m_movementAnimation = GetMovementAnimation(); 441 m_movementAnimation = GetMovementAnimation();
340// m_log.DebugFormat( 442/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
341// "[SCENE PRESENCE ANIMATOR]: Got animation {0} for {1}", m_movementAnimation, m_scenePresence.Name); 443 {
342 TrySetMovementAnimation(m_movementAnimation); 444 // This was the previous behavior before PREJUMP
445 TrySetMovementAnimation("JUMP");
446 }
447 else
448 { removed for jumping */
449 TrySetMovementAnimation(m_movementAnimation);
450// rm for jumping }
343 } 451 }
344 452
345 public UUID[] GetAnimationArray() 453 public UUID[] GetAnimationArray()