RigidHand.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. public class RigidHand : SkeletalHand
  6. {
  7. public override ModelType HandModelType
  8. {
  9. get
  10. {
  11. return ModelType.Physics;
  12. }
  13. }
  14. public override bool SupportsEditorPersistence()
  15. {
  16. return true;
  17. }
  18. public override void InitHand()
  19. {
  20. base.InitHand();
  21. }
  22. public override void UpdateHand()
  23. {
  24. for (int i = 0; i < this.fingers.Length; i++)
  25. {
  26. if (this.fingers[i] != null)
  27. {
  28. this.fingers[i].UpdateFinger();
  29. }
  30. }
  31. if (this.palm != null)
  32. {
  33. Rigidbody component = this.palm.GetComponent<Rigidbody>();
  34. if (component)
  35. {
  36. component.MovePosition(base.GetPalmCenter());
  37. component.MoveRotation(base.GetPalmRotation());
  38. }
  39. else
  40. {
  41. this.palm.position = base.GetPalmCenter();
  42. this.palm.rotation = base.GetPalmRotation();
  43. }
  44. }
  45. if (this.forearm != null)
  46. {
  47. CapsuleCollider component2 = this.forearm.GetComponent<CapsuleCollider>();
  48. if (component2 != null)
  49. {
  50. component2.direction = 2;
  51. this.forearm.localScale = new Vector3(1f / base.transform.lossyScale.x, 1f / base.transform.lossyScale.y, 1f / base.transform.lossyScale.z);
  52. component2.radius = base.GetArmWidth() / 2f;
  53. component2.height = base.GetArmLength() + base.GetArmWidth();
  54. }
  55. Rigidbody component3 = this.forearm.GetComponent<Rigidbody>();
  56. if (component3)
  57. {
  58. component3.MovePosition(base.GetArmCenter());
  59. component3.MoveRotation(base.GetArmRotation());
  60. }
  61. else
  62. {
  63. this.forearm.position = base.GetArmCenter();
  64. this.forearm.rotation = base.GetArmRotation();
  65. }
  66. }
  67. }
  68. public float filtering = 0.5f;
  69. }
  70. }