diff options
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index bfdb90f..85aac93 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -71,8 +71,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
71 | private static float PID_D = 3020.0f; | 71 | private static float PID_D = 3020.0f; |
72 | private static float PID_P = 7000.0f; | 72 | private static float PID_P = 7000.0f; |
73 | private static float POSTURE_SERVO = 10000.0f; | 73 | private static float POSTURE_SERVO = 10000.0f; |
74 | public static float CAPSULE_RADIUS = 0.5f; | 74 | public static float CAPSULE_RADIUS = 0.37f; |
75 | public float CAPSULE_LENGTH = 0.79f; | 75 | public float CAPSULE_LENGTH = 2.140599f; |
76 | private bool flying = false; | 76 | private bool flying = false; |
77 | private bool m_iscolliding = false; | 77 | private bool m_iscolliding = false; |
78 | private bool m_iscollidingGround = false; | 78 | private bool m_iscollidingGround = false; |
@@ -326,12 +326,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
326 | lock (OdeScene.OdeLock) | 326 | lock (OdeScene.OdeLock) |
327 | { | 327 | { |
328 | d.JointDestroy(Amotor); | 328 | d.JointDestroy(Amotor); |
329 | |||
329 | PhysicsVector SetSize = value; | 330 | PhysicsVector SetSize = value; |
330 | float prevCapsule = CAPSULE_LENGTH; | 331 | float prevCapsule = CAPSULE_LENGTH; |
331 | float capsuleradius = CAPSULE_RADIUS; | 332 | float capsuleradius = CAPSULE_RADIUS; |
332 | capsuleradius = 0.2f; | 333 | //capsuleradius = 0.2f; |
333 | 334 | ||
334 | CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size | 335 | CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size |
336 | OpenSim.Framework.Console.MainLog.Instance.Verbose("SIZE", CAPSULE_LENGTH.ToString()); | ||
335 | d.BodyDestroy(Body); | 337 | d.BodyDestroy(Body); |
336 | d.GeomDestroy(Shell); | 338 | d.GeomDestroy(Shell); |
337 | AvatarGeomAndBodyCreation(_position.X, _position.Y, | 339 | AvatarGeomAndBodyCreation(_position.X, _position.Y, |
@@ -351,6 +353,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
351 | /// <param name="npositionZ"></param> | 353 | /// <param name="npositionZ"></param> |
352 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) | 354 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) |
353 | { | 355 | { |
356 | |||
354 | int dAMotorEuler = 1; | 357 | int dAMotorEuler = 1; |
355 | Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); | 358 | Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); |
356 | d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); | 359 | d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); |
@@ -360,7 +363,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
360 | d.BodySetMass(Body, ref ShellMass); | 363 | d.BodySetMass(Body, ref ShellMass); |
361 | 364 | ||
362 | // 90 Stand up on the cap of the capped cyllinder | 365 | // 90 Stand up on the cap of the capped cyllinder |
363 | d.RFromAxisAndAngle(out m_StandUpRotation, 1, 0, 0, (float)(Math.PI / 2)); | 366 | d.RFromAxisAndAngle(out m_StandUpRotation, 1, 0, 1, (float)(Math.PI / 2)); |
364 | 367 | ||
365 | 368 | ||
366 | d.GeomSetRotation(Shell, ref m_StandUpRotation); | 369 | d.GeomSetRotation(Shell, ref m_StandUpRotation); |
@@ -395,21 +398,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
395 | d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); | 398 | d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); |
396 | d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 3800000f); | 399 | d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 3800000f); |
397 | 400 | ||
398 | 401 | //standupStraight(); | |
399 | // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air. | 402 | |
400 | // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you | ||
401 | // change appearance and when you enter the simulator | ||
402 | // After this routine is done, the amotor stabilizes much quicker | ||
403 | d.Vector3 feet; | ||
404 | d.Vector3 head; | ||
405 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); | ||
406 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); | ||
407 | float posture = head.Z - feet.Z; | ||
408 | |||
409 | // restoring force proportional to lack of posture: | ||
410 | float servo = (2.5f - posture) * POSTURE_SERVO; | ||
411 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); | ||
412 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); | ||
413 | 403 | ||
414 | 404 | ||
415 | } | 405 | } |
@@ -428,6 +418,27 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
428 | } | 418 | } |
429 | } | 419 | } |
430 | 420 | ||
421 | private void standupStraight() | ||
422 | { | ||
423 | |||
424 | // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air. | ||
425 | // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you | ||
426 | // change appearance and when you enter the simulator | ||
427 | // After this routine is done, the amotor stabilizes much quicker | ||
428 | d.Vector3 feet; | ||
429 | d.Vector3 head; | ||
430 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); | ||
431 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); | ||
432 | float posture = head.Z - feet.Z; | ||
433 | |||
434 | // restoring force proportional to lack of posture: | ||
435 | float servo = (2.5f - posture) * POSTURE_SERVO; | ||
436 | 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); | ||
438 | 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); | ||
440 | } | ||
441 | |||
431 | public override PhysicsVector Force | 442 | public override PhysicsVector Force |
432 | { | 443 | { |
433 | get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } | 444 | get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } |
@@ -467,7 +478,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
467 | public override Quaternion Orientation | 478 | public override Quaternion Orientation |
468 | { | 479 | { |
469 | get { return Quaternion.Identity; } | 480 | get { return Quaternion.Identity; } |
470 | set { } | 481 | set { |
482 | //Matrix3 or = Orientation.ToRotationMatrix(); | ||
483 | //d.Matrix3 ord = new d.Matrix3(or.m00, or.m10, or.m20, or.m01, or.m11, or.m21, or.m02, or.m12, or.m22); | ||
484 | //d.BodySetRotation(Body, ref ord); | ||
485 | |||
486 | } | ||
471 | } | 487 | } |
472 | 488 | ||
473 | public override PhysicsVector Acceleration | 489 | public override PhysicsVector Acceleration |
@@ -505,6 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
505 | if (!collidelock) | 521 | if (!collidelock) |
506 | { | 522 | { |
507 | d.BodyAddForce(Body, force.X, force.Y, force.Z); | 523 | d.BodyAddForce(Body, force.X, force.Y, force.Z); |
524 | //standupStraight(); | ||
508 | } | 525 | } |
509 | } | 526 | } |
510 | 527 | ||