Bone.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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_BONE_H_
  31. #define SPINE_BONE_H_
  32. #include <spine/BoneData.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. struct spSkeleton;
  37. typedef struct spBone spBone;
  38. struct spBone {
  39. spBoneData* const data;
  40. struct spSkeleton* const skeleton;
  41. spBone* const parent;
  42. int childrenCount;
  43. spBone** const children;
  44. float x, y, rotation, scaleX, scaleY, shearX, shearY;
  45. float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY;
  46. int /*bool*/ appliedValid;
  47. float const a, b, worldX;
  48. float const c, d, worldY;
  49. int/*bool*/ sorted;
  50. #ifdef __cplusplus
  51. spBone() :
  52. data(0),
  53. skeleton(0),
  54. parent(0),
  55. childrenCount(0), children(0),
  56. x(0), y(0), rotation(0), scaleX(0), scaleY(0),
  57. ax(0), ay(0), arotation(0), ascaleX(0), ascaleY(0), ashearX(0), ashearY(0),
  58. appliedValid(0),
  59. a(0), b(0), worldX(0),
  60. c(0), d(0), worldY(0),
  61. sorted(0) {
  62. }
  63. #endif
  64. };
  65. void spBone_setYDown (int/*bool*/yDown);
  66. int/*bool*/spBone_isYDown ();
  67. /* @param parent May be 0. */
  68. spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent);
  69. void spBone_dispose (spBone* self);
  70. void spBone_setToSetupPose (spBone* self);
  71. void spBone_updateWorldTransform (spBone* self);
  72. void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
  73. float spBone_getWorldRotationX (spBone* self);
  74. float spBone_getWorldRotationY (spBone* self);
  75. float spBone_getWorldScaleX (spBone* self);
  76. float spBone_getWorldScaleY (spBone* self);
  77. float spBone_worldToLocalRotationX (spBone* self);
  78. float spBone_worldToLocalRotationY (spBone* self);
  79. void spBone_rotateWorld (spBone* self, float degrees);
  80. void spBone_updateAppliedTransform (spBone* self);
  81. void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY);
  82. void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY);
  83. #ifdef SPINE_SHORT_NAMES
  84. typedef spBone Bone;
  85. #define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__)
  86. #define Bone_isYDown() spBone_isYDown()
  87. #define Bone_create(...) spBone_create(__VA_ARGS__)
  88. #define Bone_dispose(...) spBone_dispose(__VA_ARGS__)
  89. #define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__)
  90. #define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__)
  91. #define Bone_updateWorldTransformWith(...) spBone_updateWorldTransformWith(__VA_ARGS__)
  92. #define Bone_getWorldRotationX(...) spBone_getWorldRotationX(__VA_ARGS__)
  93. #define Bone_getWorldRotationY(...) spBone_getWorldRotationY(__VA_ARGS__)
  94. #define Bone_getWorldScaleX(...) spBone_getWorldScaleX(__VA_ARGS__)
  95. #define Bone_getWorldScaleY(...) spBone_getWorldScaleY(__VA_ARGS__)
  96. #define Bone_worldToLocalRotationX(...) spBone_worldToLocalRotationX(__VA_ARGS__)
  97. #define Bone_worldToLocalRotationY(...) spBone_worldToLocalRotationY(__VA_ARGS__)
  98. #define Bone_rotateWorld(...) spBone_rotateWorld(__VA_ARGS__)
  99. #define Bone_updateAppliedTransform(...) spBone_updateAppliedTransform(__VA_ARGS__)
  100. #define Bone_worldToLocal(...) spBone_worldToLocal(__VA_ARGS__)
  101. #define Bone_localToWorld(...) spBone_localToWorld(__VA_ARGS__)
  102. #endif
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* SPINE_BONE_H_ */