SpineAnimationTrack.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated April 5, 2025. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2025, Esoteric Software LLC
  6. *
  7. * Integration of the Spine Runtimes into software or otherwise creating
  8. * derivative works of the Spine Runtimes is permitted under the terms and
  9. * conditions of Section 2 of the Spine Editor License Agreement:
  10. * http://esotericsoftware.com/spine-editor-license
  11. *
  12. * Otherwise, it is permitted to integrate the Spine Runtimes into software
  13. * or otherwise create derivative works of the Spine Runtimes (collectively,
  14. * "Products"), provided that each user of the Products must obtain their own
  15. * Spine Editor license and redistribution of the Products in any form must
  16. * include this license and copyright notice.
  17. *
  18. * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. #pragma once
  30. #ifndef SPINE_GODOT_EXTENSION
  31. #include "SpineSprite.h"
  32. #include "scene/animation/animation_player.h"
  33. #include "scene/resources/animation.h"
  34. class SpineAnimationTrack : public Node {
  35. GDCLASS(SpineAnimationTrack, Node)
  36. protected:
  37. // These are not exposed in the inspector, see SpineAnimationTrackInspectorPlugin.
  38. // Instead, they are are keyed by the animations created in setup_animation_player
  39. // and primarily used for animation player editor support like scrubbing and playing
  40. // back the .
  41. String animation_name;
  42. bool loop;
  43. bool animation_changed;
  44. // These can be set by the user.
  45. int track_index;
  46. float mix_duration;
  47. bool hold_previous;
  48. bool reverse;
  49. bool shortest_rotation;
  50. float time_scale;
  51. float alpha;
  52. float mix_attachment_threshold;
  53. float mix_draw_order_threshold;
  54. SpineConstant::MixBlend mix_blend;
  55. bool blend_tree_mode;
  56. bool debug;
  57. SpineSprite *sprite;
  58. static void _bind_methods();
  59. void _notification(int what);
  60. AnimationPlayer *find_animation_player();
  61. void setup_animation_player();
  62. static Ref<Animation> create_animation(spine::Animation *animation, bool loop);
  63. void update_animation_state(const Variant &variant_sprite);
  64. public:
  65. SpineAnimationTrack();
  66. void set_animation_name(const String &_animation_name);
  67. String get_animation_name();
  68. void set_animation_time(float _animation_time);
  69. float get_animation_time();
  70. void set_loop(bool _loop);
  71. bool get_loop();
  72. void set_track_index(int _track_index);
  73. int get_track_index();
  74. void set_mix_duration(float _mix_duration);
  75. float get_mix_duration();
  76. void set_hold_previous(bool _hold_previous);
  77. bool get_hold_previous();
  78. void set_reverse(bool _reverse);
  79. bool get_reverse();
  80. void set_shortest_rotation(bool _shortest_rotation);
  81. bool get_shortest_rotation();
  82. void set_time_scale(float _time_scale);
  83. float get_time_scale();
  84. void set_alpha(float _alpha);
  85. float get_alpha();
  86. void set_mix_attachment_threshold(float _mix_attachment_threshold);
  87. float get_mix_attachment_threshold();
  88. void set_mix_draw_order_threshold(float _mix_draw_order_threshold);
  89. float get_mix_draw_order_threshold();
  90. void set_mix_blend(SpineConstant::MixBlend _blend);
  91. SpineConstant::MixBlend get_mix_blend();
  92. void set_blend_tree_mode(bool _blend_tree_mode);
  93. bool get_blend_tree_mode();
  94. void set_debug(bool _debug);
  95. bool get_debug();
  96. };
  97. #endif