getSkeleton.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. return {
  2. tag = 'input',
  3. summary = 'Get skeletal joint poses tracked by a device.',
  4. description = [[
  5. Returns a list of joint poses tracked by a device. Currently, only hand devices are able to
  6. track joints.
  7. ]],
  8. arguments = {
  9. device = {
  10. type = 'Device',
  11. description = 'The Device to query.'
  12. },
  13. t = {
  14. type = 'table',
  15. description = 'A table to fill with the joint poses, instead of allocating a new one.'
  16. }
  17. },
  18. returns = {
  19. poses = {
  20. type = 'table',
  21. description = [[
  22. A list of joint poses for the device. Each pose is a table with 3 numbers for the position
  23. of the joint followed by 4 numbers for the angle/axis orientation of the joint.
  24. ]]
  25. }
  26. },
  27. variants = {
  28. {
  29. arguments = { 'device' },
  30. returns = { 'poses' }
  31. },
  32. {
  33. arguments = { 'device', 't' },
  34. returns = { 'poses' }
  35. }
  36. },
  37. notes = [[
  38. If the Device does not support tracking joints or the poses are unavailable, `nil` is returned.
  39. The joint orientation is similar to the graphics coordinate system: -Z is the forwards
  40. direction, pointing towards the fingertips. The +Y direction is "up", pointing out of the back
  41. of the hand. The +X direction is to the right, perpendicular to X and Z.
  42. Hand joints are returned in the following order:
  43. <table>
  44. <thead>
  45. <tr>
  46. <td colspan="2">Joint</td>
  47. <td>Index</td>
  48. </tr>
  49. </thead>
  50. <tbody>
  51. <tr>
  52. <td colspan="2">Palm</td>
  53. <td>1</td>
  54. </tr>
  55. <tr>
  56. <td colspan="2">Wrist</td>
  57. <td>2</td>
  58. </tr>
  59. <tr>
  60. <td rowspan="4">Thumb</td>
  61. <td>Metacarpal</td>
  62. <td>3</td>
  63. </tr>
  64. <tr>
  65. <td>Proximal</td>
  66. <td>4</td>
  67. </tr>
  68. <tr>
  69. <td>Distal</td>
  70. <td>5</td>
  71. </tr>
  72. <tr>
  73. <td>Tip</td>
  74. <td>6</td>
  75. </tr>
  76. <tr>
  77. <td rowspan="5">Index</td>
  78. <td>Metacarpal</td>
  79. <td>7</td>
  80. </tr>
  81. <tr>
  82. <td>Proximal</td>
  83. <td>8</td>
  84. </tr>
  85. <tr>
  86. <td>Intermediate</td>
  87. <td>9</td>
  88. </tr>
  89. <tr>
  90. <td>Distal</td>
  91. <td>10</td>
  92. </tr>
  93. <tr>
  94. <td>Tip</td>
  95. <td>11</td>
  96. </tr>
  97. <tr>
  98. <td rowspan="5">Middle</td>
  99. <td>Metacarpal</td>
  100. <td>12</td>
  101. </tr>
  102. <tr>
  103. <td>Proximal</td>
  104. <td>13</td>
  105. </tr>
  106. <tr>
  107. <td>Intermediate</td>
  108. <td>14</td>
  109. </tr>
  110. <tr>
  111. <td>Distal</td>
  112. <td>15</td>
  113. </tr>
  114. <tr>
  115. <td>Tip</td>
  116. <td>16</td>
  117. </tr>
  118. <tr>
  119. <td rowspan="5">Ring</td>
  120. <td>Metacarpal</td>
  121. <td>17</td>
  122. </tr>
  123. <tr>
  124. <td>Proximal</td>
  125. <td>18</td>
  126. </tr>
  127. <tr>
  128. <td>Intermediate</td>
  129. <td>19</td>
  130. </tr>
  131. <tr>
  132. <td>Distal</td>
  133. <td>20</td>
  134. </tr>
  135. <tr>
  136. <td>Tip</td>
  137. <td>21</td>
  138. </tr>
  139. <tr>
  140. <td rowspan="5">Pinky</td>
  141. <td>Metacarpal</td>
  142. <td>22</td>
  143. </tr>
  144. <tr>
  145. <td>Proximal</td>
  146. <td>23</td>
  147. </tr>
  148. <tr>
  149. <td>Intermediate</td>
  150. <td>24</td>
  151. </tr>
  152. <tr>
  153. <td>Distal</td>
  154. <td>25</td>
  155. </tr>
  156. <tr>
  157. <td>Tip</td>
  158. <td>26</td>
  159. </tr>
  160. </tbody>
  161. </table>
  162. ]],
  163. example = [[
  164. function lovr.draw()
  165. for _, hand in ipairs({ 'left', 'right' }) do
  166. for _, joint in ipairs(lovr.headset.getSkeleton(hand) or {}) do
  167. lovr.graphics.points(unpack(joint, 1, 3))
  168. end
  169. end
  170. end
  171. ]],
  172. related = {
  173. 'lovr.headset.getPose',
  174. 'lovr.headset.animate'
  175. }
  176. }