Documentation
¶
Overview ¶
The ArrayMesh is used to construct a Mesh by specifying the attributes as arrays.
The most basic example is the creation of a single triangle:
package main import ( "graphics.gd/classdb/ArrayMesh" "graphics.gd/classdb/Mesh" "graphics.gd/classdb/MeshInstance3D" "graphics.gd/variant/Vector3" ) func ExampleArrayMesh() { var vertices = []Vector3.XYZ{ {0, 1, 0}, {1, 0, 0}, {0, 0, 1}, } // Initialize the ArrayMesh. var arrMesh = ArrayMesh.New() var arrays = make([]any, Mesh.ArrayMax) arrays[Mesh.ArrayVertex] = vertices // Create the Mesh. arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveTriangles, arrays) var m = MeshInstance3D.New() m.SetMesh(arrMesh.AsMesh()) }
The MeshInstance3D is ready to be added to the SceneTree to be shown.
See also ImmediateMesh, MeshDataTool and SurfaceTool for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AddBlendShape(name string)
- func (self Instance) AddSurfaceFromArrays(primitive Mesh.PrimitiveType, arrays []any)
- func (self Instance) AsArrayMesh() Instance
- func (self Instance) AsMesh() Mesh.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) BlendShapeMode() Mesh.BlendShapeMode
- func (self Instance) ClearBlendShapes()
- func (self Instance) ClearSurfaces()
- func (self Instance) CustomAabb() AABB.PositionSize
- func (self Instance) GetBlendShapeCount() int
- func (self Instance) GetBlendShapeName(index int) string
- func (self Instance) ID() ID
- func (self Instance) LightmapUnwrap(transform Transform3D.BasisOrigin, texel_size Float.X) error
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) RegenNormalMaps()
- func (self Instance) SetBlendShapeMode(value Mesh.BlendShapeMode)
- func (self Instance) SetBlendShapeName(index int, name string)
- func (self Instance) SetCustomAabb(value AABB.PositionSize)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetShadowMesh(value Instance)
- func (self Instance) ShadowMesh() Instance
- func (self Instance) SurfaceFindByName(name string) int
- func (self Instance) SurfaceGetArrayIndexLen(surf_idx int) int
- func (self Instance) SurfaceGetArrayLen(surf_idx int) int
- func (self Instance) SurfaceGetFormat(surf_idx int) Mesh.ArrayFormat
- func (self Instance) SurfaceGetName(surf_idx int) string
- func (self Instance) SurfaceGetPrimitiveType(surf_idx int) Mesh.PrimitiveType
- func (self Instance) SurfaceRemove(surf_idx int)
- func (self Instance) SurfaceSetName(surf_idx int, name string)
- func (self Instance) SurfaceUpdateAttributeRegion(surf_idx int, offset int, data []byte)
- func (self Instance) SurfaceUpdateSkinRegion(surf_idx int, offset int, data []byte)
- func (self Instance) SurfaceUpdateVertexRegion(surf_idx int, offset int, data []byte)
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
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 Extension ¶
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]) AsArrayMesh ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type 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.
type Instance ¶
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 (Instance) AddBlendShape ¶
Adds name for a blend shape that will be added with AddSurfaceFromArrays. Must be called before surface is added.
func (Instance) AddSurfaceFromArrays ¶
func (self Instance) AddSurfaceFromArrays(primitive Mesh.PrimitiveType, arrays []any)
Creates a new surface. Mesh.GetSurfaceCount will become the surf_idx for this new surface.
Surfaces are created to be rendered using a 'primitive', which may be any of the values defined in [Mesh.PrimitiveType].
The 'arrays' argument is an array of arrays. Each of the [Mesh.ArrayMax] elements contains an array with some of the mesh data for this surface as described by the corresponding member of [Mesh.ArrayType] or null if it is not used by the surface. For example, arrays[0] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this surface into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array (or be an exact multiple of the vertex array's length, when multiple elements of a sub-array correspond to a single vertex) or be empty, except for [Mesh.ArrayIndex] if it is used.
The 'blend_shapes' argument is an array of vertex data for each blend shape. Each element is an array of the same structure as 'arrays', but [Mesh.ArrayVertex], [Mesh.ArrayNormal], and [Mesh.ArrayTangent] are set if and only if they are set in 'arrays' and all other entries are null.
The 'lods' argument is a dictionary with Float.X keys and []int32 values. Each entry in the dictionary represents an LOD level of the surface, where the value is the [Mesh.ArrayIndex] array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.
The 'flags' argument is the bitwise OR of, as required: One value of [Mesh.ArrayCustomFormat] left shifted by ARRAY_FORMAT_CUSTOMn_SHIFT for each custom channel in use, [Mesh.ArrayFlagUseDynamicUpdate], [Mesh.ArrayFlagUse8BoneWeights], or [Mesh.ArrayFlagUsesEmptyVertexArray].
Note: When using indices, it is recommended to only use points, lines, or triangles.
func (Instance) AsArrayMesh ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) BlendShapeMode ¶
func (self Instance) BlendShapeMode() Mesh.BlendShapeMode
func (Instance) ClearBlendShapes ¶
func (self Instance) ClearBlendShapes()
Removes all blend shapes from this ArrayMesh.
func (Instance) ClearSurfaces ¶
func (self Instance) ClearSurfaces()
Removes all surfaces from this ArrayMesh.
func (Instance) CustomAabb ¶
func (self Instance) CustomAabb() AABB.PositionSize
func (Instance) GetBlendShapeCount ¶
Returns the number of blend shapes that the ArrayMesh holds.
func (Instance) GetBlendShapeName ¶
Returns the name of the blend shape at this index.
func (Instance) LightmapUnwrap ¶
func (self Instance) LightmapUnwrap(transform Transform3D.BasisOrigin, texel_size Float.X) error
Performs a UV unwrap on the ArrayMesh to prepare the mesh for lightmapping.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) RegenNormalMaps ¶
func (self Instance) RegenNormalMaps()
Regenerates tangents for each of the ArrayMesh's surfaces.
func (Instance) SetBlendShapeMode ¶
func (self Instance) SetBlendShapeMode(value Mesh.BlendShapeMode)
func (Instance) SetBlendShapeName ¶
Sets the name of the blend shape at this index.
func (Instance) SetCustomAabb ¶
func (self Instance) SetCustomAabb(value AABB.PositionSize)
func (Instance) SetShadowMesh ¶
func (Instance) ShadowMesh ¶
func (Instance) SurfaceFindByName ¶
Returns the index of the first surface with this name held within this ArrayMesh. If none are found, -1 is returned.
func (Instance) SurfaceGetArrayIndexLen ¶
Returns the length in indices of the index array in the requested surface (see AddSurfaceFromArrays).
func (Instance) SurfaceGetArrayLen ¶
Returns the length in vertices of the vertex array in the requested surface (see AddSurfaceFromArrays).
func (Instance) SurfaceGetFormat ¶
func (self Instance) SurfaceGetFormat(surf_idx int) Mesh.ArrayFormat
Returns the format mask of the requested surface (see AddSurfaceFromArrays).
func (Instance) SurfaceGetName ¶
Gets the name assigned to this surface.
func (Instance) SurfaceGetPrimitiveType ¶
func (self Instance) SurfaceGetPrimitiveType(surf_idx int) Mesh.PrimitiveType
Returns the primitive type of the requested surface (see AddSurfaceFromArrays).
func (Instance) SurfaceRemove ¶
Removes the surface at the given index from the Mesh, shifting surfaces with higher index down by one.
func (Instance) SurfaceSetName ¶
Sets a name for a given surface.
func (Instance) SurfaceUpdateAttributeRegion ¶
func (Instance) SurfaceUpdateSkinRegion ¶
func (Instance) SurfaceUpdateVertexRegion ¶
type MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) AddSurfaceFromArrays ¶
func (self MoreArgs) AddSurfaceFromArrays(primitive Mesh.PrimitiveType, arrays []any, blend_shapes [][][]interface{}, lods map[float32][]int32, flags Mesh.ArrayFormat)
Creates a new surface. Mesh.GetSurfaceCount will become the surf_idx for this new surface.
Surfaces are created to be rendered using a 'primitive', which may be any of the values defined in [Mesh.PrimitiveType].
The 'arrays' argument is an array of arrays. Each of the [Mesh.ArrayMax] elements contains an array with some of the mesh data for this surface as described by the corresponding member of [Mesh.ArrayType] or null if it is not used by the surface. For example, arrays[0] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this surface into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array (or be an exact multiple of the vertex array's length, when multiple elements of a sub-array correspond to a single vertex) or be empty, except for [Mesh.ArrayIndex] if it is used.
The 'blend_shapes' argument is an array of vertex data for each blend shape. Each element is an array of the same structure as 'arrays', but [Mesh.ArrayVertex], [Mesh.ArrayNormal], and [Mesh.ArrayTangent] are set if and only if they are set in 'arrays' and all other entries are null.
The 'lods' argument is a dictionary with Float.X keys and []int32 values. Each entry in the dictionary represents an LOD level of the surface, where the value is the [Mesh.ArrayIndex] array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.
The 'flags' argument is the bitwise OR of, as required: One value of [Mesh.ArrayCustomFormat] left shifted by ARRAY_FORMAT_CUSTOMn_SHIFT for each custom channel in use, [Mesh.ArrayFlagUseDynamicUpdate], [Mesh.ArrayFlagUse8BoneWeights], or [Mesh.ArrayFlagUsesEmptyVertexArray].
Note: When using indices, it is recommended to only use points, lines, or triangles.