RegionAttachment.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated September 24, 2021. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2021, 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_RegionAttachment_h
  30. #define Spine_RegionAttachment_h
  31. #include <spine/Attachment.h>
  32. #include <spine/Vector.h>
  33. #include <spine/Color.h>
  34. #include <spine/Sequence.h>
  35. #include <spine/TextureRegion.h>
  36. #include <spine/HasRendererObject.h>
  37. #define NUM_UVS 8
  38. namespace spine {
  39. class Bone;
  40. /// Attachment that displays a texture region.
  41. class SP_API RegionAttachment : public Attachment {
  42. friend class SkeletonBinary;
  43. friend class SkeletonJson;
  44. friend class AtlasAttachmentLoader;
  45. RTTI_DECL
  46. public:
  47. explicit RegionAttachment(const String &name);
  48. virtual ~RegionAttachment();
  49. void updateRegion();
  50. /// Transforms the attachment's four vertices to world coordinates.
  51. /// @param slot The parent slot.
  52. /// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
  53. /// @param offset The worldVertices index to begin writing values.
  54. /// @param stride The number of worldVertices entries between the value pairs written.
  55. void computeWorldVertices(Slot &slot, float *worldVertices, size_t offset, size_t stride = 2);
  56. void computeWorldVertices(Slot &slot, Vector<float> &worldVertices, size_t offset, size_t stride = 2);
  57. float getX();
  58. void setX(float inValue);
  59. float getY();
  60. void setY(float inValue);
  61. float getRotation();
  62. void setRotation(float inValue);
  63. float getScaleX();
  64. void setScaleX(float inValue);
  65. float getScaleY();
  66. void setScaleY(float inValue);
  67. float getWidth();
  68. void setWidth(float inValue);
  69. float getHeight();
  70. void setHeight(float inValue);
  71. Color &getColor();
  72. const String &getPath();
  73. void setPath(const String &inValue);
  74. TextureRegion *getRegion();
  75. void setRegion(TextureRegion *region);
  76. Sequence *getSequence();
  77. void setSequence(Sequence *sequence);
  78. Vector<float> &getOffset();
  79. Vector<float> &getUVs();
  80. virtual Attachment *copy();
  81. private:
  82. static const int BLX;
  83. static const int BLY;
  84. static const int ULX;
  85. static const int ULY;
  86. static const int URX;
  87. static const int URY;
  88. static const int BRX;
  89. static const int BRY;
  90. float _x, _y, _rotation, _scaleX, _scaleY, _width, _height;
  91. Vector<float> _vertexOffset;
  92. Vector<float> _uvs;
  93. String _path;
  94. Color _color;
  95. TextureRegion *_region;
  96. Sequence *_sequence;
  97. };
  98. }
  99. #endif /* Spine_RegionAttachment_h */