InputDataHand.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem.InputDeviceHand {
  8. public class InputDataHand: InputDataBase {
  9. public InputDeviceHandPart inputDeviceHandPart;
  10. public InputDataHand(InputDeviceHandPart inputDeviceHandPart) : base(inputDeviceHandPart) {
  11. this.inputDeviceHandPart = inputDeviceHandPart;
  12. }
  13. public class HandsInfo {
  14. /// <summary>
  15. /// 手原始数据
  16. /// </summary>
  17. public float[] originDataMode = new float[256];
  18. public float[] originDataPose = new float[128];
  19. public int handAmount = 0;
  20. /// <summary>
  21. /// 数据里是否存在双手
  22. /// </summary>
  23. public bool handLeftFind = false;
  24. public bool handRightFind = false;
  25. /// <summary>
  26. /// 数据里左右手的index
  27. /// </summary>
  28. public int handLeftIndex = 0;
  29. public int handRighIndex = 0;
  30. /// <summary>
  31. /// 左右手数据存储结构
  32. /// </summary>
  33. public handInfo handLeft;
  34. public handInfo handRight;
  35. }
  36. public bool isFound = false;//是否有数据
  37. public handInfo handInfo;
  38. public virtual void ResetHandData(InputDevicePartType type) {
  39. handInfo.localPosition.x = 0;
  40. handInfo.localPosition.y = 0;
  41. handInfo.localPosition.z = 0;
  42. if(type == InputDevicePartType.HandRight) {
  43. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.One].localPosition = new Vector3(13.3f, -51.9f, 283.2f) / 1000f;
  44. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Two].localPosition = new Vector3(26.3f, -58.6f, 273.4f) / 1000f;
  45. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Three].localPosition = new Vector3(41.4f, -66.1f, 266.9f) / 1000f;
  46. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Four].localPosition = new Vector3(92.9f, -78.0f, 260.9f) / 1000f;
  47. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.One].localPosition = new Vector3(8.5f, 8.1f, 300.0f) / 1000f;
  48. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Two].localPosition = new Vector3(18.4f, 4.1f, 289.7f) / 1000f;
  49. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Three].localPosition = new Vector3(30.9f, -6.8f, 279.0f) / 1000f;
  50. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Four].localPosition = new Vector3(51.5f, -22.4f, 267.4f) / 1000f;
  51. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.One].localPosition = new Vector3(23.8f, 27.0f, 321.9f) / 1000f;
  52. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Two].localPosition = new Vector3(35.6f, 20.0f, 310.6f) / 1000f;
  53. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Three].localPosition = new Vector3(51.2f, 8.7f, 293.9f) / 1000f;
  54. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Four].localPosition = new Vector3(65.9f, -10.9f, 282.6f) / 1000f;
  55. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.One].localPosition = new Vector3(42.4f, 18.1f, 331.2f) / 1000f;
  56. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Two].localPosition = new Vector3(51.8f, 12.2f, 322.2f) / 1000f;
  57. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Three].localPosition = new Vector3(66.0f, 3.8f, 308.3f) / 1000f;
  58. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Four].localPosition = new Vector3(79.1f, -12.5f, 296.5f) / 1000f;
  59. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.One].localPosition = new Vector3(62.2f, 2.9f, 341.0f) / 1000f;
  60. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Two].localPosition = new Vector3(70.2f, -2.0f, 333.9f) / 1000f;
  61. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Three].localPosition = new Vector3(82.0f, -10.0f, 322.7f) / 1000f;
  62. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Four].localPosition = new Vector3(92.1f, -23.5f, 310.2f) / 1000f;
  63. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Five].localPosition = new Vector3(105.6f, -73.9f, 269.9f) / 1000f;
  64. } else if(type == InputDevicePartType.HandLeft) {
  65. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.One].localPosition = new Vector3(-56.1f, -45.2f, 297.1f) / 1000f;
  66. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Two].localPosition = new Vector3(-76.5f, -49.0f, 289.2f) / 1000f;
  67. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Three].localPosition = new Vector3(-95.2f, -54.3f, 283.2f) / 1000f;
  68. handInfo.finger[(int)FINGER.thumb].joint[(int)JOINT.Four].localPosition = new Vector3(-146.3f, -60.3f, 281.8f) / 1000f;
  69. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.One].localPosition = new Vector3(-49.3f, 10.4f, 326.8f) / 1000f;
  70. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Two].localPosition = new Vector3(-61.6f, 9.0f, 318.4f) / 1000f;
  71. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Three].localPosition = new Vector3(-79.6f, 1.5f, 307.1f) / 1000f;
  72. handInfo.finger[(int)FINGER.forefinger].joint[(int)JOINT.Four].localPosition = new Vector3(-99.5f, -8.3f, 296.9f) / 1000f;
  73. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.One].localPosition = new Vector3(-62.0f, 24.6f, 352.0f) / 1000f;
  74. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Two].localPosition = new Vector3(-75.8f, 20.4f, 341.9f) / 1000f;
  75. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Three].localPosition = new Vector3(-93.5f, 13.7f, 328.5f) / 1000f;
  76. handInfo.finger[(int)FINGER.middle].joint[(int)JOINT.Four].localPosition = new Vector3(-113.8f, -2.1f, 315.1f) / 1000f;
  77. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.One].localPosition = new Vector3(-77.2f, 14.6f, 364.6f) / 1000f;
  78. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Two].localPosition = new Vector3(-88.5f, 11.6f, 355.6f) / 1000f;
  79. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Three].localPosition = new Vector3(-105.7f, 5.6f, 344.3f) / 1000f;
  80. handInfo.finger[(int)FINGER.ring].joint[(int)JOINT.Four].localPosition = new Vector3(-123.6f, -8.0f, 331.9f) / 1000f;
  81. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.One].localPosition = new Vector3(-97.7f, -3.4f, 371.5f) / 1000f;
  82. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Two].localPosition = new Vector3(-106.5f, -5.9f, 366.0f) / 1000f;
  83. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Three].localPosition = new Vector3(-120.1f, -11.3f, 357.0f) / 1000f;
  84. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Four].localPosition = new Vector3(-134.8f, -22.3f, 344.1f) / 1000f;
  85. handInfo.finger[(int)FINGER.small].joint[(int)JOINT.Five].localPosition = new Vector3(-156.3f, -59.8f, 294.4f) / 1000f;
  86. }
  87. }
  88. }
  89. }