classref: Sync with latest 4.0-dev

This commit is contained in:
Rémi Verschelde
2021-10-06 11:19:07 +02:00
parent 6952796767
commit f6f6c1bf19
958 changed files with 113054 additions and 52009 deletions
+285 -126
View File
@@ -9,7 +9,7 @@
SurfaceTool
===========
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Helper tool to create geometry.
@@ -18,90 +18,171 @@ Description
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 a script. All properties except indices need to be added before calling :ref:`add_vertex<class_SurfaceTool_method_add_vertex>`. For example, to add vertex colors and UVs:
::
.. tabs::
.. code-tab:: gdscript
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))
st.set_color(Color(1, 0, 0))
st.set_uv(Vector2(0, 0))
st.set_vertex(Vector3(0, 0, 0))
The above ``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 calling :ref:`add_uv<class_SurfaceTool_method_add_uv>` or :ref:`add_color<class_SurfaceTool_method_add_color>`, then the last values would be used.
.. code-tab:: csharp
var st = new SurfaceTool();
st.Begin(Mesh.PrimitiveType.Triangles);
st.SetColor(new Color(1, 0, 0));
st.SetUv(new Vector2(0, 0));
st.SetVertex(new Vector3(0, 0, 0));
The above ``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 calling :ref:`set_uv<class_SurfaceTool_method_set_uv>` or :ref:`set_color<class_SurfaceTool_method_set_color>`, then the last values would be used.
Vertex attributes must be passed **before** calling :ref:`add_vertex<class_SurfaceTool_method_add_vertex>`. Failure to do so 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.
See also :ref:`ArrayMesh<class_ArrayMesh>`, :ref:`ImmediateMesh<class_ImmediateMesh>` and :ref:`MeshDataTool<class_MeshDataTool>` for procedural geometry generation.
**Note:** Godot uses clockwise `winding order <https://learnopengl.com/Advanced-OpenGL/Face-culling>`__ for front faces of triangle primitive modes.
Tutorials
---------
- `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
Methods
-------
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_bones<class_SurfaceTool_method_add_bones>` **(** :ref:`PackedInt32Array<class_PackedInt32Array>` bones **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_color<class_SurfaceTool_method_add_color>` **(** :ref:`Color<class_Color>` color **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_index<class_SurfaceTool_method_add_index>` **(** :ref:`int<class_int>` index **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_normal<class_SurfaceTool_method_add_normal>` **(** :ref:`Vector3<class_Vector3>` normal **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_smooth_group<class_SurfaceTool_method_add_smooth_group>` **(** :ref:`bool<class_bool>` smooth **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_tangent<class_SurfaceTool_method_add_tangent>` **(** :ref:`Plane<class_Plane>` tangent **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_triangle_fan<class_SurfaceTool_method_add_triangle_fan>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` vertices, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`PackedColorArray<class_PackedColorArray>` colors=PackedColorArray( ), :ref:`PackedVector2Array<class_PackedVector2Array>` uv2s=PackedVector2Array( ), :ref:`PackedVector3Array<class_PackedVector3Array>` normals=PackedVector3Array( ), :ref:`Array<class_Array>` tangents=[ ] **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_uv<class_SurfaceTool_method_add_uv>` **(** :ref:`Vector2<class_Vector2>` uv **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_uv2<class_SurfaceTool_method_add_uv2>` **(** :ref:`Vector2<class_Vector2>` uv2 **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_vertex<class_SurfaceTool_method_add_vertex>` **(** :ref:`Vector3<class_Vector3>` vertex **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_weights<class_SurfaceTool_method_add_weights>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` weights **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append_from<class_SurfaceTool_method_append_from>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_Transform>` transform **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`begin<class_SurfaceTool_method_begin>` **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_SurfaceTool_method_clear>` **(** **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`commit<class_SurfaceTool_method_commit>` **(** :ref:`ArrayMesh<class_ArrayMesh>` existing=null, :ref:`int<class_int>` flags=31744 **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`commit_to_arrays<class_SurfaceTool_method_commit_to_arrays>` **(** **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_from<class_SurfaceTool_method_create_from>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_from_blend_shape<class_SurfaceTool_method_create_from_blend_shape>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`String<class_String>` blend_shape **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`deindex<class_SurfaceTool_method_deindex>` **(** **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`generate_normals<class_SurfaceTool_method_generate_normals>` **(** :ref:`bool<class_bool>` flip=false **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`generate_tangents<class_SurfaceTool_method_generate_tangents>` **(** **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`index<class_SurfaceTool_method_index>` **(** **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_material<class_SurfaceTool_method_set_material>` **(** :ref:`Material<class_Material>` material **)** |
+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_index<class_SurfaceTool_method_add_index>` **(** :ref:`int<class_int>` index **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_triangle_fan<class_SurfaceTool_method_add_triangle_fan>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` vertices, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array(), :ref:`PackedColorArray<class_PackedColorArray>` colors=PackedColorArray(), :ref:`PackedVector2Array<class_PackedVector2Array>` uv2s=PackedVector2Array(), :ref:`PackedVector3Array<class_PackedVector3Array>` normals=PackedVector3Array(), :ref:`Array<class_Array>` tangents=[] **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_vertex<class_SurfaceTool_method_add_vertex>` **(** :ref:`Vector3<class_Vector3>` vertex **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append_from<class_SurfaceTool_method_append_from>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform3D<class_Transform3D>` transform **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`begin<class_SurfaceTool_method_begin>` **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_SurfaceTool_method_clear>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`commit<class_SurfaceTool_method_commit>` **(** :ref:`ArrayMesh<class_ArrayMesh>` existing=null, :ref:`int<class_int>` flags=0 **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`commit_to_arrays<class_SurfaceTool_method_commit_to_arrays>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_from<class_SurfaceTool_method_create_from>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_from_blend_shape<class_SurfaceTool_method_create_from_blend_shape>` **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`String<class_String>` blend_shape **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`deindex<class_SurfaceTool_method_deindex>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`generate_lod<class_SurfaceTool_method_generate_lod>` **(** :ref:`float<class_float>` nd_threshold, :ref:`int<class_int>` target_index_count=3 **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`generate_normals<class_SurfaceTool_method_generate_normals>` **(** :ref:`bool<class_bool>` flip=false **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`generate_tangents<class_SurfaceTool_method_generate_tangents>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` | :ref:`get_custom_format<class_SurfaceTool_method_get_custom_format>` **(** :ref:`int<class_int>` index **)** |const| |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_max_axis_length<class_SurfaceTool_method_get_max_axis_length>` **(** **)** |const| |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` | :ref:`get_primitive<class_SurfaceTool_method_get_primitive>` **(** **)** |const| |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` | :ref:`get_skin_weight_count<class_SurfaceTool_method_get_skin_weight_count>` **(** **)** |const| |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`index<class_SurfaceTool_method_index>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`optimize_indices_for_cache<class_SurfaceTool_method_optimize_indices_for_cache>` **(** **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_bones<class_SurfaceTool_method_set_bones>` **(** :ref:`PackedInt32Array<class_PackedInt32Array>` bones **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_color<class_SurfaceTool_method_set_color>` **(** :ref:`Color<class_Color>` color **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_custom<class_SurfaceTool_method_set_custom>` **(** :ref:`int<class_int>` index, :ref:`Color<class_Color>` custom **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_custom_format<class_SurfaceTool_method_set_custom_format>` **(** :ref:`int<class_int>` index, :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` format **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_material<class_SurfaceTool_method_set_material>` **(** :ref:`Material<class_Material>` material **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_normal<class_SurfaceTool_method_set_normal>` **(** :ref:`Vector3<class_Vector3>` normal **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_skin_weight_count<class_SurfaceTool_method_set_skin_weight_count>` **(** :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` count **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_smooth_group<class_SurfaceTool_method_set_smooth_group>` **(** :ref:`int<class_int>` index **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_tangent<class_SurfaceTool_method_set_tangent>` **(** :ref:`Plane<class_Plane>` tangent **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_uv<class_SurfaceTool_method_set_uv>` **(** :ref:`Vector2<class_Vector2>` uv **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_uv2<class_SurfaceTool_method_set_uv2>` **(** :ref:`Vector2<class_Vector2>` uv2 **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_weights<class_SurfaceTool_method_set_weights>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` weights **)** |
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Enumerations
------------
.. _enum_SurfaceTool_CustomFormat:
.. _class_SurfaceTool_constant_CUSTOM_RGBA8_UNORM:
.. _class_SurfaceTool_constant_CUSTOM_RGBA8_SNORM:
.. _class_SurfaceTool_constant_CUSTOM_RG_HALF:
.. _class_SurfaceTool_constant_CUSTOM_RGBA_HALF:
.. _class_SurfaceTool_constant_CUSTOM_R_FLOAT:
.. _class_SurfaceTool_constant_CUSTOM_RG_FLOAT:
.. _class_SurfaceTool_constant_CUSTOM_RGB_FLOAT:
.. _class_SurfaceTool_constant_CUSTOM_RGBA_FLOAT:
.. _class_SurfaceTool_constant_CUSTOM_MAX:
enum **CustomFormat**:
- **CUSTOM_RGBA8_UNORM** = **0**
- **CUSTOM_RGBA8_SNORM** = **1**
- **CUSTOM_RG_HALF** = **2**
- **CUSTOM_RGBA_HALF** = **3**
- **CUSTOM_R_FLOAT** = **4**
- **CUSTOM_RG_FLOAT** = **5**
- **CUSTOM_RGB_FLOAT** = **6**
- **CUSTOM_RGBA_FLOAT** = **7**
- **CUSTOM_MAX** = **8**
----
.. _enum_SurfaceTool_SkinWeightCount:
.. _class_SurfaceTool_constant_SKIN_4_WEIGHTS:
.. _class_SurfaceTool_constant_SKIN_8_WEIGHTS:
enum **SkinWeightCount**:
- **SKIN_4_WEIGHTS** = **0**
- **SKIN_8_WEIGHTS** = **1**
Method Descriptions
-------------------
.. _class_SurfaceTool_method_add_bones:
- void **add_bones** **(** :ref:`PackedInt32Array<class_PackedInt32Array>` bones **)**
Adds an array of bones for the next vertex to use. ``bones`` must contain 4 integers.
----
.. _class_SurfaceTool_method_add_color:
- void **add_color** **(** :ref:`Color<class_Color>` color **)**
Specifies a :ref:`Color<class_Color>` for the next vertex to use.
----
.. _class_SurfaceTool_method_add_index:
- void **add_index** **(** :ref:`int<class_int>` index **)**
@@ -110,33 +191,9 @@ Adds an index to index array if you are using indexed vertices. Does not need to
----
.. _class_SurfaceTool_method_add_normal:
- void **add_normal** **(** :ref:`Vector3<class_Vector3>` normal **)**
Specifies a normal for the next vertex to use.
----
.. _class_SurfaceTool_method_add_smooth_group:
- void **add_smooth_group** **(** :ref:`bool<class_bool>` smooth **)**
Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
----
.. _class_SurfaceTool_method_add_tangent:
- void **add_tangent** **(** :ref:`Plane<class_Plane>` tangent **)**
Specifies a tangent for the next vertex to use.
----
.. _class_SurfaceTool_method_add_triangle_fan:
- void **add_triangle_fan** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` vertices, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`PackedColorArray<class_PackedColorArray>` colors=PackedColorArray( ), :ref:`PackedVector2Array<class_PackedVector2Array>` uv2s=PackedVector2Array( ), :ref:`PackedVector3Array<class_PackedVector3Array>` normals=PackedVector3Array( ), :ref:`Array<class_Array>` tangents=[ ] **)**
- void **add_triangle_fan** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` vertices, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array(), :ref:`PackedColorArray<class_PackedColorArray>` colors=PackedColorArray(), :ref:`PackedVector2Array<class_PackedVector2Array>` uv2s=PackedVector2Array(), :ref:`PackedVector3Array<class_PackedVector3Array>` normals=PackedVector3Array(), :ref:`Array<class_Array>` tangents=[] **)**
Inserts a triangle fan made of array data into :ref:`Mesh<class_Mesh>` being constructed.
@@ -144,22 +201,6 @@ Requires the primitive type be set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_
----
.. _class_SurfaceTool_method_add_uv:
- void **add_uv** **(** :ref:`Vector2<class_Vector2>` uv **)**
Specifies a set of UV coordinates to use for the next vertex.
----
.. _class_SurfaceTool_method_add_uv2:
- void **add_uv2** **(** :ref:`Vector2<class_Vector2>` uv2 **)**
Specifies an optional second set of UV coordinates to use for the next vertex.
----
.. _class_SurfaceTool_method_add_vertex:
- void **add_vertex** **(** :ref:`Vector3<class_Vector3>` vertex **)**
@@ -168,19 +209,11 @@ Specifies the position of current vertex. Should be called after specifying othe
----
.. _class_SurfaceTool_method_add_weights:
- void **add_weights** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` weights **)**
Specifies weight values for next vertex to use. ``weights`` must contain 4 values.
----
.. _class_SurfaceTool_method_append_from:
- void **append_from** **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_Transform>` transform **)**
- void **append_from** **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform3D<class_Transform3D>` transform **)**
Append vertices from a given :ref:`Mesh<class_Mesh>` surface onto the current vertex array with specified :ref:`Transform<class_Transform>`.
Append vertices from a given :ref:`Mesh<class_Mesh>` surface onto the current vertex array with specified :ref:`Transform3D<class_Transform3D>`.
----
@@ -202,11 +235,11 @@ Clear all information passed into the surface tool so far.
.. _class_SurfaceTool_method_commit:
- :ref:`ArrayMesh<class_ArrayMesh>` **commit** **(** :ref:`ArrayMesh<class_ArrayMesh>` existing=null, :ref:`int<class_int>` flags=31744 **)**
- :ref:`ArrayMesh<class_ArrayMesh>` **commit** **(** :ref:`ArrayMesh<class_ArrayMesh>` existing=null, :ref:`int<class_int>` flags=0 **)**
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>`.
Default flag is :ref:`Mesh.ARRAY_COMPRESS_DEFAULT<class_Mesh_constant_ARRAY_COMPRESS_DEFAULT>`. See ``ARRAY_COMPRESS_*`` constants in :ref:`ArrayFormat<enum_Mesh_ArrayFormat>` for other flags.
**FIXME:** Document possible values for ``flags``, it changed in 4.0. Likely some combinations of :ref:`ArrayFormat<enum_Mesh_ArrayFormat>`.
----
@@ -242,13 +275,19 @@ Removes the index array by expanding the vertex array.
----
.. _class_SurfaceTool_method_generate_lod:
- :ref:`PackedInt32Array<class_PackedInt32Array>` **generate_lod** **(** :ref:`float<class_float>` nd_threshold, :ref:`int<class_int>` target_index_count=3 **)**
----
.. _class_SurfaceTool_method_generate_normals:
- void **generate_normals** **(** :ref:`bool<class_bool>` flip=false **)**
Generates normals from vertices so you do not have to do it manually. If ``flip`` is ``true``, the resulting normals will be inverted.
Generates normals from vertices so you do not have to do it manually. If ``flip`` is ``true``, the resulting normals will be inverted. :ref:`generate_normals<class_SurfaceTool_method_generate_normals>` should be called *after* generating geometry and *before* committing the mesh using :ref:`commit<class_SurfaceTool_method_commit>` or :ref:`commit_to_arrays<class_SurfaceTool_method_commit_to_arrays>`. For correct display of normal-mapped surfaces, you will also have to generate tangents using :ref:`generate_tangents<class_SurfaceTool_method_generate_tangents>`.
Requires the primitive type to be set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
**Note:** :ref:`generate_normals<class_SurfaceTool_method_generate_normals>` only works if the primitive type to be set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
----
@@ -256,7 +295,31 @@ Requires the primitive type to be set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Me
- void **generate_tangents** **(** **)**
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already.
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already (see :ref:`generate_normals<class_SurfaceTool_method_generate_normals>`).
----
.. _class_SurfaceTool_method_get_custom_format:
- :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **get_custom_format** **(** :ref:`int<class_int>` index **)** |const|
----
.. _class_SurfaceTool_method_get_max_axis_length:
- :ref:`float<class_float>` **get_max_axis_length** **(** **)** |const|
----
.. _class_SurfaceTool_method_get_primitive:
- :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` **get_primitive** **(** **)** |const|
----
.. _class_SurfaceTool_method_get_skin_weight_count:
- :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` **get_skin_weight_count** **(** **)** |const|
----
@@ -264,7 +327,43 @@ Generates a tangent vector for each vertex. Requires that each vertex have UVs a
- void **index** **(** **)**
Shrinks the vertex array by creating an index array (avoids reusing vertices).
Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
----
.. _class_SurfaceTool_method_optimize_indices_for_cache:
- void **optimize_indices_for_cache** **(** **)**
----
.. _class_SurfaceTool_method_set_bones:
- void **set_bones** **(** :ref:`PackedInt32Array<class_PackedInt32Array>` bones **)**
Specifies an array of bones to use for the *next* vertex. ``bones`` must contain 4 integers.
----
.. _class_SurfaceTool_method_set_color:
- void **set_color** **(** :ref:`Color<class_Color>` color **)**
Specifies a :ref:`Color<class_Color>` to use for the *next* vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
**Note:** The material must have :ref:`BaseMaterial3D.vertex_color_use_as_albedo<class_BaseMaterial3D_property_vertex_color_use_as_albedo>` enabled for the vertex color to be visible.
----
.. _class_SurfaceTool_method_set_custom:
- void **set_custom** **(** :ref:`int<class_int>` index, :ref:`Color<class_Color>` custom **)**
----
.. _class_SurfaceTool_method_set_custom_format:
- void **set_custom_format** **(** :ref:`int<class_int>` index, :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` format **)**
----
@@ -274,3 +373,63 @@ Shrinks the vertex array by creating an index array (avoids reusing vertices).
Sets :ref:`Material<class_Material>` to be used by the :ref:`Mesh<class_Mesh>` you are constructing.
----
.. _class_SurfaceTool_method_set_normal:
- void **set_normal** **(** :ref:`Vector3<class_Vector3>` normal **)**
Specifies a normal to use for the *next* vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
----
.. _class_SurfaceTool_method_set_skin_weight_count:
- void **set_skin_weight_count** **(** :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` count **)**
----
.. _class_SurfaceTool_method_set_smooth_group:
- void **set_smooth_group** **(** :ref:`int<class_int>` index **)**
Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
----
.. _class_SurfaceTool_method_set_tangent:
- void **set_tangent** **(** :ref:`Plane<class_Plane>` tangent **)**
Specifies a tangent to use for the *next* vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
----
.. _class_SurfaceTool_method_set_uv:
- void **set_uv** **(** :ref:`Vector2<class_Vector2>` uv **)**
Specifies a set of UV coordinates to use for the *next* vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
----
.. _class_SurfaceTool_method_set_uv2:
- void **set_uv2** **(** :ref:`Vector2<class_Vector2>` uv2 **)**
Specifies an optional second set of UV coordinates to use for the *next* vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
----
.. _class_SurfaceTool_method_set_weights:
- void **set_weights** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` weights **)**
Specifies weight values to use for the *next* vertex. ``weights`` must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`