SurfaceTool

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

More...

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

addBones
void addBones(PoolIntArray bones)

Add an array of bones for the next Vertex to use. Array must contain 4 integers.

addColor
void addColor(Color color)

Specify a Color for the next Vertex to use.

addIndex
void addIndex(long index)

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

addNormal
void addNormal(Vector3 normal)

Specify a normal for the next Vertex to use.

addSmoothGroup
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.

addTangent
void addTangent(Plane tangent)

Specify a Tangent for the next Vertex to use.

addToFormat
void addToFormat(long flags)
addTriangleFan
void addTriangleFan(PoolVector3Array vertexes, PoolVector2Array uvs, PoolColorArray colors, PoolVector2Array uv2s, PoolVector3Array normals, Array tangents)

Insert a triangle fan made of array data into Mesh being constructed. Requires primitive type be set to PRIMITIVE_TRIANGLES.

addUv
void addUv(Vector2 uv)

Specify UV Coordinate for next Vertex to use.

addUv2
void addUv2(Vector2 uv2)

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

addVertex
void addVertex(Vector3 vertex)

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

addWeights
void addWeights(PoolRealArray weights)

Specify weight values for next Vertex to use. Array must contain 4 values.

appendFrom
void appendFrom(Mesh existing, long surface, Transform transform)

Append vertices from a given Mesh surface onto the current vertex array with specified Transform.

begin
void begin(long primitive)

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

clear
void clear()

Clear all information passed into the surface tool so far.

commit
Ref!ArrayMesh commit(ArrayMesh existing, long flags)

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.

createFrom
void createFrom(Mesh existing, long surface)

Creates a vertex array from an existing Mesh.

deindex
void deindex()

Removes index array by expanding Vertex array.

generateNormals
void generateNormals(bool flip)

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.

generateTangents
void generateTangents()

Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already.

index
void index()

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

opAssign
SurfaceTool opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(SurfaceTool other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
setMaterial
void setMaterial(Material material)

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

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
SurfaceTool _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

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.

Meta