polygon_2d.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*************************************************************************/
  2. /* polygon_2d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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. Color color;
  39. Ref<Texture> texture;
  40. Size2 tex_scale;
  41. Vector2 tex_ofs;
  42. bool tex_tile;
  43. float tex_rot;
  44. bool invert;
  45. float invert_border;
  46. bool antialiased;
  47. Vector2 offset;
  48. mutable bool rect_cache_dirty;
  49. mutable Rect2 item_rect;
  50. void _set_texture_rotationd(float p_rot);
  51. float _get_texture_rotationd() const;
  52. protected:
  53. void _notification(int p_what);
  54. static void _bind_methods();
  55. public:
  56. void set_polygon(const PoolVector<Vector2> &p_polygon);
  57. PoolVector<Vector2> get_polygon() const;
  58. void set_uv(const PoolVector<Vector2> &p_uv);
  59. PoolVector<Vector2> get_uv() const;
  60. void set_color(const Color &p_color);
  61. Color get_color() const;
  62. void set_vertex_colors(const PoolVector<Color> &p_colors);
  63. PoolVector<Color> get_vertex_colors() const;
  64. void set_texture(const Ref<Texture> &p_texture);
  65. Ref<Texture> get_texture() const;
  66. void set_texture_offset(const Vector2 &p_offset);
  67. Vector2 get_texture_offset() const;
  68. void set_texture_rotation(float p_rot);
  69. float get_texture_rotation() const;
  70. void set_texture_scale(const Size2 &p_scale);
  71. Size2 get_texture_scale() const;
  72. void set_invert(bool p_invert);
  73. bool get_invert() const;
  74. void set_antialiased(bool p_antialiased);
  75. bool get_antialiased() const;
  76. void set_invert_border(float p_invert_border);
  77. float get_invert_border() const;
  78. void set_offset(const Vector2 &p_offset);
  79. Vector2 get_offset() const;
  80. //editor stuff
  81. virtual void edit_set_pivot(const Point2 &p_pivot);
  82. virtual Point2 edit_get_pivot() const;
  83. virtual bool edit_has_pivot() const;
  84. virtual Rect2 get_item_rect() const;
  85. Polygon2D();
  86. };
  87. #endif // POLYGON_2D_H