Debian Codegraph @

scene/resources/mesh_data_tool.h

raw symbols SCIP
1 /**************************************************************************/
2 /* mesh_data_tool.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 #pragma once
32
33 #include "scene/resources/mesh.h"
34
35 class MeshDataTool : public RefCounted {
36 GDCLASS(MeshDataTool, RefCounted);
37
38 uint64_t format = 0;
39 struct Vertex {
40 Vector3 vertex;
41 Color color;
42 Vector3 normal; // normal, binormal, tangent
43 Plane tangent;
44 Vector2 uv;
45 Vector2 uv2;
46 Vector<int> bones;
47 Vector<float> weights;
48 Vector<int> edges;
49 Vector<int> faces;
50 Variant meta;
51 };
52
53 Vector<Vertex> vertices;
54
55 struct Edge {
56 int vertex[2] = {};
57 Vector<int> faces;
58 Variant meta;
59 };
60
61 Vector<Edge> edges;
62
63 struct Face {
64 int v[3] = {};
65 int edges[3] = {};
66 Variant meta;
67 };
68
69 Vector<Face> faces;
70
71 Ref<Material> material;
72
73 protected:
74 static void _bind_methods();
75
76 #ifndef DISABLE_DEPRECATED
77 Error commit_to_surface_bind_compat_81138(const Ref<ArrayMesh> &p_mesh);
78 static void _bind_compatibility_methods();
79 #endif
80
81 public:
82 void clear();
83 Error create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surface);
84 Error commit_to_surface(const Ref<ArrayMesh> &p_mesh, uint64_t p_compression_flags = 0);
85
86 uint64_t get_format() const;
87
88 int get_vertex_count() const;
89 int get_edge_count() const;
90 int get_face_count() const;
91
92 Vector3 get_vertex(int p_idx) const;
93 void set_vertex(int p_idx, const Vector3 &p_vertex);
94
95 Vector3 get_vertex_normal(int p_idx) const;
96 void set_vertex_normal(int p_idx, const Vector3 &p_normal);
97
98 Plane get_vertex_tangent(int p_idx) const;
99 void set_vertex_tangent(int p_idx, const Plane &p_tangent);
100
101 Vector2 get_vertex_uv(int p_idx) const;
102 void set_vertex_uv(int p_idx, const Vector2 &p_uv);
103
104 Vector2 get_vertex_uv2(int p_idx) const;
105 void set_vertex_uv2(int p_idx, const Vector2 &p_uv2);
106
107 Color get_vertex_color(int p_idx) const;
108 void set_vertex_color(int p_idx, const Color &p_color);
109
110 Vector<int> get_vertex_bones(int p_idx) const;
111 void set_vertex_bones(int p_idx, const Vector<int> &p_bones);
112
113 Vector<float> get_vertex_weights(int p_idx) const;
114 void set_vertex_weights(int p_idx, const Vector<float> &p_weights);
115
116 Variant get_vertex_meta(int p_idx) const;
117 void set_vertex_meta(int p_idx, const Variant &p_meta);
118
119 Vector<int> get_vertex_edges(int p_idx) const;
120 Vector<int> get_vertex_faces(int p_idx) const;
121
122 int get_edge_vertex(int p_edge, int p_vertex) const;
123 Vector<int> get_edge_faces(int p_edge) const;
124 Variant get_edge_meta(int p_idx) const;
125 void set_edge_meta(int p_idx, const Variant &p_meta);
126
127 int get_face_vertex(int p_face, int p_vertex) const;
128 int get_face_edge(int p_face, int p_vertex) const;
129 Variant get_face_meta(int p_face) const;
130 void set_face_meta(int p_face, const Variant &p_meta);
131 Vector3 get_face_normal(int p_face) const;
132
133 Ref<Material> get_material() const;
134 void set_material(const Ref<Material> &p_material);
135
136 MeshDataTool();
137 };