MeshInstance3D

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsMeshInstance3D() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsGeometryInstance3D

func (self *Extension[T]) AsGeometryInstance3D() GeometryInstance3D.Instance

func (*Extension[T]) AsMeshInstance3D

func (self *Extension[T]) AsMeshInstance3D() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode3D

func (self *Extension[T]) AsNode3D() Node3D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsVisualInstance3D

func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.MeshInstance3D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsGeometryInstance3D

func (self Instance) AsGeometryInstance3D() GeometryInstance3D.Instance

func (Instance) AsMeshInstance3D

func (self Instance) AsMeshInstance3D() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Node3D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsVisualInstance3D

func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance

func (Instance) BakeMeshFromCurrentBlendShapeMix

func (self Instance) BakeMeshFromCurrentBlendShapeMix() ArrayMesh.Instance

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.

func (Instance) BakeMeshFromCurrentSkeletonPose

func (self Instance) BakeMeshFromCurrentSkeletonPose() ArrayMesh.Instance

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.

func (Instance) CreateConvexCollision

func (self Instance) CreateConvexCollision()

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

If 'clean' is true (default), duplicate and interior vertices are removed automatically. You can set it to false to make the process faster if not needed.

If 'simplify' is true, the geometry can be further simplified to reduce the number of vertices. Disabled by default.

func (Instance) CreateDebugTangents

func (self Instance) CreateDebugTangents()

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

func (Instance) CreateMultipleConvexCollisions

func (self Instance) CreateMultipleConvexCollisions()

This helper creates a StaticBody3D child node with multiple ConvexPolygonShape3D collision shapes calculated from the mesh geometry via convex decomposition. The convex decomposition operation can be controlled with parameters from the optional 'settings'.

func (Instance) CreateTrimeshCollision

func (self Instance) CreateTrimeshCollision()

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

func (Instance) FindBlendShapeByName

func (self Instance) FindBlendShapeByName(name string) int

Returns the index of the blend shape with the given 'name'. Returns -1 if no blend shape with this name exists, including when Mesh is null.

func (Instance) GetActiveMaterial

func (self Instance) GetActiveMaterial(surface int) Material.Instance

Returns the Material that will be used by the Mesh when drawing. This can return the GeometryInstance3D.MaterialOverride, the surface override Material defined in this MeshInstance3D, or the surface Material defined in the Mesh. For example, if GeometryInstance3D.MaterialOverride is used, all surfaces will return the override material.

Returns null if no material is active, including when Mesh is null.

func (Instance) GetBlendShapeCount

func (self Instance) GetBlendShapeCount() int

Returns the number of blend shapes available. Produces an error if Mesh is null.

func (Instance) GetBlendShapeValue

func (self Instance) GetBlendShapeValue(blend_shape_idx int) Float.X

Returns the value of the blend shape at the given 'blend_shape_idx'. Returns 0.0 and produces an error if Mesh is null or doesn't have a blend shape at that index.

func (Instance) GetSkinReference

func (self Instance) GetSkinReference() SkinReference.Instance

Returns the internal SkinReference containing the skeleton's Resource.ID attached to this RID. See also Resource.GetRid, SkinReference.GetSkeleton, and RenderingServer.InstanceAttachSkeleton.

func (Instance) GetSurfaceOverrideMaterial

func (self Instance) GetSurfaceOverrideMaterial(surface int) Material.Instance

Returns the override Material for the specified 'surface' of the Mesh resource. See also GetSurfaceOverrideMaterialCount.

Note: This returns the Material associated to the MeshInstance3D's Surface Material Override properties, not the material within the Mesh resource. To get the material within the Mesh resource, use Mesh.SurfaceGetMaterial instead.

func (Instance) GetSurfaceOverrideMaterialCount

func (self Instance) GetSurfaceOverrideMaterialCount() int

Returns the number of surface override materials. This is equivalent to Mesh.GetSurfaceCount. See also GetSurfaceOverrideMaterial.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Mesh

func (self Instance) Mesh() Mesh.Instance

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) SetBlendShapeValue

func (self Instance) SetBlendShapeValue(blend_shape_idx int, value Float.X)

Sets the value of the blend shape at 'blend_shape_idx' to 'value'. Produces an error if Mesh is null or doesn't have a blend shape at that index.

func (Instance) SetMesh

func (self Instance) SetMesh(value Mesh.Instance)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSkeleton

func (self Instance) SetSkeleton(value string)

func (Instance) SetSkin

func (self Instance) SetSkin(value Skin.Instance)

func (Instance) SetSurfaceOverrideMaterial

func (self Instance) SetSurfaceOverrideMaterial(surface int, material Material.Instance)

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.SurfaceSetMaterial instead.

func (Instance) Skeleton

func (self Instance) Skeleton() string

func (Instance) Skin

func (self Instance) Skin() Skin.Instance

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

type MoreArgs [1]gdclass.MeshInstance3D

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) BakeMeshFromCurrentBlendShapeMix

func (self MoreArgs) BakeMeshFromCurrentBlendShapeMix(existing ArrayMesh.Instance) ArrayMesh.Instance

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.

func (MoreArgs) BakeMeshFromCurrentSkeletonPose

func (self MoreArgs) BakeMeshFromCurrentSkeletonPose(existing ArrayMesh.Instance) ArrayMesh.Instance

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.

func (MoreArgs) CreateConvexCollision

func (self MoreArgs) CreateConvexCollision(clean bool, simplify bool)

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

If 'clean' is true (default), duplicate and interior vertices are removed automatically. You can set it to false to make the process faster if not needed.

If 'simplify' is true, the geometry can be further simplified to reduce the number of vertices. Disabled by default.

func (MoreArgs) CreateMultipleConvexCollisions

func (self MoreArgs) CreateMultipleConvexCollisions(settings MeshConvexDecompositionSettings.Instance)

This helper creates a StaticBody3D child node with multiple ConvexPolygonShape3D collision shapes calculated from the mesh geometry via convex decomposition. The convex decomposition operation can be controlled with parameters from the optional 'settings'.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL