PXR_HandPoseConfig.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. using System;
  12. using System.Collections.Generic;
  13. using UnityEngine;
  14. namespace Unity.XR.PXR
  15. {
  16. [Serializable]
  17. public class PXR_HandPoseConfig : ScriptableObject
  18. {
  19. [DisplayOnly]
  20. public ShapesRecognizer shapesRecognizer;
  21. [DisplayOnly]
  22. public BonesRecognizer bonesRecognizer;
  23. [DisplayOnly]
  24. public TransRecognizer transRecognizer;
  25. }
  26. [Serializable]
  27. public class ShapesRecognizer
  28. {
  29. public Finger thumb = new Finger(HandFinger.Thumb);
  30. public Finger index = new Finger(HandFinger.Index);
  31. public Finger middle = new Finger(HandFinger.Middle);
  32. public Finger ring = new Finger(HandFinger.Ring);
  33. public Finger pinky = new Finger(HandFinger.Pinky);
  34. public float holdDuration = 0.09f;
  35. [Serializable]
  36. public class Finger
  37. {
  38. [HideInInspector]
  39. public HandFinger handFinger;
  40. public Flexion flexion;
  41. public Curl curl;
  42. public Abduction abduction;
  43. public FingerConfigs fingerConfigs;
  44. public Finger(HandFinger finger)
  45. {
  46. handFinger = finger;
  47. flexion = Flexion.Any;
  48. curl = Curl.Any;
  49. abduction = Abduction.Any;
  50. fingerConfigs = new FingerConfigs(finger);
  51. }
  52. }
  53. [Serializable]
  54. public class FingerConfigs
  55. {
  56. public RangeConfigs flexionConfigs;
  57. public RangeConfigs curlConfigs;
  58. public RangeConfigsAbduction abductionConfigs;
  59. public FingerConfigs(HandFinger finger)
  60. {
  61. flexionConfigs = new RangeConfigs(flexionMin, flexionMax, defaultFlexionWidth);
  62. if (finger == HandFinger.Thumb)
  63. {
  64. curlConfigs = new RangeConfigs(curlThumbMin, curlThumbMax, defaultCurlWidth);
  65. abductionConfigs = new RangeConfigsAbduction(abductionThumbMid, abductionThumbWidth);
  66. }
  67. else
  68. {
  69. curlConfigs = new RangeConfigs(curlMin, curlMax, defaultCurlWidth);
  70. abductionConfigs = new RangeConfigsAbduction(abductionMid, abductionWidth);
  71. }
  72. }
  73. }
  74. public enum ShapeType
  75. {
  76. flexion,
  77. curl,
  78. abduction
  79. }
  80. public enum Flexion
  81. {
  82. Any,
  83. Open,
  84. Close,
  85. //Custom
  86. }
  87. public enum Curl
  88. {
  89. Any,
  90. Open,
  91. Close,
  92. //Custom
  93. }
  94. public enum Abduction
  95. {
  96. Any,
  97. Open,
  98. Close,
  99. }
  100. [Serializable]
  101. public class RangeConfigs
  102. {
  103. public float min;
  104. public float max;
  105. public float width;
  106. public RangeConfigs(float n, float m, float w)
  107. {
  108. min = n;
  109. max = m;
  110. width =w;
  111. }
  112. }
  113. [Serializable]
  114. public class RangeConfigsAbduction
  115. {
  116. public float mid;
  117. public float width;
  118. public RangeConfigsAbduction(float m, float w)
  119. {
  120. mid = m;
  121. width = w;
  122. }
  123. }
  124. public const float defaultFlexionWidth = 10f;
  125. public const float flexionThumbOpenMin = 155f;
  126. public const float flexionThumbOpenMax = 180f;
  127. public const float flexionThumbCloseMin = 90f;
  128. public const float flexionThumbCloseMax = 120f;
  129. public const float flexionOpenMin = 144f;
  130. public const float flexionOpenMax = 180f;
  131. public const float flexionCloseMin = 90f;
  132. public const float flexionCloseMax = 126f;
  133. public const float flexionMin = 90f;
  134. public const float flexionMax = 180f;
  135. public const float defaultCurlWidth = 20f;
  136. public const float curlThumbOpenMin = 90f;
  137. public const float curlThumbOpenMax = 180f;
  138. public const float curlThumbCloseMin = 45f;
  139. public const float curlThumbCloseMax = 90f;
  140. public const float curlThumbMin = 45f;
  141. public const float curlThumbMax = 180f;
  142. public const float curlOpenMin = 107f;
  143. public const float curlOpenMax = 180f;
  144. public const float curlCloseMin = 0f;
  145. public const float curlCloseMax = 73f;
  146. public const float curlMin = 0f;
  147. public const float curlMax = 180f;
  148. public const float abductionThumbMid = 13f;
  149. public const float abductionThumbWidth = 6f;
  150. public const float abductionMid = 10f;
  151. public const float abductionWidth = 6f;
  152. public const float abductionMin = 0f;
  153. public const float abductionMax = 90f;
  154. }
  155. [Serializable]
  156. public class BonesRecognizer
  157. {
  158. public List<BonesGroup> Bones = new List<BonesGroup>();
  159. public float holdDuration = 0.022f;
  160. [Serializable]
  161. public class BonesGroup
  162. {
  163. [LabelAttribute("Joint 1")]
  164. public HandBones bone1 = HandBones.Wrist;
  165. [LabelAttribute("Joint 2")]
  166. public HandBones bone2 = HandBones.Wrist;
  167. public float distance = 0.025f;
  168. [LabelAttribute("Margin")]
  169. public float thresholdWidth = 0.003f;
  170. [HideInInspector]
  171. public bool activeState;
  172. }
  173. public enum HandBones
  174. {
  175. Palm = 0,
  176. Wrist = 1,
  177. Thumb_Metacarpal = 2,
  178. Thumb_Proximal = 3,
  179. Thumb_Distal = 4,
  180. Thumb_Tip = 5,
  181. Index_Metacarpal = 6,
  182. Index_Proximal = 7,
  183. Index_Intermediate = 8,
  184. Index_Distal = 9,
  185. Index_Tip = 10,
  186. Middle_Metacarpal = 11,
  187. Middle_Proximal = 12,
  188. Middle_Intermediate = 13,
  189. Middle_Distal = 14,
  190. Middle_Tip = 15,
  191. Ring_Metacarpal = 16,
  192. Ring_Proximal = 17,
  193. Ring_Intermediate = 18,
  194. Ring_Distal = 19,
  195. Ring_Tip = 20,
  196. Little_Metacarpal = 21,
  197. Little_Proximal = 22,
  198. Little_Intermediate = 23,
  199. Little_Distal = 24,
  200. Little_Tip = 25
  201. }
  202. }
  203. [Serializable]
  204. public class TransRecognizer
  205. {
  206. public TrackAxis trackAxis;
  207. public SpaceType spaceType;
  208. public TrackTarget trackTarget;
  209. public enum SpaceType
  210. {
  211. WorldSpace,
  212. LocalXY,
  213. LocalYZ,
  214. LocalXZ
  215. }
  216. public enum TrackAxis
  217. {
  218. Fingers, Palm, Thumb
  219. }
  220. public enum TrackTarget
  221. {
  222. TowardsFace,
  223. AwayFromFace,
  224. WorldUp,
  225. WorldDown,
  226. }
  227. public float angleThreshold = 35f;
  228. public float thresholdWidth = 10f;
  229. public float holdDuration = 0.022f;
  230. }
  231. public class DisplayOnly : PropertyAttribute { }
  232. public class LabelAttribute : PropertyAttribute
  233. {
  234. public string name;
  235. public LabelAttribute(string name)
  236. {
  237. this.name = name;
  238. }
  239. }
  240. }
粤ICP备19079148号