diff options
author | Teravus Ovares | 2008-01-18 21:38:47 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-01-18 21:38:47 +0000 |
commit | 741d136f8c44fbbaa9259438732185121841fd22 (patch) | |
tree | 818ad05f896286ada1d3ffa31b4ef946b66439a8 | |
parent | Why don't you try compiling before you commit? (diff) | |
download | opensim-SC-741d136f8c44fbbaa9259438732185121841fd22.zip opensim-SC-741d136f8c44fbbaa9259438732185121841fd22.tar.gz opensim-SC-741d136f8c44fbbaa9259438732185121841fd22.tar.bz2 opensim-SC-741d136f8c44fbbaa9259438732185121841fd22.tar.xz |
* Return of the avatar wobble.
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 9a37a9e..08524a7 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -73,6 +73,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
73 | private static float POSTURE_SERVO = 10000.0f; | 73 | private static float POSTURE_SERVO = 10000.0f; |
74 | public static float CAPSULE_RADIUS = 0.37f; | 74 | public static float CAPSULE_RADIUS = 0.37f; |
75 | public float CAPSULE_LENGTH = 2.140599f; | 75 | public float CAPSULE_LENGTH = 2.140599f; |
76 | private float m_tensor = 3800000f; | ||
76 | private bool flying = false; | 77 | private bool flying = false; |
77 | private bool m_iscolliding = false; | 78 | private bool m_iscolliding = false; |
78 | private bool m_iscollidingGround = false; | 79 | private bool m_iscollidingGround = false; |
@@ -105,10 +106,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
105 | _position = pos; | 106 | _position = pos; |
106 | _acceleration = new PhysicsVector(); | 107 | _acceleration = new PhysicsVector(); |
107 | _parent_scene = parent_scene; | 108 | _parent_scene = parent_scene; |
108 | 109 | ||
109 | m_StandUpRotation = | 110 | m_StandUpRotation = |
110 | new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, | 111 | new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, |
111 | -0.004689182f, 0.9998941f); | 112 | 0.5f); |
112 | 113 | ||
113 | for (int i = 0; i < 11; i++) | 114 | for (int i = 0; i < 11; i++) |
114 | { | 115 | { |
@@ -117,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
117 | 118 | ||
118 | lock (OdeScene.OdeLock) | 119 | lock (OdeScene.OdeLock) |
119 | { | 120 | { |
120 | AvatarGeomAndBodyCreation(pos.X, pos.Y, pos.Z); | 121 | AvatarGeomAndBodyCreation(pos.X, pos.Y, pos.Z, m_tensor); |
121 | } | 122 | } |
122 | m_name = avName; | 123 | m_name = avName; |
123 | parent_scene.geom_name_map[Shell] = avName; | 124 | parent_scene.geom_name_map[Shell] = avName; |
@@ -325,7 +326,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
325 | m_pidControllerActive = true; | 326 | m_pidControllerActive = true; |
326 | lock (OdeScene.OdeLock) | 327 | lock (OdeScene.OdeLock) |
327 | { | 328 | { |
328 | d.JointDestroy(Amotor); | 329 | //d.JointDestroy(Amotor); |
329 | 330 | ||
330 | PhysicsVector SetSize = value; | 331 | PhysicsVector SetSize = value; |
331 | float prevCapsule = CAPSULE_LENGTH; | 332 | float prevCapsule = CAPSULE_LENGTH; |
@@ -337,7 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
337 | d.BodyDestroy(Body); | 338 | d.BodyDestroy(Body); |
338 | d.GeomDestroy(Shell); | 339 | d.GeomDestroy(Shell); |
339 | AvatarGeomAndBodyCreation(_position.X, _position.Y, | 340 | AvatarGeomAndBodyCreation(_position.X, _position.Y, |
340 | _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule)*2)); | 341 | _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); |
341 | Velocity = new PhysicsVector(0f, 0f, 0f); | 342 | Velocity = new PhysicsVector(0f, 0f, 0f); |
342 | 343 | ||
343 | } | 344 | } |
@@ -351,7 +352,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
351 | /// <param name="npositionX"></param> | 352 | /// <param name="npositionX"></param> |
352 | /// <param name="npositionY"></param> | 353 | /// <param name="npositionY"></param> |
353 | /// <param name="npositionZ"></param> | 354 | /// <param name="npositionZ"></param> |
354 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) | 355 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor) |
355 | { | 356 | { |
356 | 357 | ||
357 | int dAMotorEuler = 1; | 358 | int dAMotorEuler = 1; |
@@ -361,44 +362,49 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
361 | d.BodySetPosition(Body, npositionX, npositionY, npositionZ); | 362 | d.BodySetPosition(Body, npositionX, npositionY, npositionZ); |
362 | 363 | ||
363 | d.BodySetMass(Body, ref ShellMass); | 364 | d.BodySetMass(Body, ref ShellMass); |
364 | 365 | d.Matrix3 m_caprot; | |
365 | // 90 Stand up on the cap of the capped cyllinder | 366 | // 90 Stand up on the cap of the capped cyllinder |
366 | d.RFromAxisAndAngle(out m_StandUpRotation, 1, 0, 1, (float)(Math.PI / 2)); | 367 | //d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); |
367 | 368 | ||
368 | 369 | ||
369 | d.GeomSetRotation(Shell, ref m_StandUpRotation); | 370 | //d.GeomSetRotation(Shell, ref m_caprot); |
370 | d.BodySetRotation(Body, ref m_StandUpRotation); | 371 | //d.BodySetRotation(Body, ref m_caprot); |
371 | 372 | ||
372 | d.GeomSetBody(Shell, Body); | 373 | d.GeomSetBody(Shell, Body); |
373 | 374 | ||
374 | 375 | ||
375 | // The purpose of the AMotor here is to keep the avatar's physical | 376 | // The purpose of the AMotor here is to keep the avatar's physical |
376 | // surrogate from rotating while moving | 377 | // surrogate from rotating while moving |
377 | Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); | 378 | //Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); |
378 | d.JointAttach(Amotor, Body, IntPtr.Zero); | 379 | //d.JointAttach(Amotor, Body, IntPtr.Zero); |
379 | d.JointSetAMotorMode(Amotor, dAMotorEuler); | 380 | ///d.JointSetAMotorMode(Amotor, dAMotorEuler); |
380 | d.JointSetAMotorNumAxes(Amotor, 3); | 381 | //d.JointSetAMotorNumAxes(Amotor, 3); |
381 | d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); | 382 | //d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); |
382 | d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); | 383 | //d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); |
383 | d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); | 384 | //d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); |
384 | d.JointSetAMotorAngle(Amotor, 0, 0); | 385 | //d.JointSetAMotorAngle(Amotor, 0, 0); |
385 | d.JointSetAMotorAngle(Amotor, 1, 0); | 386 | //d.JointSetAMotorAngle(Amotor, 1, 0); |
386 | d.JointSetAMotorAngle(Amotor, 2, 0); | 387 | //d.JointSetAMotorAngle(Amotor, 2, 0); |
387 | 388 | ||
388 | // These lowstops and high stops are effectively (no wiggle room) | 389 | // These lowstops and high stops are effectively (no wiggle room) |
389 | d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); | 390 | //d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); |
390 | d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); | 391 | //d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); |
391 | d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); | 392 | //d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); |
392 | d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); | 393 | //d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); |
393 | d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); | 394 | //d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); |
394 | d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); | 395 | //d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); |
395 | 396 | ||
396 | // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the | 397 | // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the |
397 | // capped cyllinder will fall over | 398 | // capped cyllinder will fall over |
398 | d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); | 399 | //d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); |
399 | d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 3800000f); | 400 | //d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); |
400 | 401 | ||
401 | standupStraight(); | 402 | //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); |
403 | //d.QfromR( | ||
404 | //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068, | ||
405 | // | ||
406 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICSAV", "Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); | ||
407 | //standupStraight(); | ||
402 | 408 | ||
403 | 409 | ||
404 | 410 | ||
@@ -435,8 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
435 | float servo = (2.5f - posture) * POSTURE_SERVO; | 441 | float servo = (2.5f - posture) * POSTURE_SERVO; |
436 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); | 442 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); |
437 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); | 443 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); |
438 | d.Matrix3 bodyrotation = d.BodyGetRotation(Body); | 444 | //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); |
439 | OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICSAV", "Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); | 445 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICSAV", "Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); |
440 | } | 446 | } |
441 | 447 | ||
442 | public override PhysicsVector Force | 448 | public override PhysicsVector Force |
@@ -521,7 +527,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
521 | if (!collidelock) | 527 | if (!collidelock) |
522 | { | 528 | { |
523 | d.BodyAddForce(Body, force.X, force.Y, force.Z); | 529 | d.BodyAddForce(Body, force.X, force.Y, force.Z); |
524 | //standupStraight(); | 530 | //d.BodySetRotation(Body, ref m_StandUpRotation); |
531 | standupStraight(); | ||
532 | |||
525 | } | 533 | } |
526 | } | 534 | } |
527 | 535 | ||
@@ -713,7 +721,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
713 | lock (OdeScene.OdeLock) | 721 | lock (OdeScene.OdeLock) |
714 | { | 722 | { |
715 | // Kill the Amotor | 723 | // Kill the Amotor |
716 | d.JointDestroy(Amotor); | 724 | //d.JointDestroy(Amotor); |
717 | 725 | ||
718 | //kill the Geometry | 726 | //kill the Geometry |
719 | d.GeomDestroy(Shell); | 727 | d.GeomDestroy(Shell); |