SkeletalHand.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. public class SkeletalHand : HandModel
  6. {
  7. public override ModelType HandModelType
  8. {
  9. get
  10. {
  11. return ModelType.Graphics;
  12. }
  13. }
  14. private void Start()
  15. {
  16. Utils.IgnoreCollisions(base.gameObject, base.gameObject, true);
  17. for (int i = 0; i < this.fingers.Length; i++)
  18. {
  19. if (this.fingers[i] != null)
  20. {
  21. this.fingers[i].fingerType = (Finger.FingerType)i;
  22. }
  23. }
  24. }
  25. public override void UpdateHand()
  26. {
  27. this.SetPositions();
  28. }
  29. protected Vector3 GetPalmCenter()
  30. {
  31. Vector3 b = 0.015f * Vector3.Scale(base.GetPalmDirection(), base.transform.lossyScale);
  32. return base.GetPalmPosition() - b;
  33. }
  34. protected void SetPositions()
  35. {
  36. Debug.Log("SkeletalHand.SetPositions()");
  37. for (int i = 0; i < this.fingers.Length; i++)
  38. {
  39. if (this.fingers[i] != null)
  40. {
  41. this.fingers[i].UpdateFinger();
  42. }
  43. }
  44. if (this.palm != null)
  45. {
  46. this.palm.position = this.GetPalmCenter();
  47. this.palm.rotation = base.GetPalmRotation();
  48. }
  49. if (this.wristJoint != null)
  50. {
  51. this.wristJoint.position = base.GetWristPosition();
  52. this.wristJoint.rotation = base.GetPalmRotation();
  53. }
  54. if (this.forearm != null)
  55. {
  56. this.forearm.position = base.GetArmCenter();
  57. this.forearm.rotation = base.GetArmRotation();
  58. }
  59. }
  60. protected const float PALM_CENTER_OFFSET = 0.015f;
  61. }
  62. }