Documentation
¶
Overview ¶
ImporterMesh is a type of graphics.gd/classdb/Resource analogous to graphics.gd/classdb/ArrayMesh. It contains vertex array-based geometry, divided in surfaces. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.
Unlike its runtime counterpart, graphics.gd/classdb/ImporterMesh contains mesh data before various import steps, such as lod and shadow mesh generation, have taken place. Modify surface data by calling Instance.Clear, followed by Instance.AddSurface for each surface.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AddBlendShape(name string)
- func (self Instance) AddSurface(primitive Mesh.PrimitiveType, arrays []any)
- func (self Instance) AsImporterMesh() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) Clear()
- func (self Instance) GenerateLods(normal_merge_angle Angle.Degrees, normal_split_angle Angle.Degrees, ...)
- func (self Instance) GetBlendShapeCount() int
- func (self Instance) GetBlendShapeMode() Mesh.BlendShapeMode
- func (self Instance) GetBlendShapeName(blend_shape_idx int) string
- func (self Instance) GetLightmapSizeHint() Vector2i.XY
- func (self Instance) GetMesh() ArrayMesh.Instance
- func (self Instance) GetSurfaceArrays(surface_idx int) []any
- func (self Instance) GetSurfaceBlendShapeArrays(surface_idx int, blend_shape_idx int) [][]interface{}
- func (self Instance) GetSurfaceCount() int
- func (self Instance) GetSurfaceFormat(surface_idx int) int
- func (self Instance) GetSurfaceLodCount(surface_idx int) int
- func (self Instance) GetSurfaceLodIndices(surface_idx int, lod_idx int) []int32
- func (self Instance) GetSurfaceLodSize(surface_idx int, lod_idx int) Float.X
- func (self Instance) GetSurfaceMaterial(surface_idx int) Material.Instance
- func (self Instance) GetSurfaceName(surface_idx int) string
- func (self Instance) GetSurfacePrimitiveType(surface_idx int) Mesh.PrimitiveType
- func (self Instance) ID() ID
- func (self Instance) SetBlendShapeMode(mode Mesh.BlendShapeMode)
- func (self Instance) SetLightmapSizeHint(size Vector2i.XY)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSurfaceMaterial(surface_idx int, material Material.Instance)
- func (self Instance) SetSurfaceName(surface_idx int, name string)
- func (self Instance) Virtual(name string) reflect.Value
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 Expanded ¶
type Expanded [1]gdclass.ImporterMesh
func (Expanded) AddSurface ¶
func (self Expanded) AddSurface(primitive Mesh.PrimitiveType, arrays []any, blend_shapes [][][]interface{}, lods map[float32][]int32, material Material.Instance, name string, flags int)
Creates a new surface. graphics.gd/classdb/Mesh.Instance.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 (Expanded) GetMesh ¶
Returns the mesh data represented by this graphics.gd/classdb/ImporterMesh as a usable graphics.gd/classdb/ArrayMesh.
This method caches the returned mesh, and subsequent calls will return the cached data until Instance.Clear is called.
If not yet cached and 'base_mesh' is provided, 'base_mesh' will be used and mutated.
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]) AsImporterMesh ¶
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 ¶
type Instance [1]gdclass.ImporterMesh
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 Instance.AddSurface. Must be called before surface is added.
func (Instance) AddSurface ¶
func (self Instance) AddSurface(primitive Mesh.PrimitiveType, arrays []any)
Creates a new surface. graphics.gd/classdb/Mesh.Instance.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) AsImporterMesh ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) Clear ¶
func (self Instance) Clear()
Removes all surfaces and blend shapes from this graphics.gd/classdb/ImporterMesh.
func (Instance) GenerateLods ¶
func (self Instance) GenerateLods(normal_merge_angle Angle.Degrees, normal_split_angle Angle.Degrees, bone_transform_array []struct { Basis struct { X struct { X float32 Y float32 Z float32 } Y struct { X float32 Y float32 Z float32 } Z struct { X float32 Y float32 Z float32 } } Origin struct { X float32 Y float32 Z float32 } })
Generates all lods for this ImporterMesh.
'normal_merge_angle' is in degrees and used in the same way as the importer settings in lods.
'normal_split_angle' is not used and only remains for compatibility with older versions of the API.
The number of generated lods can be accessed using Instance.GetSurfaceLodCount, and each LOD is available in Instance.GetSurfaceLodSize and Instance.GetSurfaceLodIndices.
'bone_transform_array' is an slice which can be either empty or contain [Transform3D.BasisOrigin]s which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.
func (Instance) GetBlendShapeCount ¶
Returns the number of blend shapes that the mesh holds.
func (Instance) GetBlendShapeMode ¶
func (self Instance) GetBlendShapeMode() Mesh.BlendShapeMode
Returns the blend shape mode for this Mesh.
func (Instance) GetBlendShapeName ¶
Returns the name of the blend shape at this index.
func (Instance) GetLightmapSizeHint ¶
Returns the size hint of this mesh for lightmap-unwrapping in UV-space.
func (Instance) GetMesh ¶
Returns the mesh data represented by this graphics.gd/classdb/ImporterMesh as a usable graphics.gd/classdb/ArrayMesh.
This method caches the returned mesh, and subsequent calls will return the cached data until Instance.Clear is called.
If not yet cached and 'base_mesh' is provided, 'base_mesh' will be used and mutated.
func (Instance) GetSurfaceArrays ¶
Returns the arrays for the vertices, normals, UVs, etc. that make up the requested surface. See Instance.AddSurface.
func (Instance) GetSurfaceBlendShapeArrays ¶
func (self Instance) GetSurfaceBlendShapeArrays(surface_idx int, blend_shape_idx int) [][]interface{}
Returns a single set of blend shape arrays for the requested blend shape index for a surface.
func (Instance) GetSurfaceCount ¶
Returns the number of surfaces that the mesh holds.
func (Instance) GetSurfaceFormat ¶
Returns the format of the surface that the mesh holds.
func (Instance) GetSurfaceLodCount ¶
Returns the number of lods that the mesh holds on a given surface.
func (Instance) GetSurfaceLodIndices ¶
Returns the index buffer of a lod for a surface.
func (Instance) GetSurfaceLodSize ¶
Returns the screen ratio which activates a lod for a surface.
func (Instance) GetSurfaceMaterial ¶
Returns a graphics.gd/classdb/Material in a given surface. Surface is rendered using this material.
func (Instance) GetSurfaceName ¶
Gets the name assigned to this surface.
func (Instance) GetSurfacePrimitiveType ¶
func (self Instance) GetSurfacePrimitiveType(surface_idx int) Mesh.PrimitiveType
Returns the primitive type of the requested surface (see Instance.AddSurface).
func (Instance) SetBlendShapeMode ¶
func (self Instance) SetBlendShapeMode(mode Mesh.BlendShapeMode)
Sets the blend shape mode.
func (Instance) SetLightmapSizeHint ¶
Sets the size hint of this mesh for lightmap-unwrapping in UV-space.
func (Instance) SetSurfaceMaterial ¶
Sets a graphics.gd/classdb/Material for a given surface. Surface will be rendered using this material.
func (Instance) SetSurfaceName ¶
Sets a name for a given surface.