navigation_mesh.h
1 #ifndef NAVIGATION_MESH_H
2 #define NAVIGATION_MESH_H
3 
4 #include "scene/3d/spatial.h"
5 #include "scene/resources/mesh.h"
6 
7 class Mesh;
8 
9 class NavigationMesh : public Resource {
10 
11  OBJ_TYPE( NavigationMesh, Resource );
12 
13  DVector<Vector3> vertices;
14  struct Polygon {
15  Vector<int> indices;
16  };
17  Vector<Polygon> polygons;
18  Ref<Mesh> debug_mesh;
19 
20  struct _EdgeKey {
21 
22  Vector3 from;
23  Vector3 to;
24 
25  bool operator<(const _EdgeKey& p_with) const { return from==p_with.from ? to < p_with.to : from < p_with.from; }
26  };
27 
28 
29 protected:
30 
31  static void _bind_methods();
32 
33  void _set_polygons(const Array& p_array);
34  Array _get_polygons() const;
35 
36 public:
37 
38  void create_from_mesh(const Ref<Mesh>& p_mesh);
39 
40  void set_vertices(const DVector<Vector3>& p_vertices);
41  DVector<Vector3> get_vertices() const;
42 
43  void add_polygon(const Vector<int>& p_polygon);
44  int get_polygon_count() const;
45  Vector<int> get_polygon(int p_idx);
46  void clear_polygons();
47 
48  Ref<Mesh> get_debug_mesh();
49 
51 };
52 
53 
54 class Navigation;
55 
57 
59 
60  bool enabled;
61  int nav_id;
62  Navigation *navigation;
63  Ref<NavigationMesh> navmesh;
64 
65  Node *debug_view;
66 
67 protected:
68 
69  void _notification(int p_what);
70  static void _bind_methods();
71 public:
72 
73 
74 
75  void set_enabled(bool p_enabled);
76  bool is_enabled() const;
77 
78  void set_navigation_mesh(const Ref<NavigationMesh>& p_navmesh);
79  Ref<NavigationMesh> get_navigation_mesh() const;
80 
82 };
83 
84 
85 #endif // NAVIGATION_MESH_H
Definition: mesh.h:40
Definition: array.h:38
Definition: navigation_mesh.h:56
Definition: node.h:42
Definition: vector3.h:38
Definition: resource.h:89
Definition: navigation_mesh.h:9
Definition: navigation.h:7
Definition: spatial.h:56