SkeletonData.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /******************************************************************************
  2. * Spine Runtimes Software License v2.5
  3. *
  4. * Copyright (c) 2013-2016, Esoteric Software
  5. * All rights reserved.
  6. *
  7. * You are granted a perpetual, non-exclusive, non-sublicensable, and
  8. * non-transferable license to use, install, execute, and perform the Spine
  9. * Runtimes software and derivative works solely for personal or internal
  10. * use. Without the written permission of Esoteric Software (see Section 2 of
  11. * the Spine Software License Agreement), you may not (a) modify, translate,
  12. * adapt, or develop new applications using the Spine Runtimes or otherwise
  13. * create derivative works or improvements of the Spine Runtimes or (b) remove,
  14. * delete, alter, or obscure any trademarks or any copyright, trademark, patent,
  15. * or other intellectual property or proprietary rights notices on or in the
  16. * Software, including any copy thereof. Redistributions in binary or source
  17. * form must include this license and terms.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
  20. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  22. * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
  25. * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  26. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. *****************************************************************************/
  30. #ifndef Spine_SkeletonData_h
  31. #define Spine_SkeletonData_h
  32. #include <spine/Vector.h>
  33. #include <spine/SpineString.h>
  34. namespace spine {
  35. class BoneData;
  36. class SlotData;
  37. class Skin;
  38. class EventData;
  39. class Animation;
  40. class IkConstraintData;
  41. class TransformConstraintData;
  42. class PathConstraintData;
  43. /// Stores the setup pose and all of the stateless data for a skeleton.
  44. class SP_API SkeletonData : public SpineObject {
  45. friend class SkeletonBinary;
  46. friend class SkeletonJson;
  47. friend class Skeleton;
  48. public:
  49. SkeletonData();
  50. ~SkeletonData();
  51. /// Finds a bone by comparing each bone's name.
  52. /// It is more efficient to cache the results of this method than to call it multiple times.
  53. /// @return May be NULL.
  54. BoneData *findBone(const String &boneName);
  55. /// @return -1 if the bone was not found.
  56. int findBoneIndex(const String &boneName);
  57. /// @return May be NULL.
  58. SlotData *findSlot(const String &slotName);
  59. /// @return -1 if the slot was not found.
  60. int findSlotIndex(const String &slotName);
  61. /// @return May be NULL.
  62. Skin *findSkin(const String &skinName);
  63. /// @return May be NULL.
  64. spine::EventData *findEvent(const String &eventDataName);
  65. /// @return May be NULL.
  66. Animation *findAnimation(const String &animationName);
  67. /// @return May be NULL.
  68. IkConstraintData *findIkConstraint(const String &constraintName);
  69. /// @return May be NULL.
  70. TransformConstraintData *findTransformConstraint(const String &constraintName);
  71. /// @return May be NULL.
  72. PathConstraintData *findPathConstraint(const String &constraintName);
  73. /// @return -1 if the path constraint was not found.
  74. int findPathConstraintIndex(const String &pathConstraintName);
  75. const String &getName();
  76. void setName(const String &inValue);
  77. /// The skeleton's bones, sorted parent first. The root bone is always the first bone.
  78. Vector<BoneData *> &getBones();
  79. Vector<SlotData *> &getSlots();
  80. /// All skins, including the default skin.
  81. Vector<Skin *> &getSkins();
  82. /// The skeleton's default skin.
  83. /// By default this skin contains all attachments that were not in a skin in Spine.
  84. ///
  85. /// @return May be NULL.
  86. Skin *getDefaultSkin();
  87. void setDefaultSkin(Skin *inValue);
  88. Vector<spine::EventData *> &getEvents();
  89. Vector<Animation *> &getAnimations();
  90. Vector<IkConstraintData *> &getIkConstraints();
  91. Vector<TransformConstraintData *> &getTransformConstraints();
  92. Vector<PathConstraintData *> &getPathConstraints();
  93. float getWidth();
  94. void setWidth(float inValue);
  95. float getHeight();
  96. void setHeight(float inValue);
  97. /// The Spine version used to export this data, or NULL.
  98. const String &getVersion();
  99. void setVersion(const String &inValue);
  100. const String &getHash();
  101. void setHash(const String &inValue);
  102. const String &getImagesPath();
  103. void setImagesPath(const String &inValue);
  104. /// The dopesheet FPS in Spine. Available only when nonessential data was exported.
  105. float getFps();
  106. void setFps(float inValue);
  107. private:
  108. String _name;
  109. Vector<BoneData *> _bones; // Ordered parents first
  110. Vector<SlotData *> _slots; // Setup pose draw order.
  111. Vector<Skin *> _skins;
  112. Skin *_defaultSkin;
  113. Vector<EventData *> _events;
  114. Vector<Animation *> _animations;
  115. Vector<IkConstraintData *> _ikConstraints;
  116. Vector<TransformConstraintData *> _transformConstraints;
  117. Vector<PathConstraintData *> _pathConstraints;
  118. float _width, _height;
  119. String _version;
  120. String _hash;
  121. // Nonessential.
  122. float _fps;
  123. String _imagesPath;
  124. };
  125. }
  126. #endif /* Spine_SkeletonData_h */