SkeletonData.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 Spine_SkeletonData_h
  30. #define Spine_SkeletonData_h
  31. #include <spine/Vector.h>
  32. #include <spine/SpineString.h>
  33. namespace spine {
  34. class BoneData;
  35. class SlotData;
  36. class Skin;
  37. class EventData;
  38. class Animation;
  39. class IkConstraintData;
  40. class TransformConstraintData;
  41. class PathConstraintData;
  42. /// Stores the setup pose and all of the stateless data for a skeleton.
  43. class SP_API SkeletonData : public SpineObject {
  44. friend class SkeletonBinary;
  45. friend class SkeletonJson;
  46. friend class Skeleton;
  47. public:
  48. SkeletonData();
  49. ~SkeletonData();
  50. /// Finds a bone by comparing each bone's name.
  51. /// It is more efficient to cache the results of this method than to call it multiple times.
  52. /// @return May be NULL.
  53. BoneData *findBone(const String &boneName);
  54. /// @return -1 if the bone was not found.
  55. int findBoneIndex(const String &boneName);
  56. /// @return May be NULL.
  57. SlotData *findSlot(const String &slotName);
  58. /// @return -1 if the slot was not found.
  59. int findSlotIndex(const String &slotName);
  60. /// @return May be NULL.
  61. Skin *findSkin(const String &skinName);
  62. /// @return May be NULL.
  63. spine::EventData *findEvent(const String &eventDataName);
  64. /// @return May be NULL.
  65. Animation *findAnimation(const String &animationName);
  66. /// @return May be NULL.
  67. IkConstraintData *findIkConstraint(const String &constraintName);
  68. /// @return May be NULL.
  69. TransformConstraintData *findTransformConstraint(const String &constraintName);
  70. /// @return May be NULL.
  71. PathConstraintData *findPathConstraint(const String &constraintName);
  72. /// @return -1 if the path constraint was not found.
  73. int findPathConstraintIndex(const String &pathConstraintName);
  74. const String &getName();
  75. void setName(const String &inValue);
  76. /// The skeleton's bones, sorted parent first. The root bone is always the first bone.
  77. Vector<BoneData *> &getBones();
  78. Vector<SlotData *> &getSlots();
  79. /// All skins, including the default skin.
  80. Vector<Skin *> &getSkins();
  81. /// The skeleton's default skin.
  82. /// By default this skin contains all attachments that were not in a skin in Spine.
  83. /// @return May be NULL.
  84. Skin *getDefaultSkin();
  85. void setDefaultSkin(Skin *inValue);
  86. Vector<spine::EventData *> &getEvents();
  87. Vector<Animation *> &getAnimations();
  88. Vector<IkConstraintData *> &getIkConstraints();
  89. Vector<TransformConstraintData *> &getTransformConstraints();
  90. Vector<PathConstraintData *> &getPathConstraints();
  91. float getX();
  92. void setX(float inValue);
  93. float getY();
  94. void setY(float inValue);
  95. float getWidth();
  96. void setWidth(float inValue);
  97. float getHeight();
  98. void setHeight(float inValue);
  99. /// The Spine version used to export this data, or NULL.
  100. const String &getVersion();
  101. void setVersion(const String &inValue);
  102. const String &getHash();
  103. void setHash(const String &inValue);
  104. const String &getImagesPath();
  105. void setImagesPath(const String &inValue);
  106. const String &getAudioPath();
  107. void setAudioPath(const String &inValue);
  108. /// The dopesheet FPS in Spine. Available only when nonessential data was exported.
  109. float getFps();
  110. void setFps(float inValue);
  111. private:
  112. String _name;
  113. Vector<BoneData *> _bones; // Ordered parents first
  114. Vector<SlotData *> _slots; // Setup pose draw order.
  115. Vector<Skin *> _skins;
  116. Skin *_defaultSkin;
  117. Vector<EventData *> _events;
  118. Vector<Animation *> _animations;
  119. Vector<IkConstraintData *> _ikConstraints;
  120. Vector<TransformConstraintData *> _transformConstraints;
  121. Vector<PathConstraintData *> _pathConstraints;
  122. float _x, _y, _width, _height;
  123. String _version;
  124. String _hash;
  125. Vector<char*> _strings;
  126. // Nonessential.
  127. float _fps;
  128. String _imagesPath;
  129. String _audioPath;
  130. };
  131. }
  132. #endif /* Spine_SkeletonData_h */