RegionAttachment.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_REGIONATTACHMENT_H_
  29. #define SPINE_REGIONATTACHMENT_H_
  30. #include <spine/Attachment.h>
  31. #include <spine/Atlas.h>
  32. #include <spine/Slot.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. typedef enum {
  37. VERTEX_X1 = 0, VERTEX_Y1, VERTEX_X2, VERTEX_Y2, VERTEX_X3, VERTEX_Y3, VERTEX_X4, VERTEX_Y4
  38. } spVertexIndex;
  39. typedef struct spRegionAttachment spRegionAttachment;
  40. struct spRegionAttachment {
  41. spAttachment super;
  42. float x, y, scaleX, scaleY, rotation, width, height;
  43. void* rendererObject;
  44. int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
  45. int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */
  46. int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */
  47. float offset[8];
  48. float uvs[8];
  49. };
  50. spRegionAttachment* spRegionAttachment_create (const char* name);
  51. void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate);
  52. void spRegionAttachment_updateOffset (spRegionAttachment* self);
  53. void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices);
  54. #ifdef SPINE_SHORT_NAMES
  55. typedef spVertexIndex VertexIndex;
  56. typedef spRegionAttachment RegionAttachment;
  57. #define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__)
  58. #define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__)
  59. #define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__)
  60. #define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__)
  61. #endif
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* SPINE_REGIONATTACHMENT_H_ */