polygon_2d.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*************************************************************************/
  2. /* polygon_2d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef POLYGON_2D_H
  31. #define POLYGON_2D_H
  32. #include "scene/2d/node_2d.h"
  33. class Polygon2D : public Node2D {
  34. GDCLASS(Polygon2D, Node2D);
  35. PoolVector<Vector2> polygon;
  36. PoolVector<Vector2> uv;
  37. PoolVector<Color> vertex_colors;
  38. PoolVector<int> splits;
  39. struct Bone {
  40. NodePath path;
  41. PoolVector<float> weights;
  42. };
  43. Vector<Bone> bone_weights;
  44. Color color;
  45. Ref<Texture> texture;
  46. Size2 tex_scale;
  47. Vector2 tex_ofs;
  48. bool tex_tile;
  49. float tex_rot;
  50. bool invert;
  51. float invert_border;
  52. bool antialiased;
  53. Vector2 offset;
  54. mutable bool rect_cache_dirty;
  55. mutable Rect2 item_rect;
  56. NodePath skeleton;
  57. Array _get_bones() const;
  58. void _set_bones(const Array &p_bones);
  59. protected:
  60. void _notification(int p_what);
  61. static void _bind_methods();
  62. public:
  63. virtual Dictionary _edit_get_state() const;
  64. virtual void _edit_set_state(const Dictionary &p_state);
  65. virtual void _edit_set_pivot(const Point2 &p_pivot);
  66. virtual Point2 _edit_get_pivot() const;
  67. virtual bool _edit_use_pivot() const;
  68. virtual Rect2 _edit_get_rect() const;
  69. virtual bool _edit_use_rect() const;
  70. virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
  71. void set_polygon(const PoolVector<Vector2> &p_polygon);
  72. PoolVector<Vector2> get_polygon() const;
  73. void set_uv(const PoolVector<Vector2> &p_uv);
  74. PoolVector<Vector2> get_uv() const;
  75. void set_splits(const PoolVector<int> &p_uv);
  76. PoolVector<int> get_splits() const;
  77. void set_color(const Color &p_color);
  78. Color get_color() const;
  79. void set_vertex_colors(const PoolVector<Color> &p_colors);
  80. PoolVector<Color> get_vertex_colors() const;
  81. void set_texture(const Ref<Texture> &p_texture);
  82. Ref<Texture> get_texture() const;
  83. void set_texture_offset(const Vector2 &p_offset);
  84. Vector2 get_texture_offset() const;
  85. void set_texture_rotation(float p_rot);
  86. float get_texture_rotation() const;
  87. void set_texture_rotation_degrees(float p_rot);
  88. float get_texture_rotation_degrees() const;
  89. void set_texture_scale(const Size2 &p_scale);
  90. Size2 get_texture_scale() const;
  91. void set_invert(bool p_invert);
  92. bool get_invert() const;
  93. void set_antialiased(bool p_antialiased);
  94. bool get_antialiased() const;
  95. void set_invert_border(float p_invert_border);
  96. float get_invert_border() const;
  97. void set_offset(const Vector2 &p_offset);
  98. Vector2 get_offset() const;
  99. void add_bone(const NodePath &p_path = NodePath(), const PoolVector<float> &p_weights = PoolVector<float>());
  100. int get_bone_count() const;
  101. NodePath get_bone_path(int p_index) const;
  102. PoolVector<float> get_bone_weights(int p_index) const;
  103. void erase_bone(int p_idx);
  104. void clear_bones();
  105. void set_bone_weights(int p_index, const PoolVector<float> &p_weights);
  106. void set_bone_path(int p_index, const NodePath &p_path);
  107. void set_skeleton(const NodePath &p_skeleton);
  108. NodePath get_skeleton() const;
  109. Polygon2D();
  110. };
  111. #endif // POLYGON_2D_H