| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/2d/node_2d.h" |
| 34 |
|
| 35 |
class NavigationPolygon; |
| 36 |
class NavigationMeshSourceGeometryData2D; |
| 37 |
|
| 38 |
class Polygon2D : public Node2D { |
| 39 |
GDCLASS(Polygon2D, Node2D); |
| 40 |
|
| 41 |
Vector<Vector2> polygon; |
| 42 |
Vector<Vector2> uv; |
| 43 |
Vector<Color> vertex_colors; |
| 44 |
Array polygons; |
| 45 |
int internal_vertices = 0; |
| 46 |
|
| 47 |
struct Bone { |
| 48 |
NodePath path; |
| 49 |
Vector<float> weights; |
| 50 |
}; |
| 51 |
|
| 52 |
Vector<Bone> bone_weights; |
| 53 |
|
| 54 |
Color color = Color(1, 1, 1); |
| 55 |
Ref<Texture2D> texture; |
| 56 |
|
| 57 |
Size2 tex_scale = Vector2(1, 1); |
| 58 |
Vector2 tex_ofs; |
| 59 |
real_t tex_rot = 0.0; |
| 60 |
bool invert = false; |
| 61 |
real_t invert_border = 100.0; |
| 62 |
bool antialiased = false; |
| 63 |
|
| 64 |
Vector2 offset; |
| 65 |
mutable bool rect_cache_dirty = true; |
| 66 |
mutable Rect2 item_rect; |
| 67 |
|
| 68 |
NodePath skeleton; |
| 69 |
ObjectID current_skeleton_id; |
| 70 |
|
| 71 |
Array _get_bones() const; |
| 72 |
void _set_bones(const Array &p_bones); |
| 73 |
|
| 74 |
void _skeleton_bone_setup_changed(); |
| 75 |
|
| 76 |
RID mesh; |
| 77 |
|
| 78 |
protected: |
| 79 |
void _notification(int p_what); |
| 80 |
static void _bind_methods(); |
| 81 |
|
| 82 |
public: |
| 83 |
#ifdef TOOLS_ENABLED |
| 84 |
virtual Dictionary _edit_get_state() const override; |
| 85 |
virtual void _edit_set_state(const Dictionary &p_state) override; |
| 86 |
|
| 87 |
virtual void _edit_set_pivot(const Point2 &p_pivot) override; |
| 88 |
virtual Point2 _edit_get_pivot() const override; |
| 89 |
virtual bool _edit_use_pivot() const override; |
| 90 |
#endif |
| 91 |
|
| 92 |
#ifdef DEBUG_ENABLED |
| 93 |
virtual Rect2 _edit_get_rect() const override; |
| 94 |
virtual bool _edit_use_rect() const override; |
| 95 |
|
| 96 |
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override; |
| 97 |
#endif |
| 98 |
|
| 99 |
void set_polygon(const Vector<Vector2> &p_polygon); |
| 100 |
Vector<Vector2> get_polygon() const; |
| 101 |
|
| 102 |
void set_internal_vertex_count(int p_count); |
| 103 |
int get_internal_vertex_count() const; |
| 104 |
|
| 105 |
void set_uv(const Vector<Vector2> &p_uv); |
| 106 |
Vector<Vector2> get_uv() const; |
| 107 |
|
| 108 |
void set_polygons(const Array &p_polygons); |
| 109 |
Array get_polygons() const; |
| 110 |
|
| 111 |
void set_color(const Color &p_color); |
| 112 |
Color get_color() const; |
| 113 |
|
| 114 |
void set_vertex_colors(const Vector<Color> &p_colors); |
| 115 |
Vector<Color> get_vertex_colors() const; |
| 116 |
|
| 117 |
void set_texture(const Ref<Texture2D> &p_texture); |
| 118 |
Ref<Texture2D> get_texture() const; |
| 119 |
|
| 120 |
void set_texture_offset(const Vector2 &p_offset); |
| 121 |
Vector2 get_texture_offset() const; |
| 122 |
|
| 123 |
void set_texture_rotation(real_t p_rot); |
| 124 |
real_t get_texture_rotation() const; |
| 125 |
|
| 126 |
void set_texture_scale(const Size2 &p_scale); |
| 127 |
Size2 get_texture_scale() const; |
| 128 |
|
| 129 |
void set_invert(bool p_invert); |
| 130 |
bool get_invert() const; |
| 131 |
|
| 132 |
void set_antialiased(bool p_antialiased); |
| 133 |
bool get_antialiased() const; |
| 134 |
|
| 135 |
void set_invert_border(real_t p_invert_border); |
| 136 |
real_t get_invert_border() const; |
| 137 |
|
| 138 |
void set_offset(const Vector2 &p_offset); |
| 139 |
Vector2 get_offset() const; |
| 140 |
|
| 141 |
void add_bone(const NodePath &p_path = NodePath(), const Vector<float> &p_weights = Vector<float>()); |
| 142 |
int get_bone_count() const; |
| 143 |
NodePath get_bone_path(int p_index) const; |
| 144 |
Vector<float> get_bone_weights(int p_index) const; |
| 145 |
void erase_bone(int p_idx); |
| 146 |
void clear_bones(); |
| 147 |
void set_bone_weights(int p_index, const Vector<float> &p_weights); |
| 148 |
void set_bone_path(int p_index, const NodePath &p_path); |
| 149 |
|
| 150 |
void set_skeleton(const NodePath &p_skeleton); |
| 151 |
NodePath get_skeleton() const; |
| 152 |
|
| 153 |
#ifndef NAVIGATION_2D_DISABLED |
| 154 |
private: |
| 155 |
static Callable _navmesh_source_geometry_parsing_callback; |
| 156 |
static RID _navmesh_source_geometry_parser; |
| 157 |
#endif |
| 158 |
|
| 159 |
public: |
| 160 |
#ifndef NAVIGATION_2D_DISABLED |
| 161 |
static void navmesh_parse_init(); |
| 162 |
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node); |
| 163 |
#endif |
| 164 |
|
| 165 |
Polygon2D(); |
| 166 |
~Polygon2D(); |
| 167 |
}; |