MeshAttachment.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated January 1, 2020. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2020, 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_MeshAttachment_h
  30. #define Spine_MeshAttachment_h
  31. #include <spine/VertexAttachment.h>
  32. #include <spine/Vector.h>
  33. #include <spine/Color.h>
  34. #include <spine/HasRendererObject.h>
  35. namespace spine {
  36. /// Attachment that displays a texture region using a mesh.
  37. class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
  38. friend class SkeletonBinary;
  39. friend class SkeletonJson;
  40. friend class AtlasAttachmentLoader;
  41. RTTI_DECL
  42. public:
  43. explicit MeshAttachment(const String& name);
  44. virtual ~MeshAttachment();
  45. void updateUVs();
  46. int getHullLength();
  47. void setHullLength(int inValue);
  48. Vector<float>& getRegionUVs();
  49. /// The UV pair for each vertex, normalized within the entire texture. See also MeshAttachment::updateUVs
  50. Vector<float>& getUVs();
  51. Vector<unsigned short>& getTriangles();
  52. Color& getColor();
  53. const String& getPath();
  54. void setPath(const String& inValue);
  55. float getRegionU();
  56. void setRegionU(float inValue);
  57. float getRegionV();
  58. void setRegionV(float inValue);
  59. float getRegionU2();
  60. void setRegionU2(float inValue);
  61. float getRegionV2();
  62. void setRegionV2(float inValue);
  63. bool getRegionRotate();
  64. void setRegionRotate(bool inValue);
  65. int getRegionDegrees();
  66. void setRegionDegrees(int inValue);
  67. float getRegionOffsetX();
  68. void setRegionOffsetX(float inValue);
  69. // Pixels stripped from the bottom left, unrotated.
  70. float getRegionOffsetY();
  71. void setRegionOffsetY(float inValue);
  72. float getRegionWidth();
  73. void setRegionWidth(float inValue);
  74. // Unrotated, stripped size.
  75. float getRegionHeight();
  76. void setRegionHeight(float inValue);
  77. float getRegionOriginalWidth();
  78. void setRegionOriginalWidth(float inValue);
  79. // Unrotated, unstripped size.
  80. float getRegionOriginalHeight();
  81. void setRegionOriginalHeight(float inValue);
  82. MeshAttachment* getParentMesh();
  83. void setParentMesh(MeshAttachment* inValue);
  84. // Nonessential.
  85. Vector<unsigned short>& getEdges();
  86. float getWidth();
  87. void setWidth(float inValue);
  88. float getHeight();
  89. void setHeight(float inValue);
  90. virtual Attachment* copy();
  91. MeshAttachment* newLinkedMesh();
  92. private:
  93. float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
  94. MeshAttachment* _parentMesh;
  95. Vector<float> _uvs;
  96. Vector<float> _regionUVs;
  97. Vector<unsigned short> _triangles;
  98. Vector<unsigned short> _edges;
  99. String _path;
  100. float _regionU;
  101. float _regionV;
  102. float _regionU2;
  103. float _regionV2;
  104. float _width;
  105. float _height;
  106. Color _color;
  107. int _hullLength;
  108. bool _regionRotate;
  109. int _regionDegrees;
  110. };
  111. }
  112. #endif /* Spine_MeshAttachment_h */