Helper tool to create geometry.
    public class SurfaceTool : Reference

The SurfaceTool is used to construct a Mesh by specifying vertex attributes individually. It can be used to construct a Mesh from script. All properties except index need to be added before a call to AddVertex(Godot.Vector3). For example adding vertex colors and UVs looks like

[codeblock]

var st = SurfaceTool.new()

st.begin(Mesh.PRIMITIVE_TRIANGLES)

st.add_color(Color(1, 0, 0))

st.add_uv(Vector2(0, 0))

st.add_vertex(Vector3(0, 0, 0))

[/codeblock]

The SurfaceTool now contains one vertex of a triangle which has a UV coordinate and a specified Color. If another vertex were added without calls to AddUv(Godot.Vector2) or AddColor(Godot.Color) then the last values would be used.

It is very important that vertex attributes are passed before the call to AddVertex(Godot.Vector3), failure to do this will result in an error when committing the vertex information to a mesh.

Inheritance Chain

Constructors

    public SurfaceTool()

Methods

    public void AddBones(int[] bones)

Add an array of bones for the next Vertex to use.

    public void AddColor(Color color)

Specify a Color for the next Vertex to use.

    public void AddIndex(int index)

Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.

    public void AddNormal(Vector3 normal)

Specify a normal for the next Vertex to use.

    public void AddSmoothGroup(bool smooth)

Specify whether current Vertex (if using only Vertex arrays) or current index (if also using index arrays) should utilize smooth normals for normal calculation.

    public void AddTangent(Plane tangent)

Specify a Tangent for the next Vertex to use.

    public void AddToFormat(int flags)

    public void AddTriangleFan(Vector3[] vertexes, Vector2[] uvs = null, Color[] colors = null, Vector2[] uv2s = null, Vector3[] normals = null, object[] tangents = null)

Insert a triangle fan made of array data into Mesh being constructed.

    public void AddUv(Vector2 uv)

Specify UV Coordinate for next Vertex to use.

    public void AddUv2(Vector2 uv2)

Specify an optional second set of UV coordinates for next Vertex to use.

    public void AddVertex(Vector3 vertex)

Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).

    public void AddWeights(float[] weights)

Specify weight value for next Vertex to use.

    public void AppendFrom(Mesh existing, int surface, Transform transform)

    public void Begin(Mesh.PrimitiveType primitive)

Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).

    public void Clear()

Clear all information passed into the surface tool so far.

    public ArrayMesh Commit(ArrayMesh existing = null, int flags = 97792)

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.

    public void CreateFrom(Mesh existing, int surface)

    public void Deindex()

Removes index array by expanding Vertex array.

    public void GenerateNormals()

Generates normals from Vertices so you do not have to do it manually.

    public void GenerateTangents()

    public void Index()

Shrinks Vertex array by creating an index array. Avoids reusing Vertices.

    public void SetMaterial(Material material)

Sets Material to be used by the Mesh you are constructing.

Tags: