Documentation
¶
Overview ¶
Package SurfaceTool provides methods for working with SurfaceTool object instances.
Index ¶
- type Advanced
- type Any
- type CustomFormat
- type Expanded
- func (self Expanded) AddTriangleFan(vertices []Vector3.XYZ, uvs []Vector2.XY, colors []Color.RGBA, ...)
- func (self Expanded) Commit(existing ArrayMesh.Instance, flags int) ArrayMesh.Instance
- func (self Expanded) CreateFromArrays(arrays []any, primitive_type Mesh.PrimitiveType)
- func (self Expanded) GenerateLod(nd_threshold Float.X, target_index_count int) []int32
- func (self Expanded) GenerateNormals(flip bool)
- type Extension
- type ID
- type Instance
- func (self Instance) AddIndex(index int)
- func (self Instance) AddTriangleFan(vertices []Vector3.XYZ)
- func (self Instance) AddVertex(vertex Vector3.XYZ)
- func (self Instance) AppendFrom(existing Mesh.Instance, surface int, transform Transform3D.BasisOrigin)
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsSurfaceTool() Instance
- func (self Instance) Begin(primitive Mesh.PrimitiveType)
- func (self Instance) Clear()
- func (self Instance) Commit() ArrayMesh.Instance
- func (self Instance) CommitToArrays() []any
- func (self Instance) CreateFrom(existing Mesh.Instance, surface int)
- func (self Instance) CreateFromArrays(arrays []any)
- func (self Instance) CreateFromBlendShape(existing Mesh.Instance, surface int, blend_shape string)
- func (self Instance) Deindex()
- func (self Instance) GenerateLod(nd_threshold Float.X) []int32
- func (self Instance) GenerateNormals()
- func (self Instance) GenerateTangents()
- func (self Instance) GetAabb() AABB.PositionSize
- func (self Instance) GetCustomFormat(channel_index int) CustomFormat
- func (self Instance) GetPrimitiveType() Mesh.PrimitiveType
- func (self Instance) GetSkinWeightCount() SkinWeightCount
- func (self Instance) ID() ID
- func (self Instance) Index()
- func (self Instance) OptimizeIndicesForCache()
- func (self Instance) SetBones(bones []int32)
- func (self Instance) SetColor(color Color.RGBA)
- func (self Instance) SetCustom(channel_index int, custom_color Color.RGBA)
- func (self Instance) SetCustomFormat(channel_index int, format CustomFormat)
- func (self Instance) SetMaterial(material Material.Instance)
- func (self Instance) SetNormal(normal Vector3.XYZ)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSkinWeightCount(count SkinWeightCount)
- func (self Instance) SetSmoothGroup(index int)
- func (self Instance) SetTangent(tangent Plane.NormalD)
- func (self Instance) SetUv(uv Vector2.XY)
- func (self Instance) SetUv2(uv2 Vector2.XY)
- func (self Instance) SetWeights(weights []float32)
- func (self Instance) Virtual(name string) reflect.Value
- type SkinWeightCount
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 CustomFormat ¶
type CustomFormat int //gd:SurfaceTool.CustomFormat
const ( /*Limits range of data passed to [method set_custom] to unsigned normalized 0 to 1 stored in 8 bits per channel. See [constant Mesh.ARRAY_CUSTOM_RGBA8_UNORM].*/ CustomRgba8Unorm CustomFormat = 0 /*Limits range of data passed to [method set_custom] to signed normalized -1 to 1 stored in 8 bits per channel. See [constant Mesh.ARRAY_CUSTOM_RGBA8_SNORM].*/ CustomRgba8Snorm CustomFormat = 1 /*Stores data passed to [method set_custom] as half precision floats, and uses only red and green color channels. See [constant Mesh.ARRAY_CUSTOM_RG_HALF].*/ CustomRgHalf CustomFormat = 2 /*Stores data passed to [method set_custom] as half precision floats and uses all color channels. See [constant Mesh.ARRAY_CUSTOM_RGBA_HALF].*/ CustomRgbaHalf CustomFormat = 3 /*Stores data passed to [method set_custom] as full precision floats, and uses only red color channel. See [constant Mesh.ARRAY_CUSTOM_R_FLOAT].*/ CustomRFloat CustomFormat = 4 /*Stores data passed to [method set_custom] as full precision floats, and uses only red and green color channels. See [constant Mesh.ARRAY_CUSTOM_RG_FLOAT].*/ CustomRgFloat CustomFormat = 5 /*Stores data passed to [method set_custom] as full precision floats, and uses only red, green and blue color channels. See [constant Mesh.ARRAY_CUSTOM_RGB_FLOAT].*/ CustomRgbFloat CustomFormat = 6 /*Stores data passed to [method set_custom] as full precision floats, and uses all color channels. See [constant Mesh.ARRAY_CUSTOM_RGBA_FLOAT].*/ CustomRgbaFloat CustomFormat = 7 /*Used to indicate a disabled custom channel.*/ CustomMax CustomFormat = 8 )
type Expanded ¶
type Expanded [1]gdclass.SurfaceTool
func (Expanded) AddTriangleFan ¶
func (self Expanded) AddTriangleFan(vertices []Vector3.XYZ, uvs []Vector2.XY, colors []Color.RGBA, uv2s []Vector2.XY, normals []Vector3.XYZ, tangents []Plane.NormalD)
Inserts a triangle fan made of array data into [Mesh] being constructed. Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES].
func (Expanded) Commit ¶
Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh]. The [param flags] argument can be the bitwise OR of [constant Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE], [constant Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS], or [constant Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY].
func (Expanded) CreateFromArrays ¶
func (self Expanded) CreateFromArrays(arrays []any, primitive_type Mesh.PrimitiveType)
Creates this SurfaceTool from existing vertex arrays such as returned by [method commit_to_arrays], [method Mesh.surface_get_arrays], [method Mesh.surface_get_blend_shape_arrays], [method ImporterMesh.get_surface_arrays], and [method ImporterMesh.get_surface_blend_shape_arrays]. [param primitive_type] controls the type of mesh data, defaulting to [constant Mesh.PRIMITIVE_TRIANGLES].
func (Expanded) GenerateLod ¶
Generates an LOD for a given [param nd_threshold] in linear units (square root of quadric error metric), using at most [param target_index_count] indices.
func (Expanded) GenerateNormals ¶
Generates normals from vertices so you do not have to do it manually. If [param flip] is [code]true[/code], the resulting normals will be inverted. [method generate_normals] should be called [i]after[/i] generating geometry and [i]before[/i] committing the mesh using [method commit] or [method commit_to_arrays]. For correct display of normal-mapped surfaces, you will also have to generate tangents using [method generate_tangents]. [b]Note:[/b] [method generate_normals] only works if the primitive type is set to [constant Mesh.PRIMITIVE_TRIANGLES]. [b]Note:[/b] [method generate_normals] takes smooth groups into account. To generate smooth normals, set the smooth group to a value greater than or equal to [code]0[/code] using [method set_smooth_group] or leave the smooth group at the default of [code]0[/code]. To generate flat normals, set the smooth group to [code]-1[/code] using [method set_smooth_group] prior to adding vertices.
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]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsSurfaceTool ¶
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.SurfaceTool
The [SurfaceTool] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from a script. All properties except indices need to be added before calling [method add_vertex]. For example, to add vertex colors and UVs: [codeblocks] [gdscript] var st = SurfaceTool.new() st.begin(Mesh.PRIMITIVE_TRIANGLES) st.set_color(Color(1, 0, 0)) st.set_uv(Vector2(0, 0)) st.add_vertex(Vector3(0, 0, 0)) [/gdscript] [csharp] var st = new SurfaceTool(); st.Begin(Mesh.PrimitiveType.Triangles); st.SetColor(new Color(1, 0, 0)); st.SetUV(new Vector2(0, 0)); st.AddVertex(new Vector3(0, 0, 0)); [/csharp] [/codeblocks] The above [SurfaceTool] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calling [method set_uv] or [method set_color], then the last values would be used. Vertex attributes must be passed [b]before[/b] calling [method add_vertex]. Failure to do so will result in an error when committing the vertex information to a mesh. Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices. See also [ArrayMesh], [ImmediateMesh] and [MeshDataTool] for procedural geometry generation. [b]Note:[/b] Godot uses clockwise [url=https://learnopengl.com/Advanced-OpenGL/Face-culling]winding order[/url] for front faces of triangle primitive modes.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddIndex ¶
Adds a vertex to index array if you are using indexed vertices. Does not need to be called before adding vertices.
func (Instance) AddTriangleFan ¶
Inserts a triangle fan made of array data into [Mesh] being constructed. Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES].
func (Instance) AddVertex ¶
Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
func (Instance) AppendFrom ¶
func (self Instance) AppendFrom(existing Mesh.Instance, surface int, transform Transform3D.BasisOrigin)
Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform3D].
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsSurfaceTool ¶
func (Instance) Begin ¶
func (self Instance) Begin(primitive Mesh.PrimitiveType)
Called before adding any vertices. Takes the primitive type as an argument (e.g. [constant Mesh.PRIMITIVE_TRIANGLES]).
func (Instance) Clear ¶
func (self Instance) Clear()
Clear all information passed into the surface tool so far.
func (Instance) Commit ¶
Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh]. The [param flags] argument can be the bitwise OR of [constant Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE], [constant Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS], or [constant Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY].
func (Instance) CommitToArrays ¶
Commits the data to the same format used by [method ArrayMesh.add_surface_from_arrays], [method ImporterMesh.add_surface], and [method create_from_arrays]. This way you can further process the mesh data using the [ArrayMesh] or [ImporterMesh] APIs.
func (Instance) CreateFrom ¶
Creates a vertex array from an existing [Mesh].
func (Instance) CreateFromArrays ¶
Creates this SurfaceTool from existing vertex arrays such as returned by [method commit_to_arrays], [method Mesh.surface_get_arrays], [method Mesh.surface_get_blend_shape_arrays], [method ImporterMesh.get_surface_arrays], and [method ImporterMesh.get_surface_blend_shape_arrays]. [param primitive_type] controls the type of mesh data, defaulting to [constant Mesh.PRIMITIVE_TRIANGLES].
func (Instance) CreateFromBlendShape ¶
Creates a vertex array from the specified blend shape of an existing [Mesh]. This can be used to extract a specific pose from a blend shape.
func (Instance) Deindex ¶
func (self Instance) Deindex()
Removes the index array by expanding the vertex array.
func (Instance) GenerateLod ¶
Generates an LOD for a given [param nd_threshold] in linear units (square root of quadric error metric), using at most [param target_index_count] indices.
func (Instance) GenerateNormals ¶
func (self Instance) GenerateNormals()
Generates normals from vertices so you do not have to do it manually. If [param flip] is [code]true[/code], the resulting normals will be inverted. [method generate_normals] should be called [i]after[/i] generating geometry and [i]before[/i] committing the mesh using [method commit] or [method commit_to_arrays]. For correct display of normal-mapped surfaces, you will also have to generate tangents using [method generate_tangents]. [b]Note:[/b] [method generate_normals] only works if the primitive type is set to [constant Mesh.PRIMITIVE_TRIANGLES]. [b]Note:[/b] [method generate_normals] takes smooth groups into account. To generate smooth normals, set the smooth group to a value greater than or equal to [code]0[/code] using [method set_smooth_group] or leave the smooth group at the default of [code]0[/code]. To generate flat normals, set the smooth group to [code]-1[/code] using [method set_smooth_group] prior to adding vertices.
func (Instance) GenerateTangents ¶
func (self Instance) GenerateTangents()
Generates a tangent vector for each vertex. Requires that each vertex already has UVs and normals set (see [method generate_normals]).
func (Instance) GetAabb ¶
func (self Instance) GetAabb() AABB.PositionSize
Returns the axis-aligned bounding box of the vertex positions.
func (Instance) GetCustomFormat ¶
func (self Instance) GetCustomFormat(channel_index int) CustomFormat
Returns the format for custom [param channel_index] (currently up to 4). Returns [constant CUSTOM_MAX] if this custom channel is unused.
func (Instance) GetPrimitiveType ¶
func (self Instance) GetPrimitiveType() Mesh.PrimitiveType
Returns the type of mesh geometry, such as [constant Mesh.PRIMITIVE_TRIANGLES].
func (Instance) GetSkinWeightCount ¶
func (self Instance) GetSkinWeightCount() SkinWeightCount
By default, returns [constant SKIN_4_WEIGHTS] to indicate only 4 bone influences per vertex are used. Returns [constant SKIN_8_WEIGHTS] if up to 8 influences are used. [b]Note:[/b] This function returns an enum, not the exact number of weights.
func (Instance) Index ¶
func (self Instance) Index()
Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
func (Instance) OptimizeIndicesForCache ¶
func (self Instance) OptimizeIndicesForCache()
Optimizes triangle sorting for performance. Requires that [method get_primitive_type] is [constant Mesh.PRIMITIVE_TRIANGLES].
func (Instance) SetBones ¶
Specifies an array of bones to use for the [i]next[/i] vertex. [param bones] must contain 4 integers.
func (Instance) SetColor ¶
Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. [b]Note:[/b] The material must have [member BaseMaterial3D.vertex_color_use_as_albedo] enabled for the vertex color to be visible.
func (Instance) SetCustom ¶
Sets the custom value on this vertex for [param channel_index]. [method set_custom_format] must be called first for this [param channel_index]. Formats which are not RGBA will ignore other color channels.
func (Instance) SetCustomFormat ¶
func (self Instance) SetCustomFormat(channel_index int, format CustomFormat)
Sets the color format for this custom [param channel_index]. Use [constant CUSTOM_MAX] to disable. Must be invoked after [method begin] and should be set before [method commit] or [method commit_to_arrays].
func (Instance) SetMaterial ¶
Sets [Material] to be used by the [Mesh] you are constructing.
func (Instance) SetNormal ¶
Specifies a normal to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
func (Instance) SetSkinWeightCount ¶
func (self Instance) SetSkinWeightCount(count SkinWeightCount)
Set to [constant SKIN_8_WEIGHTS] to indicate that up to 8 bone influences per vertex may be used. By default, only 4 bone influences are used ([constant SKIN_4_WEIGHTS]). [b]Note:[/b] This function takes an enum, not the exact number of weights.
func (Instance) SetSmoothGroup ¶
Specifies the smooth group to use for the [i]next[/i] vertex. If this is never called, all vertices will have the default smooth group of [code]0[/code] and will be smoothed with adjacent vertices of the same group. To produce a mesh with flat normals, set the smooth group to [code]-1[/code]. [b]Note:[/b] This function actually takes a [code]uint32_t[/code], so C# users should use [code]uint32.MaxValue[/code] instead of [code]-1[/code] to produce a mesh with flat normals.
func (Instance) SetTangent ¶
Specifies a tangent to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
func (Instance) SetUv ¶
Specifies a set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
func (Instance) SetUv2 ¶
Specifies an optional second set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
func (Instance) SetWeights ¶
Specifies weight values to use for the [i]next[/i] vertex. [param weights] must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
type SkinWeightCount ¶
type SkinWeightCount int //gd:SurfaceTool.SkinWeightCount
const ( /*Each individual vertex can be influenced by only 4 bone weights.*/ Skin4Weights SkinWeightCount = 0 /*Each individual vertex can be influenced by up to 8 bone weights.*/ Skin8Weights SkinWeightCount = 1 )