class_surfacetool.rst 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SurfaceTool.xml.
  6. .. _class_SurfaceTool:
  7. SurfaceTool
  8. ===========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Helper tool to create geometry.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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:
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. var st = SurfaceTool.new()
  18. st.begin(Mesh.PRIMITIVE_TRIANGLES)
  19. st.set_color(Color(1, 0, 0))
  20. st.set_uv(Vector2(0, 0))
  21. st.add_vertex(Vector3(0, 0, 0))
  22. .. code-tab:: csharp
  23. var st = new SurfaceTool();
  24. st.Begin(Mesh.PrimitiveType.Triangles);
  25. st.SetColor(new Color(1, 0, 0));
  26. st.SetUV(new Vector2(0, 0));
  27. st.AddVertex(new Vector3(0, 0, 0));
  28. 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.
  29. 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.
  30. 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.
  31. See also :ref:`ArrayMesh<class_ArrayMesh>`, :ref:`ImmediateMesh<class_ImmediateMesh>` and :ref:`MeshDataTool<class_MeshDataTool>` for procedural geometry generation.
  32. \ **Note:** Godot uses clockwise `winding order <https://learnopengl.com/Advanced-OpenGL/Face-culling>`__ for front faces of triangle primitive modes.
  33. .. rst-class:: classref-introduction-group
  34. Tutorials
  35. ---------
  36. - :doc:`Using the SurfaceTool <../tutorials/3d/procedural_geometry/surfacetool>`
  37. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/2755>`__
  38. .. rst-class:: classref-reftable-group
  39. Methods
  40. -------
  41. .. table::
  42. :widths: auto
  43. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`add_index<class_SurfaceTool_method_add_index>`\ (\ index\: :ref:`int<class_int>`\ ) |
  45. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | |void| | :ref:`add_triangle_fan<class_SurfaceTool_method_add_triangle_fan>`\ (\ vertices\: :ref:`PackedVector3Array<class_PackedVector3Array>`, uvs\: :ref:`PackedVector2Array<class_PackedVector2Array>` = PackedVector2Array(), colors\: :ref:`PackedColorArray<class_PackedColorArray>` = PackedColorArray(), uv2s\: :ref:`PackedVector2Array<class_PackedVector2Array>` = PackedVector2Array(), normals\: :ref:`PackedVector3Array<class_PackedVector3Array>` = PackedVector3Array(), tangents\: :ref:`Array<class_Array>`\[:ref:`Plane<class_Plane>`\] = []\ ) |
  47. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`add_vertex<class_SurfaceTool_method_add_vertex>`\ (\ vertex\: :ref:`Vector3<class_Vector3>`\ ) |
  49. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`append_from<class_SurfaceTool_method_append_from>`\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`, transform\: :ref:`Transform3D<class_Transform3D>`\ ) |
  51. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | |void| | :ref:`begin<class_SurfaceTool_method_begin>`\ (\ primitive\: :ref:`PrimitiveType<enum_Mesh_PrimitiveType>`\ ) |
  53. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | |void| | :ref:`clear<class_SurfaceTool_method_clear>`\ (\ ) |
  55. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`commit<class_SurfaceTool_method_commit>`\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null, flags\: :ref:`int<class_int>` = 0\ ) |
  57. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Array<class_Array>` | :ref:`commit_to_arrays<class_SurfaceTool_method_commit_to_arrays>`\ (\ ) |
  59. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | |void| | :ref:`create_from<class_SurfaceTool_method_create_from>`\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`\ ) |
  61. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`create_from_arrays<class_SurfaceTool_method_create_from_arrays>`\ (\ arrays\: :ref:`Array<class_Array>`, primitive_type\: :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` = 3\ ) |
  63. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | |void| | :ref:`create_from_blend_shape<class_SurfaceTool_method_create_from_blend_shape>`\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`, blend_shape\: :ref:`String<class_String>`\ ) |
  65. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | |void| | :ref:`deindex<class_SurfaceTool_method_deindex>`\ (\ ) |
  67. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`generate_lod<class_SurfaceTool_method_generate_lod>`\ (\ nd_threshold\: :ref:`float<class_float>`, target_index_count\: :ref:`int<class_int>` = 3\ ) |
  69. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | |void| | :ref:`generate_normals<class_SurfaceTool_method_generate_normals>`\ (\ flip\: :ref:`bool<class_bool>` = false\ ) |
  71. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | |void| | :ref:`generate_tangents<class_SurfaceTool_method_generate_tangents>`\ (\ ) |
  73. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`AABB<class_AABB>` | :ref:`get_aabb<class_SurfaceTool_method_get_aabb>`\ (\ ) |const| |
  75. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` | :ref:`get_custom_format<class_SurfaceTool_method_get_custom_format>`\ (\ channel_index\: :ref:`int<class_int>`\ ) |const| |
  77. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` | :ref:`get_primitive_type<class_SurfaceTool_method_get_primitive_type>`\ (\ ) |const| |
  79. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` | :ref:`get_skin_weight_count<class_SurfaceTool_method_get_skin_weight_count>`\ (\ ) |const| |
  81. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | |void| | :ref:`index<class_SurfaceTool_method_index>`\ (\ ) |
  83. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | |void| | :ref:`optimize_indices_for_cache<class_SurfaceTool_method_optimize_indices_for_cache>`\ (\ ) |
  85. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | |void| | :ref:`set_bones<class_SurfaceTool_method_set_bones>`\ (\ bones\: :ref:`PackedInt32Array<class_PackedInt32Array>`\ ) |
  87. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | |void| | :ref:`set_color<class_SurfaceTool_method_set_color>`\ (\ color\: :ref:`Color<class_Color>`\ ) |
  89. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | |void| | :ref:`set_custom<class_SurfaceTool_method_set_custom>`\ (\ channel_index\: :ref:`int<class_int>`, custom_color\: :ref:`Color<class_Color>`\ ) |
  91. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | |void| | :ref:`set_custom_format<class_SurfaceTool_method_set_custom_format>`\ (\ channel_index\: :ref:`int<class_int>`, format\: :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>`\ ) |
  93. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | |void| | :ref:`set_material<class_SurfaceTool_method_set_material>`\ (\ material\: :ref:`Material<class_Material>`\ ) |
  95. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | |void| | :ref:`set_normal<class_SurfaceTool_method_set_normal>`\ (\ normal\: :ref:`Vector3<class_Vector3>`\ ) |
  97. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | |void| | :ref:`set_skin_weight_count<class_SurfaceTool_method_set_skin_weight_count>`\ (\ count\: :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>`\ ) |
  99. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | |void| | :ref:`set_smooth_group<class_SurfaceTool_method_set_smooth_group>`\ (\ index\: :ref:`int<class_int>`\ ) |
  101. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | |void| | :ref:`set_tangent<class_SurfaceTool_method_set_tangent>`\ (\ tangent\: :ref:`Plane<class_Plane>`\ ) |
  103. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | |void| | :ref:`set_uv<class_SurfaceTool_method_set_uv>`\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) |
  105. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | |void| | :ref:`set_uv2<class_SurfaceTool_method_set_uv2>`\ (\ uv2\: :ref:`Vector2<class_Vector2>`\ ) |
  107. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | |void| | :ref:`set_weights<class_SurfaceTool_method_set_weights>`\ (\ weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) |
  109. +----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. .. rst-class:: classref-section-separator
  111. ----
  112. .. rst-class:: classref-descriptions-group
  113. Enumerations
  114. ------------
  115. .. _enum_SurfaceTool_CustomFormat:
  116. .. rst-class:: classref-enumeration
  117. enum **CustomFormat**: :ref:`๐Ÿ”—<enum_SurfaceTool_CustomFormat>`
  118. .. _class_SurfaceTool_constant_CUSTOM_RGBA8_UNORM:
  119. .. rst-class:: classref-enumeration-constant
  120. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RGBA8_UNORM** = ``0``
  121. Limits range of data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` to unsigned normalized 0 to 1 stored in 8 bits per channel. See :ref:`Mesh.ARRAY_CUSTOM_RGBA8_UNORM<class_Mesh_constant_ARRAY_CUSTOM_RGBA8_UNORM>`.
  122. .. _class_SurfaceTool_constant_CUSTOM_RGBA8_SNORM:
  123. .. rst-class:: classref-enumeration-constant
  124. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RGBA8_SNORM** = ``1``
  125. Limits range of data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` to signed normalized -1 to 1 stored in 8 bits per channel. See :ref:`Mesh.ARRAY_CUSTOM_RGBA8_SNORM<class_Mesh_constant_ARRAY_CUSTOM_RGBA8_SNORM>`.
  126. .. _class_SurfaceTool_constant_CUSTOM_RG_HALF:
  127. .. rst-class:: classref-enumeration-constant
  128. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RG_HALF** = ``2``
  129. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as half precision floats, and uses only red and green color channels. See :ref:`Mesh.ARRAY_CUSTOM_RG_HALF<class_Mesh_constant_ARRAY_CUSTOM_RG_HALF>`.
  130. .. _class_SurfaceTool_constant_CUSTOM_RGBA_HALF:
  131. .. rst-class:: classref-enumeration-constant
  132. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RGBA_HALF** = ``3``
  133. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as half precision floats and uses all color channels. See :ref:`Mesh.ARRAY_CUSTOM_RGBA_HALF<class_Mesh_constant_ARRAY_CUSTOM_RGBA_HALF>`.
  134. .. _class_SurfaceTool_constant_CUSTOM_R_FLOAT:
  135. .. rst-class:: classref-enumeration-constant
  136. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_R_FLOAT** = ``4``
  137. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as full precision floats, and uses only red color channel. See :ref:`Mesh.ARRAY_CUSTOM_R_FLOAT<class_Mesh_constant_ARRAY_CUSTOM_R_FLOAT>`.
  138. .. _class_SurfaceTool_constant_CUSTOM_RG_FLOAT:
  139. .. rst-class:: classref-enumeration-constant
  140. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RG_FLOAT** = ``5``
  141. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as full precision floats, and uses only red and green color channels. See :ref:`Mesh.ARRAY_CUSTOM_RG_FLOAT<class_Mesh_constant_ARRAY_CUSTOM_RG_FLOAT>`.
  142. .. _class_SurfaceTool_constant_CUSTOM_RGB_FLOAT:
  143. .. rst-class:: classref-enumeration-constant
  144. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RGB_FLOAT** = ``6``
  145. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as full precision floats, and uses only red, green and blue color channels. See :ref:`Mesh.ARRAY_CUSTOM_RGB_FLOAT<class_Mesh_constant_ARRAY_CUSTOM_RGB_FLOAT>`.
  146. .. _class_SurfaceTool_constant_CUSTOM_RGBA_FLOAT:
  147. .. rst-class:: classref-enumeration-constant
  148. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_RGBA_FLOAT** = ``7``
  149. Stores data passed to :ref:`set_custom()<class_SurfaceTool_method_set_custom>` as full precision floats, and uses all color channels. See :ref:`Mesh.ARRAY_CUSTOM_RGBA_FLOAT<class_Mesh_constant_ARRAY_CUSTOM_RGBA_FLOAT>`.
  150. .. _class_SurfaceTool_constant_CUSTOM_MAX:
  151. .. rst-class:: classref-enumeration-constant
  152. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **CUSTOM_MAX** = ``8``
  153. Used to indicate a disabled custom channel.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _enum_SurfaceTool_SkinWeightCount:
  157. .. rst-class:: classref-enumeration
  158. enum **SkinWeightCount**: :ref:`๐Ÿ”—<enum_SurfaceTool_SkinWeightCount>`
  159. .. _class_SurfaceTool_constant_SKIN_4_WEIGHTS:
  160. .. rst-class:: classref-enumeration-constant
  161. :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` **SKIN_4_WEIGHTS** = ``0``
  162. Each individual vertex can be influenced by only 4 bone weights.
  163. .. _class_SurfaceTool_constant_SKIN_8_WEIGHTS:
  164. .. rst-class:: classref-enumeration-constant
  165. :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` **SKIN_8_WEIGHTS** = ``1``
  166. Each individual vertex can be influenced by up to 8 bone weights.
  167. .. rst-class:: classref-section-separator
  168. ----
  169. .. rst-class:: classref-descriptions-group
  170. Method Descriptions
  171. -------------------
  172. .. _class_SurfaceTool_method_add_index:
  173. .. rst-class:: classref-method
  174. |void| **add_index**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_add_index>`
  175. Adds a vertex to index array if you are using indexed vertices. Does not need to be called before adding vertices.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_SurfaceTool_method_add_triangle_fan:
  179. .. rst-class:: classref-method
  180. |void| **add_triangle_fan**\ (\ vertices\: :ref:`PackedVector3Array<class_PackedVector3Array>`, uvs\: :ref:`PackedVector2Array<class_PackedVector2Array>` = PackedVector2Array(), colors\: :ref:`PackedColorArray<class_PackedColorArray>` = PackedColorArray(), uv2s\: :ref:`PackedVector2Array<class_PackedVector2Array>` = PackedVector2Array(), normals\: :ref:`PackedVector3Array<class_PackedVector3Array>` = PackedVector3Array(), tangents\: :ref:`Array<class_Array>`\[:ref:`Plane<class_Plane>`\] = []\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_add_triangle_fan>`
  181. Inserts a triangle fan made of array data into :ref:`Mesh<class_Mesh>` being constructed.
  182. Requires the primitive type be set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_SurfaceTool_method_add_vertex:
  186. .. rst-class:: classref-method
  187. |void| **add_vertex**\ (\ vertex\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_add_vertex>`
  188. Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_SurfaceTool_method_append_from:
  192. .. rst-class:: classref-method
  193. |void| **append_from**\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`, transform\: :ref:`Transform3D<class_Transform3D>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_append_from>`
  194. Append vertices from a given :ref:`Mesh<class_Mesh>` surface onto the current vertex array with specified :ref:`Transform3D<class_Transform3D>`.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_SurfaceTool_method_begin:
  198. .. rst-class:: classref-method
  199. |void| **begin**\ (\ primitive\: :ref:`PrimitiveType<enum_Mesh_PrimitiveType>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_begin>`
  200. Called before adding any vertices. Takes the primitive type as an argument (e.g. :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`).
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_SurfaceTool_method_clear:
  204. .. rst-class:: classref-method
  205. |void| **clear**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_clear>`
  206. Clear all information passed into the surface tool so far.
  207. .. rst-class:: classref-item-separator
  208. ----
  209. .. _class_SurfaceTool_method_commit:
  210. .. rst-class:: classref-method
  211. :ref:`ArrayMesh<class_ArrayMesh>` **commit**\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null, flags\: :ref:`int<class_int>` = 0\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_commit>`
  212. 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>`.
  213. The ``flags`` argument can be the bitwise OR of :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_SurfaceTool_method_commit_to_arrays:
  217. .. rst-class:: classref-method
  218. :ref:`Array<class_Array>` **commit_to_arrays**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_commit_to_arrays>`
  219. Commits the data to the same format used by :ref:`ArrayMesh.add_surface_from_arrays()<class_ArrayMesh_method_add_surface_from_arrays>`, :ref:`ImporterMesh.add_surface()<class_ImporterMesh_method_add_surface>`, and :ref:`create_from_arrays()<class_SurfaceTool_method_create_from_arrays>`. This way you can further process the mesh data using the :ref:`ArrayMesh<class_ArrayMesh>` or :ref:`ImporterMesh<class_ImporterMesh>` APIs.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_SurfaceTool_method_create_from:
  223. .. rst-class:: classref-method
  224. |void| **create_from**\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_create_from>`
  225. Creates a vertex array from an existing :ref:`Mesh<class_Mesh>`.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_SurfaceTool_method_create_from_arrays:
  229. .. rst-class:: classref-method
  230. |void| **create_from_arrays**\ (\ arrays\: :ref:`Array<class_Array>`, primitive_type\: :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` = 3\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_create_from_arrays>`
  231. Creates this SurfaceTool from existing vertex arrays such as returned by :ref:`commit_to_arrays()<class_SurfaceTool_method_commit_to_arrays>`, :ref:`Mesh.surface_get_arrays()<class_Mesh_method_surface_get_arrays>`, :ref:`Mesh.surface_get_blend_shape_arrays()<class_Mesh_method_surface_get_blend_shape_arrays>`, :ref:`ImporterMesh.get_surface_arrays()<class_ImporterMesh_method_get_surface_arrays>`, and :ref:`ImporterMesh.get_surface_blend_shape_arrays()<class_ImporterMesh_method_get_surface_blend_shape_arrays>`. ``primitive_type`` controls the type of mesh data, defaulting to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_SurfaceTool_method_create_from_blend_shape:
  235. .. rst-class:: classref-method
  236. |void| **create_from_blend_shape**\ (\ existing\: :ref:`Mesh<class_Mesh>`, surface\: :ref:`int<class_int>`, blend_shape\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_create_from_blend_shape>`
  237. Creates a vertex array from the specified blend shape of an existing :ref:`Mesh<class_Mesh>`. This can be used to extract a specific pose from a blend shape.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_SurfaceTool_method_deindex:
  241. .. rst-class:: classref-method
  242. |void| **deindex**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_deindex>`
  243. Removes the index array by expanding the vertex array.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_SurfaceTool_method_generate_lod:
  247. .. rst-class:: classref-method
  248. :ref:`PackedInt32Array<class_PackedInt32Array>` **generate_lod**\ (\ nd_threshold\: :ref:`float<class_float>`, target_index_count\: :ref:`int<class_int>` = 3\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_generate_lod>`
  249. **Deprecated:** This method is unused internally, as it does not preserve normals or UVs. Consider using :ref:`ImporterMesh.generate_lods()<class_ImporterMesh_method_generate_lods>` instead.
  250. Generates an LOD for a given ``nd_threshold`` in linear units (square root of quadric error metric), using at most ``target_index_count`` indices.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_SurfaceTool_method_generate_normals:
  254. .. rst-class:: classref-method
  255. |void| **generate_normals**\ (\ flip\: :ref:`bool<class_bool>` = false\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_generate_normals>`
  256. 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>`.
  257. \ **Note:** :ref:`generate_normals()<class_SurfaceTool_method_generate_normals>` only works if the primitive type is set to :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
  258. \ **Note:** :ref:`generate_normals()<class_SurfaceTool_method_generate_normals>` takes smooth groups into account. To generate smooth normals, set the smooth group to a value greater than or equal to ``0`` using :ref:`set_smooth_group()<class_SurfaceTool_method_set_smooth_group>` or leave the smooth group at the default of ``0``. To generate flat normals, set the smooth group to ``-1`` using :ref:`set_smooth_group()<class_SurfaceTool_method_set_smooth_group>` prior to adding vertices.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_SurfaceTool_method_generate_tangents:
  262. .. rst-class:: classref-method
  263. |void| **generate_tangents**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_generate_tangents>`
  264. Generates a tangent vector for each vertex. Requires that each vertex already has UVs and normals set (see :ref:`generate_normals()<class_SurfaceTool_method_generate_normals>`).
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_SurfaceTool_method_get_aabb:
  268. .. rst-class:: classref-method
  269. :ref:`AABB<class_AABB>` **get_aabb**\ (\ ) |const| :ref:`๐Ÿ”—<class_SurfaceTool_method_get_aabb>`
  270. Returns the axis-aligned bounding box of the vertex positions.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_SurfaceTool_method_get_custom_format:
  274. .. rst-class:: classref-method
  275. :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>` **get_custom_format**\ (\ channel_index\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_SurfaceTool_method_get_custom_format>`
  276. Returns the format for custom ``channel_index`` (currently up to 4). Returns :ref:`CUSTOM_MAX<class_SurfaceTool_constant_CUSTOM_MAX>` if this custom channel is unused.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_SurfaceTool_method_get_primitive_type:
  280. .. rst-class:: classref-method
  281. :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` **get_primitive_type**\ (\ ) |const| :ref:`๐Ÿ”—<class_SurfaceTool_method_get_primitive_type>`
  282. Returns the type of mesh geometry, such as :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_SurfaceTool_method_get_skin_weight_count:
  286. .. rst-class:: classref-method
  287. :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>` **get_skin_weight_count**\ (\ ) |const| :ref:`๐Ÿ”—<class_SurfaceTool_method_get_skin_weight_count>`
  288. By default, returns :ref:`SKIN_4_WEIGHTS<class_SurfaceTool_constant_SKIN_4_WEIGHTS>` to indicate only 4 bone influences per vertex are used.
  289. Returns :ref:`SKIN_8_WEIGHTS<class_SurfaceTool_constant_SKIN_8_WEIGHTS>` if up to 8 influences are used.
  290. \ **Note:** This function returns an enum, not the exact number of weights.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_SurfaceTool_method_index:
  294. .. rst-class:: classref-method
  295. |void| **index**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_index>`
  296. Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_SurfaceTool_method_optimize_indices_for_cache:
  300. .. rst-class:: classref-method
  301. |void| **optimize_indices_for_cache**\ (\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_optimize_indices_for_cache>`
  302. Optimizes triangle sorting for performance. Requires that :ref:`get_primitive_type()<class_SurfaceTool_method_get_primitive_type>` is :ref:`Mesh.PRIMITIVE_TRIANGLES<class_Mesh_constant_PRIMITIVE_TRIANGLES>`.
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_SurfaceTool_method_set_bones:
  306. .. rst-class:: classref-method
  307. |void| **set_bones**\ (\ bones\: :ref:`PackedInt32Array<class_PackedInt32Array>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_bones>`
  308. Specifies an array of bones to use for the *next* vertex. ``bones`` must contain 4 integers.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_SurfaceTool_method_set_color:
  312. .. rst-class:: classref-method
  313. |void| **set_color**\ (\ color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_color>`
  314. 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.
  315. \ **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.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_SurfaceTool_method_set_custom:
  319. .. rst-class:: classref-method
  320. |void| **set_custom**\ (\ channel_index\: :ref:`int<class_int>`, custom_color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_custom>`
  321. Sets the custom value on this vertex for ``channel_index``.
  322. \ :ref:`set_custom_format()<class_SurfaceTool_method_set_custom_format>` must be called first for this ``channel_index``. Formats which are not RGBA will ignore other color channels.
  323. .. rst-class:: classref-item-separator
  324. ----
  325. .. _class_SurfaceTool_method_set_custom_format:
  326. .. rst-class:: classref-method
  327. |void| **set_custom_format**\ (\ channel_index\: :ref:`int<class_int>`, format\: :ref:`CustomFormat<enum_SurfaceTool_CustomFormat>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_custom_format>`
  328. Sets the color format for this custom ``channel_index``. Use :ref:`CUSTOM_MAX<class_SurfaceTool_constant_CUSTOM_MAX>` to disable.
  329. Must be invoked after :ref:`begin()<class_SurfaceTool_method_begin>` and should be set before :ref:`commit()<class_SurfaceTool_method_commit>` or :ref:`commit_to_arrays()<class_SurfaceTool_method_commit_to_arrays>`.
  330. .. rst-class:: classref-item-separator
  331. ----
  332. .. _class_SurfaceTool_method_set_material:
  333. .. rst-class:: classref-method
  334. |void| **set_material**\ (\ material\: :ref:`Material<class_Material>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_material>`
  335. Sets :ref:`Material<class_Material>` to be used by the :ref:`Mesh<class_Mesh>` you are constructing.
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_SurfaceTool_method_set_normal:
  339. .. rst-class:: classref-method
  340. |void| **set_normal**\ (\ normal\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_normal>`
  341. 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.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_SurfaceTool_method_set_skin_weight_count:
  345. .. rst-class:: classref-method
  346. |void| **set_skin_weight_count**\ (\ count\: :ref:`SkinWeightCount<enum_SurfaceTool_SkinWeightCount>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_skin_weight_count>`
  347. Set to :ref:`SKIN_8_WEIGHTS<class_SurfaceTool_constant_SKIN_8_WEIGHTS>` to indicate that up to 8 bone influences per vertex may be used.
  348. By default, only 4 bone influences are used (:ref:`SKIN_4_WEIGHTS<class_SurfaceTool_constant_SKIN_4_WEIGHTS>`).
  349. \ **Note:** This function takes an enum, not the exact number of weights.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_SurfaceTool_method_set_smooth_group:
  353. .. rst-class:: classref-method
  354. |void| **set_smooth_group**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_smooth_group>`
  355. Specifies the smooth group to use for the *next* vertex. If this is never called, all vertices will have the default smooth group of ``0`` and will be smoothed with adjacent vertices of the same group. To produce a mesh with flat normals, set the smooth group to ``-1``.
  356. \ **Note:** This function actually takes a ``uint32_t``, so C# users should use ``uint32.MaxValue`` instead of ``-1`` to produce a mesh with flat normals.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _class_SurfaceTool_method_set_tangent:
  360. .. rst-class:: classref-method
  361. |void| **set_tangent**\ (\ tangent\: :ref:`Plane<class_Plane>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_tangent>`
  362. 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.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_SurfaceTool_method_set_uv:
  366. .. rst-class:: classref-method
  367. |void| **set_uv**\ (\ uv\: :ref:`Vector2<class_Vector2>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_uv>`
  368. 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.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_SurfaceTool_method_set_uv2:
  372. .. rst-class:: classref-method
  373. |void| **set_uv2**\ (\ uv2\: :ref:`Vector2<class_Vector2>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_uv2>`
  374. 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.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_SurfaceTool_method_set_weights:
  378. .. rst-class:: classref-method
  379. |void| **set_weights**\ (\ weights\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) :ref:`๐Ÿ”—<class_SurfaceTool_method_set_weights>`
  380. 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.
  381. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  382. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  383. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  384. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  385. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  386. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  387. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  388. .. |void| replace:: :abbr:`void (No return value.)`