Inherits: :ref:`Reference<class_reference>` < :ref:`Object<class_object>`
Category: Core
Helper tool to create geometry.
The SurfaceTool
is used to construct a :ref:`Mesh<class_mesh>` by specifying vertex attributes individually. It can be used to construct a :ref:`Mesh<class_mesh>` from script. All properties except index need to be added before a call to :ref:`add_vertex<class_SurfaceTool_add_vertex>`. For example adding vertex colors and UVs looks like
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 :ref:`Color<class_color>`. If another vertex were added without calls to :ref:`add_uv<class_SurfaceTool_add_uv>` or :ref:`add_color<class_SurfaceTool_add_color>` then the last values would be used.
It is very important that vertex attributes are passed before the call to :ref:`add_vertex<class_SurfaceTool_add_vertex>`, failure to do this will result in an error when committing the vertex information to a mesh.
- void add_bones ( :ref:`PoolIntArray<class_poolintarray>` bones )
Add an array of bones for the next Vertex to use.
- void add_color ( :ref:`Color<class_color>` color )
Specify a :ref:`Color<class_color>` for the next Vertex to use.
- void add_index ( :ref:`int<class_int>` index )
Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.
- void add_normal ( :ref:`Vector3<class_vector3>` normal )
Specify a normal for the next Vertex to use.
- void add_smooth_group ( :ref:`bool<class_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.
- void add_tangent ( :ref:`Plane<class_plane>` tangent )
Specify a Tangent for the next Vertex to use.
- void add_to_format ( :ref:`int<class_int>` flags )
- void add_triangle_fan ( :ref:`PoolVector3Array<class_poolvector3array>` vertexes, :ref:`PoolVector2Array<class_poolvector2array>` uvs=PoolVector2Array( ), :ref:`PoolColorArray<class_poolcolorarray>` colors=PoolColorArray( ), :ref:`PoolVector2Array<class_poolvector2array>` uv2s=PoolVector2Array( ), :ref:`PoolVector3Array<class_poolvector3array>` normals=PoolVector3Array( ), :ref:`Array<class_array>` tangents=[ ] )
Insert a triangle fan made of array data into :ref:`Mesh<class_mesh>` being constructed.
- void add_uv ( :ref:`Vector2<class_vector2>` uv )
Specify UV Coordinate for next Vertex to use.
- void add_uv2 ( :ref:`Vector2<class_vector2>` uv2 )
Specify an optional second set of UV coordinates for next Vertex to use.
- void add_vertex ( :ref:`Vector3<class_vector3>` vertex )
Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
- void add_weights ( :ref:`PoolRealArray<class_poolrealarray>` weights )
Specify weight value for next Vertex to use.
- void append_from ( :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_transform>` transform )
- void begin ( :ref:`int<class_int>` primitive )
Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).
- void clear ( )
Clear all information passed into the surface tool so far.
- :ref:`ArrayMesh<class_arraymesh>` commit ( :ref:`ArrayMesh<class_arraymesh>` existing=null, :ref:`int<class_int>` flags=97792 )
Returns a constructed :ref:`ArrayMesh<class_arraymesh>` from current information passed in. If an existing :ref:`ArrayMesh<class_arraymesh>` is passed in as an argument, will add an extra surface to the existing :ref:`ArrayMesh<class_arraymesh>`.
- void create_from ( :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface )
- void deindex ( )
Removes index array by expanding Vertex array.
- void generate_normals ( )
Generates normals from Vertices so you do not have to do it manually.
- void generate_tangents ( )
- void index ( )
Shrinks Vertex array by creating an index array. Avoids reusing Vertices.
- void set_material ( :ref:`Material<class_material>` material )
Sets :ref:`Material<class_material>` to be used by the :ref:`Mesh<class_mesh>` you are constructing.