Add an array of bones for the next Vertex to use. Array must contain 4 integers.
Specify a Color for the next Vertex to use.
Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.
Specify a normal for the next Vertex to use.
Specify whether current Vertex (if using only Vertex arrays) or current index (if also using index arrays) should utilize smooth normals for normal calculation.
Specify a Tangent for the next Vertex to use.
Insert a triangle fan made of array data into Mesh being constructed. Requires primitive type be set to PRIMITIVE_TRIANGLES.
Specify UV Coordinate for next Vertex to use.
Specify an optional second set of UV coordinates for next Vertex to use.
Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
Specify weight values for next Vertex to use. Array must contain 4 values.
Append vertices from a given Mesh surface onto the current vertex array with specified Transform.
Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).
Clear all information passed into the surface tool so far.
Creates a vertex array from an existing Mesh.
Removes index array by expanding Vertex array.
Generates normals from Vertices so you do not have to do it manually. Setting "flip" true inverts resulting normals. Requires primitive type to be set to PRIMITIVE_TRIANGLES.
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already.
Shrinks Vertex array by creating an index array. Avoids reusing Vertices.
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))
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 or addColor then the last values would be used. It is very important that vertex attributes are passed before the call to addVertex, failure to do this 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.
Helper tool to create geometry.
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. For example adding vertex colors and UVs looks like