Files
godot-docs-l10n/classes/es/class_surfacetool.rst
Rémi Verschelde cf78697eea Add localized class reference as pre-generated RST files
Currently including `zh_CN` and `es` which both have very high completion
ratios. Others will be added once they reach a significant percentage too.

These RST files will be used by godot-docs in place of its `classes` folder
after we sync with https://github.com/godotengine/godot-docs/pull/5458.

The update workflow is manual for now (example for `zh_CN`):

- Build `godotengine/godot` in the branch we currently track (now `3.x`)
- Run `godot --doctool -l zh_CN`
- Run `cd doc && make rst LANGARG=zh_CN`
- Copy `doc/_build/rst/*` to `classes/zh_CN/` here
- Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
2021-12-21 16:07:55 +01:00

293 lines
35 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the SurfaceTool.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_SurfaceTool:
SurfaceTool
===========
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
Herramienta de ayuda para crear geometría.
Descripción
----------------------
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:
::
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 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.
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:`ImmediateGeometry<class_ImmediateGeometry>` 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.
Tutoriales
--------------------
- `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
Métodos
--------------
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_bones<class_SurfaceTool_method_add_bones>` **(** :ref:`PoolIntArray<class_PoolIntArray>` 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:`PoolVector3Array<class_PoolVector3Array>` vertices, :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=[ ] **)** |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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:`PoolRealArray<class_PoolRealArray>` 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=2194432 **)** |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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 **)** |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Descripciones de Métodos
------------------------------------------------
.. _class_SurfaceTool_method_add_bones:
- void **add_bones** **(** :ref:`PoolIntArray<class_PoolIntArray>` bones **)**
Specifies an array of bones to use for the *next* vertex. ``bones`` must contain 4 integers.
----
.. _class_SurfaceTool_method_add_color:
- void **add_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:`SpatialMaterial.vertex_color_use_as_albedo<class_SpatialMaterial_property_vertex_color_use_as_albedo>` enabled for the vertex color to be visible.
----
.. _class_SurfaceTool_method_add_index:
- void **add_index** **(** :ref:`int<class_int>` index **)**
Añade un índice a un array de índices si está usando vértices indexados. No es necesario llamar antes de añadir los vértices.
----
.. _class_SurfaceTool_method_add_normal:
- void **add_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_add_smooth_group:
- void **add_smooth_group** **(** :ref:`bool<class_bool>` smooth **)**
Especifica si el vértice actual (si se utilizan sólo arrays de vértices) o el índice actual (si también se utilizan arrays de índices) debe utilizar normales suaves para el cálculo normal.
----
.. _class_SurfaceTool_method_add_tangent:
- void **add_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_add_triangle_fan:
- void **add_triangle_fan** **(** :ref:`PoolVector3Array<class_PoolVector3Array>` vertices, :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=[ ] **)**
Inserta un triangulo fan hecho de un array de datos en la :ref:`Mesh<class_Mesh>` que se está construyendo.
Requiere que el tipo primitivo se establezca en :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
----
.. _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. 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_add_uv2:
- void **add_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_add_vertex:
- void **add_vertex** **(** :ref:`Vector3<class_Vector3>` vertex **)**
Especifica la posición del vértice actual. Debe ser llamado después de especificar otras propiedades del vértice (por ejemplo, Color, UV).
----
.. _class_SurfaceTool_method_add_weights:
- void **add_weights** **(** :ref:`PoolRealArray<class_PoolRealArray>` 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.
----
.. _class_SurfaceTool_method_append_from:
- void **append_from** **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_Transform>` transform **)**
Append vertices from a given :ref:`Mesh<class_Mesh>` surface onto the current vertex array with specified :ref:`Transform<class_Transform>`.
\ **Note:** Using :ref:`append_from<class_SurfaceTool_method_append_from>` on a :ref:`Thread<class_Thread>` is much slower as the GPU must communicate data back to the CPU, while also causing the main thread to stall (as OpenGL is not thread-safe). Consider requesting a copy of the mesh, converting it to an :ref:`ArrayMesh<class_ArrayMesh>` and adding vertices manually instead.
----
.. _class_SurfaceTool_method_begin:
- void **begin** **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive **)**
Llamado antes de añadir cualquier vértice. Toma el tipo primitivo como argumento (por ejemplo, :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`).
----
.. _class_SurfaceTool_method_clear:
- void **clear** **(** **)**
Despeja toda la información pasada a la herramienta de la superficie hasta ahora.
----
.. _class_SurfaceTool_method_commit:
- :ref:`ArrayMesh<class_ArrayMesh>` **commit** **(** :ref:`ArrayMesh<class_ArrayMesh>` existing=null, :ref:`int<class_int>` flags=2194432 **)**
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>` if compression is enabled. If compression is disabled the default flag is :ref:`Mesh.ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION<class_Mesh_constant_ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION>`. See ``ARRAY_COMPRESS_*`` constants in :ref:`ArrayFormat<enum_Mesh_ArrayFormat>` for other flags.
----
.. _class_SurfaceTool_method_commit_to_arrays:
- :ref:`Array<class_Array>` **commit_to_arrays** **(** **)**
Confirma los datos al mismo formato utilizado por el :ref:`ArrayMesh.add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`. De esta manera se puede seguir procesando los datos de la malla usando la API :ref:`ArrayMesh<class_ArrayMesh>`.
----
.. _class_SurfaceTool_method_create_from:
- void **create_from** **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface **)**
Crea un array de vértices a partir de una :ref:`Mesh<class_Mesh>` existente.
----
.. _class_SurfaceTool_method_create_from_blend_shape:
- void **create_from_blend_shape** **(** :ref:`Mesh<class_Mesh>` existing, :ref:`int<class_int>` surface, :ref:`String<class_String>` blend_shape **)**
Crea un array de vértices a partir de la forma de mezcla especificada de una :ref:`Mesh<class_Mesh>` existente. Esto puede ser usado para extraer una pose específica de una forma de mezcla.
----
.. _class_SurfaceTool_method_deindex:
- void **deindex** **(** **)**
Elimina el array de índices expandiendo el array de vértices.
----
.. _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. :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>`.
\ **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>`.
----
.. _class_SurfaceTool_method_generate_tangents:
- void **generate_tangents** **(** **)**
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_index:
- void **index** **(** **)**
Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
----
.. _class_SurfaceTool_method_set_material:
- void **set_material** **(** :ref:`Material<class_Material>` material **)**
Establece :ref:`Material<class_Material>` para ser usado por la :ref:`Mesh<class_Mesh>` que estás construyendo.
.. |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.)`