SpineSkeleton.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated January 1, 2020. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2020, 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. #ifndef GODOT_SPINESKELETON_H
  30. #define GODOT_SPINESKELETON_H
  31. #include "core/variant_parser.h"
  32. #include <spine/spine.h>
  33. #include "SpineSkeletonDataResource.h"
  34. #include "SpineBone.h"
  35. #include "SpineSlot.h"
  36. class SpineSprite;
  37. class SpineSkeleton : public Reference{
  38. GDCLASS(SpineSkeleton, Reference);
  39. protected:
  40. static void _bind_methods();
  41. private:
  42. spine::Skeleton *skeleton;
  43. bool spine_object;
  44. SpineSprite *the_sprite;
  45. public:
  46. SpineSkeleton();
  47. ~SpineSkeleton();
  48. void load_skeleton(Ref<SpineSkeletonDataResource> sd);
  49. inline void set_spine_object(spine::Skeleton *s){
  50. skeleton = s;
  51. spine_object = true;
  52. }
  53. inline spine::Skeleton *get_spine_object(){
  54. return skeleton;
  55. }
  56. void set_spine_sprite(SpineSprite *s);
  57. void update_world_transform();
  58. void set_to_setup_pose();
  59. void set_bones_to_setup_pose();
  60. void set_slots_to_setup_pose();
  61. Ref<SpineBone> find_bone(const String &name);
  62. Ref<SpineSlot> find_slot(const String &name);
  63. void set_skin_by_name(const String &skin_name);
  64. void set_skin(Ref<SpineSkin> new_skin);
  65. Ref<SpineAttachment> get_attachment_by_slot_name(const String &slot_name, const String &attachment_name);
  66. Ref<SpineAttachment> get_attachment_by_slot_index(int slot_index, const String &attachment_name);
  67. void set_attachment(const String &slot_name, const String &attachment_name);
  68. Ref<SpineIkConstraint> find_ik_constraint(const String &constraint_name);
  69. Ref<SpineTransformConstraint> find_transform_constraint(const String &constraint_name);
  70. Ref<SpinePathConstraint> find_path_constraint(const String &constraint_name);
  71. void update(float delta);
  72. Dictionary get_bounds();
  73. Ref<SpineBone> get_root_bone();
  74. Ref<SpineSkeletonDataResource> get_data() const;
  75. Array get_bones();
  76. Array get_slots();
  77. Array get_draw_orders();
  78. Array get_ik_constraints();
  79. Array get_path_constraints();
  80. Array get_transform_constraints();
  81. Ref<SpineSkin> get_skin();
  82. Color get_color();
  83. void set_color(Color v);
  84. float get_time();
  85. void set_time(float v);
  86. void set_position(Vector2 pos);
  87. float get_x();
  88. void set_x(float v);
  89. float get_y();
  90. void set_y(float v);
  91. float get_scale_x();
  92. void set_scale_x(float v);
  93. float get_scale_y();
  94. void set_scale_y(float v);
  95. };
  96. #endif //GODOT_SPINESKELETON_H