Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
clear
Clear all information passed into the surface tool so far.
SurfaceTool.swift:876final func clear()
Other members in extension
Types
Type members
Instance members
func addIndex(Int32
) Adds a vertex to index array if you are using indexed vertices. Does not need to be called before adding vertices.
func addTriangleFan(vertices: PackedVector3Array, uvs: PackedVector2Array, colors: PackedColorArray, uv2s: PackedVector2Array, normals: PackedVector3Array, tangents: VariantCollection<Plane>
) Inserts a triangle fan made of array data into
Mesh
being constructed.func addVertex(Vector3
) Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
func appendFrom(existing: Mesh?, surface: Int32, transform: Transform3D
) Append vertices from a given
Mesh
surface onto the current vertex array with specifiedTransform3D
.func begin(primitive: Mesh.PrimitiveType
) Called before adding any vertices. Takes the primitive type as an argument (e.g.
Mesh/PrimitiveType/primitiveTriangles
).func commit(existing: ArrayMesh?, flags: UInt
) -> ArrayMesh? Returns a constructed
ArrayMesh
from current information passed in. If an existingArrayMesh
is passed in as an argument, will add an extra surface to the existingArrayMesh
.func commitToArrays(
) -> GArray Commits the data to the same format used by
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
. This way you can further process the mesh data using theArrayMesh
API.func createFrom(existing: Mesh?, surface: Int32
) Creates a vertex array from an existing
Mesh
.func createFromBlendShape(existing: Mesh?, surface: Int32, blendShape: String
) 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 deindex(
) Removes the index array by expanding the vertex array.
func generateLod(ndThreshold: Double, targetIndexCount: Int32
) -> PackedInt32Array Generates a LOD for a given
ndThreshold
in linear units (square root of quadric error metric), using at mosttargetIndexCount
indices.func generateNormals(flip: Bool
) Generates normals from vertices so you do not have to do it manually. If
flip
istrue
, the resulting normals will be inverted.generateNormals(flip:)
should be called after generating geometry and before committing the mesh usingcommit(existing:flags:)
orcommitToArrays
. For correct display of normal-mapped surfaces, you will also have to generate tangents usinggenerateTangents
.func generateTangents(
) Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already (see
generateNormals(flip:)
).func getAabb(
) -> AABB Returns the axis-aligned bounding box of the vertex positions.
func getCustomFormat(channelIndex: Int32
) -> SurfaceTool.CustomFormat Returns the format for custom
channelIndex
(currently up to 4). Returns .customMax if this custom channel is unused.func getPrimitiveType(
) -> Mesh.PrimitiveType Returns the type of mesh geometry, such as
Mesh/PrimitiveType/primitiveTriangles
.func getSkinWeightCount(
) -> SurfaceTool.SkinWeightCount By default, returns .skin4Weights to indicate only 4 bone influences per vertex are used.
func index(
) Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
func optimizeIndicesForCache(
) Optimizes triangle sorting for performance. Requires that
getPrimitiveType
isMesh/PrimitiveType/primitiveTriangles
.func setBones(PackedInt32Array
) Specifies an array of bones to use for the next vertex.
bones
must contain 4 integers.func setColor(Color
) Specifies a
Color
to use for the next 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 setCustom(channelIndex: Int32, customColor: Color
) Sets the custom value on this vertex for
channelIndex
.func setCustomFormat(channelIndex: Int32, format: SurfaceTool.CustomFormat
) Sets the color format for this custom
channelIndex
. Use .customMax to disable.func setMaterial(Material?
) Sets
Material
to be used by theMesh
you are constructing.func setNormal(Vector3
) Specifies a normal to use for the next 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 setSkinWeightCount(SurfaceTool.SkinWeightCount
) Set to .skin8Weights to indicate that up to 8 bone influences per vertex may be used.
func setSmoothGroup(index: UInt32
) Specifies the smooth group to use for the next vertex. If this is never called, all vertices will have the default smooth group of
0
and will be smoothed with adjacent vertices of the same group. To produce a mesh with flat normals, set the smooth group to-1
.func setTangent(Plane
) Specifies a tangent to use for the next 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 setUv(Vector2
) Specifies a set of UV coordinates to use for the next 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 setUv2(Vector2
) Specifies an optional second set of UV coordinates to use for the next 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 setWeights(PackedFloat32Array
) Specifies weight values to use for the next vertex.
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.