MeshInstance3D

Inherits:GeometryInstance3D<VisualInstance3D<Node3D<Node<Object

Inherited By:SoftBody3D

Node that instances meshes into a scenario.

Description

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

Tutorials

Properties

Mesh

mesh

NodePath

skeleton

NodePath("..")

Skin

skin

Methods

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)


Property Descriptions

Meshmesh🔗

TheMesh resource for the instance.


NodePathskeleton =NodePath("..")🔗

NodePath to theSkeleton3D associated with the instance.


Skinskin🔗

TheSkin to be used by this instance.


Method Descriptions

ArrayMeshbake_mesh_from_current_blend_shape_mix(existing:ArrayMesh = null)🔗

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

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


ArrayMeshbake_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 providedexisting mesh. If noexisting mesh is provided a newArrayMesh 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 theRenderingServer in the process.


voidcreate_convex_collision(clean:bool = true, simplify:bool = false)🔗

This helper creates aStaticBody3D child node with aConvexPolygonShape3D collision shape calculated from the mesh geometry. It's mainly used for testing.

Ifclean istrue (default), duplicate and interior vertices are removed automatically. You can set it tofalse to make the process faster if not needed.

Ifsimplify istrue, the geometry can be further simplified to reduce the number of vertices. Disabled by default.


voidcreate_debug_tangents()🔗

This helper creates aMeshInstance3D child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.


voidcreate_multiple_convex_collisions(settings:MeshConvexDecompositionSettings = null)🔗

This helper creates aStaticBody3D child node with multipleConvexPolygonShape3D collision shapes calculated from the mesh geometry via convex decomposition. The convex decomposition operation can be controlled with parameters from the optionalsettings.


voidcreate_trimesh_collision()🔗

This helper creates aStaticBody3D child node with aConcavePolygonShape3D collision shape calculated from the mesh geometry. It's mainly used for testing.


intfind_blend_shape_by_name(name:StringName)🔗

Returns the index of the blend shape with the givenname. Returns-1 if no blend shape with this name exists, including whenmesh isnull.


Materialget_active_material(surface:int)const🔗

Returns theMaterial that will be used by theMesh when drawing. This can return theGeometryInstance3D.material_override, the surface overrideMaterial defined in thisMeshInstance3D, or the surfaceMaterial defined in themesh. For example, ifGeometryInstance3D.material_override is used, all surfaces will return the override material.

Returnsnull if no material is active, including whenmesh isnull.


intget_blend_shape_count()const🔗

Returns the number of blend shapes available. Produces an error ifmesh isnull.


floatget_blend_shape_value(blend_shape_idx:int)const🔗

Returns the value of the blend shape at the givenblend_shape_idx. Returns0.0 and produces an error ifmesh isnull or doesn't have a blend shape at that index.


SkinReferenceget_skin_reference()const🔗

Returns the internalSkinReference containing the skeleton'sRID attached to this RID. See alsoResource.get_rid(),SkinReference.get_skeleton(), andRenderingServer.instance_attach_skeleton().


Materialget_surface_override_material(surface:int)const🔗

Returns the overrideMaterial for the specifiedsurface of theMesh resource. See alsoget_surface_override_material_count().

Note: This returns theMaterial associated to theMeshInstance3D's Surface Material Override properties, not the material within theMesh resource. To get the material within theMesh resource, useMesh.surface_get_material() instead.


intget_surface_override_material_count()const🔗

Returns the number of surface override materials. This is equivalent toMesh.get_surface_count(). See alsoget_surface_override_material().


voidset_blend_shape_value(blend_shape_idx:int, value:float)🔗

Sets the value of the blend shape atblend_shape_idx tovalue. Produces an error ifmesh isnull or doesn't have a blend shape at that index.


voidset_surface_override_material(surface:int, material:Material)🔗

Sets the overridematerial for the specifiedsurface of theMesh resource. This material is associated with thisMeshInstance3D rather than withmesh.

Note: This assigns theMaterial associated to theMeshInstance3D's Surface Material Override properties, not the material within theMesh resource. To set the material within theMesh resource, useMesh.surface_set_material() instead.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.