| 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 "core/io/resource.h" |
| 34 |
#include "scene/resources/mesh.h" |
| 35 |
#include "scene/resources/navigation_mesh.h" |
| 36 |
|
| 37 |
#ifndef PHYSICS_3D_DISABLED |
| 38 |
#include "scene/resources/3d/concave_polygon_shape_3d.h" |
| 39 |
#include "scene/resources/3d/convex_polygon_shape_3d.h" |
| 40 |
#endif |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
class ImporterMesh : public Resource { |
| 47 |
GDCLASS(ImporterMesh, Resource) |
| 48 |
|
| 49 |
struct Surface { |
| 50 |
Mesh::PrimitiveType primitive; |
| 51 |
Array arrays; |
| 52 |
struct BlendShape { |
| 53 |
Array arrays; |
| 54 |
}; |
| 55 |
Vector<BlendShape> blend_shape_data; |
| 56 |
struct LOD { |
| 57 |
Vector<int> indices; |
| 58 |
float distance = 0.0f; |
| 59 |
}; |
| 60 |
Vector<LOD> lods; |
| 61 |
Ref<Material> material; |
| 62 |
String name; |
| 63 |
uint64_t flags = 0; |
| 64 |
|
| 65 |
struct LODComparator { |
| 66 |
_FORCE_INLINE_ bool operator()(const LOD &l, const LOD &r) const { |
| 67 |
return l.distance < r.distance; |
| 68 |
} |
| 69 |
}; |
| 70 |
}; |
| 71 |
Vector<Surface> surfaces; |
| 72 |
Vector<String> blend_shapes; |
| 73 |
Mesh::BlendShapeMode blend_shape_mode = Mesh::BLEND_SHAPE_MODE_NORMALIZED; |
| 74 |
|
| 75 |
Ref<ArrayMesh> mesh; |
| 76 |
|
| 77 |
Ref<ImporterMesh> shadow_mesh; |
| 78 |
|
| 79 |
Size2i lightmap_size_hint; |
| 80 |
|
| 81 |
protected: |
| 82 |
void _set_data(const Dictionary &p_data); |
| 83 |
Dictionary _get_data() const; |
| 84 |
|
| 85 |
void _generate_lods_bind(float p_normal_merge_angle, float p_normal_split_angle, Array p_skin_pose_transform_array); |
| 86 |
|
| 87 |
static void _bind_methods(); |
| 88 |
|
| 89 |
public: |
| 90 |
void add_blend_shape(const String &p_name); |
| 91 |
int get_blend_shape_count() const; |
| 92 |
String get_blend_shape_name(int p_blend_shape) const; |
| 93 |
|
| 94 |
static String validate_blend_shape_name(const String &p_name); |
| 95 |
|
| 96 |
void add_surface(Mesh::PrimitiveType p_primitive, const Array &p_arrays, const TypedArray<Array> &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), const Ref<Material> &p_material = Ref<Material>(), const String &p_surface_name = String(), const uint64_t p_flags = 0); |
| 97 |
int get_surface_count() const; |
| 98 |
|
| 99 |
void set_blend_shape_mode(Mesh::BlendShapeMode p_blend_shape_mode); |
| 100 |
Mesh::BlendShapeMode get_blend_shape_mode() const; |
| 101 |
|
| 102 |
Mesh::PrimitiveType get_surface_primitive_type(int p_surface); |
| 103 |
String get_surface_name(int p_surface) const; |
| 104 |
void set_surface_name(int p_surface, const String &p_name); |
| 105 |
Array get_surface_arrays(int p_surface) const; |
| 106 |
Array get_surface_blend_shape_arrays(int p_surface, int p_blend_shape) const; |
| 107 |
int get_surface_lod_count(int p_surface) const; |
| 108 |
Vector<int> get_surface_lod_indices(int p_surface, int p_lod) const; |
| 109 |
float get_surface_lod_size(int p_surface, int p_lod) const; |
| 110 |
Ref<Material> get_surface_material(int p_surface) const; |
| 111 |
uint64_t get_surface_format(int p_surface) const; |
| 112 |
|
| 113 |
void set_surface_material(int p_surface, const Ref<Material> &p_material); |
| 114 |
|
| 115 |
void optimize_indices(); |
| 116 |
|
| 117 |
void generate_lods(float p_normal_merge_angle, Array p_skin_pose_transform_array); |
| 118 |
|
| 119 |
void create_shadow_mesh(); |
| 120 |
Ref<ImporterMesh> get_shadow_mesh() const; |
| 121 |
|
| 122 |
Vector<Face3> get_faces() const; |
| 123 |
#ifndef PHYSICS_3D_DISABLED |
| 124 |
Vector<Ref<Shape3D>> convex_decompose(const Ref<MeshConvexDecompositionSettings> &p_settings) const; |
| 125 |
Ref<ConvexPolygonShape3D> create_convex_shape(bool p_clean = true, bool p_simplify = false) const; |
| 126 |
Ref<ConcavePolygonShape3D> create_trimesh_shape() const; |
| 127 |
#endif |
| 128 |
Ref<NavigationMesh> create_navigation_mesh(); |
| 129 |
Error lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache); |
| 130 |
|
| 131 |
void set_lightmap_size_hint(const Size2i &p_size); |
| 132 |
Size2i get_lightmap_size_hint() const; |
| 133 |
|
| 134 |
bool has_mesh() const; |
| 135 |
Ref<ArrayMesh> get_mesh(const Ref<ArrayMesh> &p_base = Ref<ArrayMesh>()); |
| 136 |
static Ref<ImporterMesh> from_mesh(const Ref<Mesh> &p_mesh); |
| 137 |
void clear(); |
| 138 |
}; |