animate.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. return {
  2. tag = 'controller-models',
  3. summary = 'Animate a model to match its Device input state.',
  4. description = [[
  5. Animates a model to match its input state. The buttons and joysticks on a controller will move
  6. as they're pressed/moved and hand models will move to match hand tracking joints.
  7. The model must have been created using `lovr.headset.newModel` with the `animated` flag set to
  8. `true`.
  9. ]],
  10. arguments = {
  11. device = {
  12. type = 'Device',
  13. default = [['head']],
  14. description = 'The device to use for the animation data.'
  15. },
  16. model = {
  17. type = 'Model',
  18. description = 'The model to animate.'
  19. }
  20. },
  21. returns = {
  22. success = {
  23. type = 'boolean',
  24. description = [[
  25. Whether the animation was applied successfully to the Model. If the Model was not
  26. compatible or animation data for the device was not available, this will be `false`.
  27. ]]
  28. }
  29. },
  30. variants = {
  31. {
  32. arguments = { 'model' },
  33. returns = { 'success' }
  34. },
  35. {
  36. deprecated = true,
  37. arguments = { 'device', 'model' },
  38. returns = { 'success' }
  39. }
  40. },
  41. notes = [[
  42. It's possible to animate a custom hand model by retargeting joint poses, see the
  43. `Interaction/Custom_Hand_Rig` example.
  44. ]],
  45. example = [[
  46. function lovr.load()
  47. models = {
  48. left = lovr.headset.newModel('hand/left'),
  49. right = lovr.headset.newModel('hand/right')
  50. }
  51. end
  52. function lovr.draw(pass)
  53. for hand, model in pairs(models) do
  54. if lovr.headset.isTracked(hand) then
  55. lovr.headset.animate(model)
  56. pass:draw(model, mat4(lovr.headset.getPose(hand)))
  57. end
  58. end
  59. if not next(models) then
  60. pass:text('No models loaded', 0, 1.7, -1, .1)
  61. end
  62. end
  63. ]],
  64. related = {
  65. 'lovr.headset.newModel',
  66. 'Model:animate'
  67. }
  68. }