Path: blob/master/scene/resources/3d/importer_mesh.h
10278 views
/**************************************************************************/1/* importer_mesh.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/io/resource.h"33#include "scene/resources/mesh.h"34#include "scene/resources/navigation_mesh.h"3536#ifndef PHYSICS_3D_DISABLED37#include "scene/resources/3d/concave_polygon_shape_3d.h"38#include "scene/resources/3d/convex_polygon_shape_3d.h"39#endif // PHYSICS_3D_DISABLED4041// The following classes are used by importers instead of ArrayMesh and MeshInstance3D42// so the data is not registered (hence, quality loss), importing happens faster and43// its easier to modify before saving4445class ImporterMesh : public Resource {46GDCLASS(ImporterMesh, Resource)4748struct Surface {49Mesh::PrimitiveType primitive;50Array arrays;51struct BlendShape {52Array arrays;53};54Vector<BlendShape> blend_shape_data;55struct LOD {56Vector<int> indices;57float distance = 0.0f;58};59Vector<LOD> lods;60Ref<Material> material;61String name;62uint64_t flags = 0;6364struct LODComparator {65_FORCE_INLINE_ bool operator()(const LOD &l, const LOD &r) const {66return l.distance < r.distance;67}68};69};70Vector<Surface> surfaces;71Vector<String> blend_shapes;72Mesh::BlendShapeMode blend_shape_mode = Mesh::BLEND_SHAPE_MODE_NORMALIZED;7374Ref<ArrayMesh> mesh;7576Ref<ImporterMesh> shadow_mesh;7778Size2i lightmap_size_hint;7980protected:81void _set_data(const Dictionary &p_data);82Dictionary _get_data() const;8384void _generate_lods_bind(float p_normal_merge_angle, float p_normal_split_angle, Array p_skin_pose_transform_array);8586static void _bind_methods();8788public:89void add_blend_shape(const String &p_name);90int get_blend_shape_count() const;91String get_blend_shape_name(int p_blend_shape) const;9293static String validate_blend_shape_name(const String &p_name);9495void 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_name = String(), const uint64_t p_flags = 0);96int get_surface_count() const;9798void set_blend_shape_mode(Mesh::BlendShapeMode p_blend_shape_mode);99Mesh::BlendShapeMode get_blend_shape_mode() const;100101Mesh::PrimitiveType get_surface_primitive_type(int p_surface);102String get_surface_name(int p_surface) const;103void set_surface_name(int p_surface, const String &p_name);104Array get_surface_arrays(int p_surface) const;105Array get_surface_blend_shape_arrays(int p_surface, int p_blend_shape) const;106int get_surface_lod_count(int p_surface) const;107Vector<int> get_surface_lod_indices(int p_surface, int p_lod) const;108float get_surface_lod_size(int p_surface, int p_lod) const;109Ref<Material> get_surface_material(int p_surface) const;110uint64_t get_surface_format(int p_surface) const;111112void set_surface_material(int p_surface, const Ref<Material> &p_material);113114void optimize_indices();115116void generate_lods(float p_normal_merge_angle, Array p_skin_pose_transform_array);117118void create_shadow_mesh();119Ref<ImporterMesh> get_shadow_mesh() const;120121Vector<Face3> get_faces() const;122#ifndef PHYSICS_3D_DISABLED123Vector<Ref<Shape3D>> convex_decompose(const Ref<MeshConvexDecompositionSettings> &p_settings) const;124Ref<ConvexPolygonShape3D> create_convex_shape(bool p_clean = true, bool p_simplify = false) const;125Ref<ConcavePolygonShape3D> create_trimesh_shape() const;126#endif // PHYSICS_3D_DISABLED127Ref<NavigationMesh> create_navigation_mesh();128Error 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);129130void set_lightmap_size_hint(const Size2i &p_size);131Size2i get_lightmap_size_hint() const;132133bool has_mesh() const;134Ref<ArrayMesh> get_mesh(const Ref<ArrayMesh> &p_base = Ref<ArrayMesh>());135void clear();136};137138139