| 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/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; |
| 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 |
}; |