| 1 | /**************************************************************************/ |
| 2 | /* navigation_mesh_source_geometry_data_3d.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 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 | |
| 31 | #ifndef NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_3D_H |
| 32 | #define NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_3D_H |
| 33 | |
| 34 | #include "scene/3d/visual_instance_3d.h" |
| 35 | |
| 36 | class NavigationMeshSourceGeometryData3D : public Resource { |
| 37 | GDCLASS(NavigationMeshSourceGeometryData3D, Resource); |
| 38 | |
| 39 | Vector<float> vertices; |
| 40 | Vector<int> indices; |
| 41 | |
| 42 | protected: |
| 43 | static void _bind_methods(); |
| 44 | |
| 45 | private: |
| 46 | void _add_vertex(const Vector3 &p_vec3); |
| 47 | void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform); |
| 48 | void _add_mesh_array(const Array &p_array, const Transform3D &p_xform); |
| 49 | void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform); |
| 50 | |
| 51 | public: |
| 52 | // kept root node transform here on the geometry data |
| 53 | // if we add this transform to all exposed functions we need to break comp on all functions later |
| 54 | // when navmesh changes from global transform to relative to navregion |
| 55 | // but if it stays here we can just remove it and change the internal functions only |
| 56 | Transform3D root_node_transform; |
| 57 | |
| 58 | void set_vertices(const Vector<float> &p_vertices); |
| 59 | const Vector<float> &get_vertices() const { return vertices; } |
| 60 | |
| 61 | void set_indices(const Vector<int> &p_indices); |
| 62 | const Vector<int> &get_indices() const { return indices; } |
| 63 | |
| 64 | bool has_data() { return vertices.size() && indices.size(); }; |
| 65 | void clear(); |
| 66 | |
| 67 | void add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform); |
| 68 | void add_mesh_array(const Array &p_mesh_array, const Transform3D &p_xform); |
| 69 | void add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform); |
| 70 | |
| 71 | NavigationMeshSourceGeometryData3D(); |
| 72 | ~NavigationMeshSourceGeometryData3D(); |
| 73 | }; |
| 74 | |
| 75 | #endif // NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_3D_H |
| 76 | |