Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

MeshInstance3D

繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

被繼承: SoftBody3D

網格實例與場景相結合的節點。

說明

MeshInstance3D is a node that takes a Mesh resource and adds it to the current scenario by creating an instance of it. This is the class most often used to render 3D geometry and can be used to instance a single Mesh in many places. This allows reusing geometry, which can save on resources. When a Mesh has to be instantiated more than thousands of times at close proximity, consider using a MultiMesh in a MultiMeshInstance3D instead.

教學

屬性

Mesh

mesh

NodePath

skeleton

NodePath("")

Skin

skin

方法

ArrayMesh

bake_mesh_from_current_blend_shape_mix(existing: ArrayMesh = null)

ArrayMesh

bake_mesh_from_current_skeleton_pose(existing: ArrayMesh = null)

void

create_convex_collision(clean: bool = true, simplify: bool = false)

void

create_debug_tangents()

void

create_multiple_convex_collisions(settings: MeshConvexDecompositionSettings = null)

void

create_trimesh_collision()

int

find_blend_shape_by_name(name: StringName)

Material

get_active_material(surface: int) const

int

get_blend_shape_count() const

float

get_blend_shape_value(blend_shape_idx: int) const

SkinReference

get_skin_reference() const

Material

get_surface_override_material(surface: int) const

int

get_surface_override_material_count() const

void

set_blend_shape_value(blend_shape_idx: int, value: float)

void

set_surface_override_material(surface: int, material: Material)


屬性說明

Mesh mesh 🔗

  • void set_mesh(value: Mesh)

  • Mesh get_mesh()

該實例的 Mesh 資源。


NodePath skeleton = NodePath("") 🔗

NodePath to the Skeleton3D associated with the instance.

Note: The default value of this property has changed in Godot 4.6. Enable ProjectSettings.animation/compatibility/default_parent_skeleton_in_mesh_instance_3d if the old behavior is needed for compatibility.


Skin skin 🔗

  • void set_skin(value: Skin)

  • Skin get_skin()

該實例要使用的 Skin


方法說明

ArrayMesh bake_mesh_from_current_blend_shape_mix(existing: ArrayMesh = null) 🔗

Takes a snapshot from the current ArrayMesh with all blend shapes applied according to their current weights and bakes it to the provided existing mesh. If no existing mesh is provided a new ArrayMesh is created, baked and returned. Mesh surface materials are not copied.

Performance: Mesh data needs to be received from the GPU, stalling the RenderingServer in the process.


ArrayMesh bake_mesh_from_current_skeleton_pose(existing: ArrayMesh = null) 🔗

Takes a snapshot of the current animated skeleton pose of the skinned mesh and bakes it to the provided existing mesh. If no existing mesh is provided a new ArrayMesh is created, baked, and returned. Requires a skeleton with a registered skin to work. Blendshapes are ignored. Mesh surface materials are not copied.

Performance: Mesh data needs to be retrieved from the GPU, stalling the RenderingServer in the process.


void create_convex_collision(clean: bool = true, simplify: bool = false) 🔗

該助手建立一個 StaticBody3D 子節點,該子節點具有根據網格幾何計算的 ConvexPolygonShape3D 碰撞形狀。它主要用於測試。

如果 cleantrue(預設值),則重複的頂點和內部頂點會被自動移除。如果不需要,可以將其設定為 false,以加快處理速度。

如果 simplifytrue,則該幾何體可以進一步被簡化以減少頂點的數量。預設情況下是禁用的。


void create_debug_tangents() 🔗

建立 MeshInstance3D 子節點的輔助函式,會根據網格幾何體計算出各個頂點的小工具。主要用於測試。


void create_multiple_convex_collisions(settings: MeshConvexDecompositionSettings = null) 🔗

建立 StaticBody3D 子節點的輔助函式,會根據網格幾何體使用凸分解計算出多個 ConvexPolygonShape3D 碰撞形狀。凸分解操作可以通過可選的 settings 參數控制。


void create_trimesh_collision() 🔗

該助手建立一個 StaticBody3D 子節點,該子節點具有一個 ConcavePolygonShape3D 碰撞形狀,該形狀是根據網格幾何體計算出來的。它主要用於測試。


int find_blend_shape_by_name(name: StringName) 🔗

返回具有給定 name 的混合形狀的索引。如果不存在具有該名稱的混合形狀,以及當 meshnull 時,則返回 -1


Material get_active_material(surface: int) const 🔗

返回 Mesh 在繪製時將使用的 Material。這可以返回 GeometryInstance3D.material_override、在該 MeshInstance3D 中定義的表面覆蓋 Material、或 mesh 中定義的表面 Material。例如,如果使用 GeometryInstance3D.material_override,則所有表面都將返回該覆蓋材質。

如果沒有材質處於活動狀態,包括當 meshnull 時,則返回 null


int get_blend_shape_count() const 🔗

返回可用混合形狀的數量。如果 meshnull 則會報告有錯。


float get_blend_shape_value(blend_shape_idx: int) const 🔗

返回給定 blend_shape_idx 處的混合形狀的值。如果 meshnull,或在該索引處沒有混合形狀,則返回 0.0 並產生一個錯誤。


SkinReference get_skin_reference() const 🔗

Returns the internal SkinReference containing the skeleton's RID attached to this RID. See also Resource.get_rid(), SkinReference.get_skeleton(), and RenderingServer.instance_attach_skeleton().


Material get_surface_override_material(surface: int) const 🔗

傳回 Mesh 資源的指定 surface 的覆寫 Material。另請參閱 get_surface_override_material_count()

注意: 這將傳回與 MeshInstance3D 的表面材質覆蓋屬性關聯的 Material,而不是 Mesh 資源內的材質。若要取得 Mesh 資源中的材質,請使用 Mesh.surface_get_material()


int get_surface_override_material_count() const 🔗

返回表面覆蓋材質的數量。相當於 Mesh.get_surface_count()


void set_blend_shape_value(blend_shape_idx: int, value: float) 🔗

blend_shape_idx 處的混合形狀的值設定為 value。如果 meshnull,或在該索引處沒有混合形狀,則會產生一個錯誤。


void set_surface_override_material(surface: int, material: Material) 🔗

Sets the override material for the specified surface of the Mesh resource. This material is associated with this MeshInstance3D rather than with mesh.

Note: This assigns the Material associated to the MeshInstance3D's Surface Material Override properties, not the material within the Mesh resource. To set the material within the Mesh resource, use Mesh.surface_set_material() instead.