.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_SurfaceTool: SurfaceTool =========== **Inherits:** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Helper tool to create geometry. Member Functions ---------------- +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_bones` **(** :ref:`IntArray` bones **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_color` **(** :ref:`Color` color **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_index` **(** :ref:`int` index **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_normal` **(** :ref:`Vector3` normal **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_smooth_group` **(** :ref:`bool` smooth **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_tangent` **(** :ref:`Plane` tangent **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_to_format` **(** :ref:`int` flags **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_triangle_fan` **(** :ref:`Vector3Array` vertexes, :ref:`Vector2Array` uvs=Vector2Array([]), :ref:`ColorArray` colors=ColorArray([ColorArray]), :ref:`Vector2Array` uv2s=Vector2Array([]), :ref:`Vector3Array` normals=Vector3Array([]), :ref:`Array` tangents=Array() **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_uv` **(** :ref:`Vector2` uv **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_uv2` **(** :ref:`Vector2` uv2 **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_vertex` **(** :ref:`Vector3` vertex **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_weights` **(** :ref:`RealArray` weights **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`append_from` **(** :ref:`Mesh` existing, :ref:`int` surface, :ref:`Transform` transform **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`begin` **(** :ref:`int` primitive **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Mesh` | :ref:`commit` **(** :ref:`Mesh` existing=NULL **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`create_from` **(** :ref:`Mesh` existing, :ref:`int` surface **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`deindex` **(** **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`generate_normals` **(** **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`generate_tangents` **(** **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`index` **(** **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_material` **(** :ref:`Material` material **)** | +--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Description ----------- The :ref:`SurfaceTool` is used to construct a :ref:`Mesh` by specifying vertex attributes individually. It can be used to construct a :ref:`Mesh` from script. All properties except index need to be added before a call to :ref:`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 :ref:`SurfaceTool` now contains one vertex of a triangle which has a UV coordinate and a specified :ref:`Color`. If another vertex were added without calls to :ref:`add_uv` or :ref:`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`, failure to do this will result in an error when committing the vertex information to a mesh. Member Function Description --------------------------- .. _class_SurfaceTool_add_bones: - void **add_bones** **(** :ref:`PoolIntArray` bones **)** Add an array of bones for the next Vertex to use. Add an array of bones for the next Vertex to use. .. _class_SurfaceTool_add_color: - void **add_color** **(** :ref:`Color` color **)** Specify a :ref:`Color` for the next Vertex to use. .. _class_SurfaceTool_add_index: - void **add_index** **(** :ref:`int` index **)** Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex. .. _class_SurfaceTool_add_normal: - void **add_normal** **(** :ref:`Vector3` normal **)** Specify a normal for the next Vertex to use. .. _class_SurfaceTool_add_smooth_group: - void **add_smooth_group** **(** :ref:`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. .. _class_SurfaceTool_add_tangent: - void **add_tangent** **(** :ref:`Plane` tangent **)** Specify a Tangent for the next Vertex to use. .. _class_SurfaceTool_add_to_format: - void **add_to_format** **(** :ref:`int` flags **)** .. _class_SurfaceTool_add_triangle_fan: - void **add_triangle_fan** **(** :ref:`PoolVector3Array` vertexes, :ref:`PoolVector2Array` uvs=PoolVector3Array( ), :ref:`PoolColorArray` colors=PoolVector2Array( ), :ref:`PoolVector2Array` uv2s=PoolColorArray( ), :ref:`PoolVector3Array` normals=PoolVector2Array( ), :ref:`Array` tangents=null **)** Insert a triangle fan made of array data into :ref:`Mesh` being constructed. Insert a triangle fan made of array data into :ref:`Mesh` being constructed. .. _class_SurfaceTool_add_uv: - void **add_uv** **(** :ref:`Vector2` uv **)** Specify UV Coordinate for next Vertex to use. .. _class_SurfaceTool_add_uv2: - void **add_uv2** **(** :ref:`Vector2` uv2 **)** Specify an optional second set of UV coordinates for next Vertex to use. .. _class_SurfaceTool_add_vertex: - void **add_vertex** **(** :ref:`Vector3` vertex **)** Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV). .. _class_SurfaceTool_add_weights: - void **add_weights** **(** :ref:`PoolRealArray` weights **)** Specify weight value for next Vertex to use. .. _class_SurfaceTool_append_from: - void **append_from** **(** :ref:`Mesh` existing, :ref:`int` surface, :ref:`Transform` transform **)** Specify weight value for next Vertex to use. .. _class_SurfaceTool_append_from: - void **append_from** **(** :ref:`Mesh` existing, :ref:`int` surface, :ref:`Transform` transform **)** .. _class_SurfaceTool_begin: - void **begin** **(** :ref:`int` primitive **)** Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES). .. _class_SurfaceTool_clear: - void **clear** **(** **)** Clear all information passed into the surface tool so far. .. _class_SurfaceTool_commit: - :ref:`ArrayMesh` **commit** **(** :ref:`ArrayMesh` existing=null **)** Returns a constructed :ref:`ArrayMesh` from current information passed in. If an existing :ref:`ArrayMesh` is passed in as an argument, will add an extra surface to the existing :ref:`ArrayMesh`. .. _class_SurfaceTool_create_from: - void **create_from** **(** :ref:`Mesh` existing, :ref:`int` surface **)** Returns a constructed :ref:`Mesh` from current information passed in. If an existing :ref:`Mesh` is passed in as an argument, will add an extra surface to the existing :ref:`Mesh`. .. _class_SurfaceTool_create_from: - void **create_from** **(** :ref:`Mesh` existing, :ref:`int` surface **)** .. _class_SurfaceTool_deindex: - void **deindex** **(** **)** Removes index array by expanding Vertex array. .. _class_SurfaceTool_generate_normals: - void **generate_normals** **(** **)** Generates normals from Vertices so you do not have to do it manually. .. _class_SurfaceTool_generate_tangents: - void **generate_tangents** **(** **)** .. _class_SurfaceTool_index: - void **index** **(** **)** Shrinks Vertex array by creating an index array. Avoids reusing Vertices. .. _class_SurfaceTool_set_material: - void **set_material** **(** :ref:`Material` material **)** Sets :ref:`Material` to be used by the :ref:`Mesh` you are constructing.