Skeleton.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /******************************************************************************
  2. * Spine Runtimes Software License
  3. * Version 2
  4. *
  5. * Copyright (c) 2013, Esoteric Software
  6. * All rights reserved.
  7. *
  8. * You are granted a perpetual, non-exclusive, non-sublicensable and
  9. * non-transferable license to install, execute and perform the Spine Runtimes
  10. * Software (the "Software") solely for internal use. Without the written
  11. * permission of Esoteric Software, you may not (a) modify, translate, adapt or
  12. * otherwise create derivative works, improvements of the Software or develop
  13. * new applications using the Software or (b) remove, delete, alter or obscure
  14. * any trademarks or any copyright, trademark, patent or other intellectual
  15. * property or proprietary rights notices on or in the Software, including
  16. * any copy thereof. Redistributions in binary or source form must include
  17. * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE
  18. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  19. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *****************************************************************************/
  28. #ifndef SPINE_SKELETON_H_
  29. #define SPINE_SKELETON_H_
  30. #include <spine/SkeletonData.h>
  31. #include <spine/Slot.h>
  32. #include <spine/Skin.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. typedef struct spSkeleton spSkeleton;
  37. struct spSkeleton {
  38. spSkeletonData* const data;
  39. int boneCount;
  40. spBone** bones;
  41. spBone* const root;
  42. int slotCount;
  43. spSlot** slots;
  44. spSlot** drawOrder;
  45. spSkin* const skin;
  46. float r, g, b, a;
  47. float time;
  48. int/*bool*/flipX, flipY;
  49. float x, y;
  50. };
  51. spSkeleton* spSkeleton_create (spSkeletonData* data);
  52. void spSkeleton_dispose (spSkeleton* self);
  53. void spSkeleton_updateWorldTransform (const spSkeleton* self);
  54. void spSkeleton_setToSetupPose (const spSkeleton* self);
  55. void spSkeleton_setBonesToSetupPose (const spSkeleton* self);
  56. void spSkeleton_setSlotsToSetupPose (const spSkeleton* self);
  57. /* Returns 0 if the bone was not found. */
  58. spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName);
  59. /* Returns -1 if the bone was not found. */
  60. int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName);
  61. /* Returns 0 if the slot was not found. */
  62. spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName);
  63. /* Returns -1 if the slot was not found. */
  64. int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName);
  65. /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
  66. * attached if the corresponding attachment from the old skin was attached.
  67. * @param skin May be 0.*/
  68. void spSkeleton_setSkin (spSkeleton* self, spSkin* skin);
  69. /* Returns 0 if the skin was not found. See spSkeleton_setSkin.
  70. * @param skinName May be 0. */
  71. int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName);
  72. /* Returns 0 if the slot or attachment was not found. */
  73. spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName);
  74. /* Returns 0 if the slot or attachment was not found. */
  75. spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName);
  76. /* Returns 0 if the slot or attachment was not found. */
  77. int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName);
  78. void spSkeleton_update (spSkeleton* self, float deltaTime);
  79. #ifdef SPINE_SHORT_NAMES
  80. typedef spSkeleton Skeleton;
  81. #define Skeleton_create(...) spSkeleton_create(__VA_ARGS__)
  82. #define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__)
  83. #define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__)
  84. #define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__)
  85. #define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__)
  86. #define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__)
  87. #define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__)
  88. #define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__)
  89. #define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__)
  90. #define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__)
  91. #define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__)
  92. #define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__)
  93. #define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__)
  94. #define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__)
  95. #define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__)
  96. #define Skeleton_update(...) spSkeleton_update(__VA_ARGS__)
  97. #endif
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* SPINE_SKELETON_H_*/