class_arraymesh.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the ArrayMesh.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_ArrayMesh:
  5. ArrayMesh
  6. =========
  7. **Inherits:** :ref:`Mesh<class_Mesh>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Properties
  12. ----------
  13. +-------------------------------------------------+--------------------------------------------------------------------+
  14. | :ref:`BlendShapeMode<enum_Mesh_BlendShapeMode>` | :ref:`blend_shape_mode<class_ArrayMesh_property_blend_shape_mode>` |
  15. +-------------------------------------------------+--------------------------------------------------------------------+
  16. | :ref:`AABB<class_AABB>` | :ref:`custom_aabb<class_ArrayMesh_property_custom_aabb>` |
  17. +-------------------------------------------------+--------------------------------------------------------------------+
  18. Methods
  19. -------
  20. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`add_blend_shape<class_ArrayMesh_method_add_blend_shape>` **(** :ref:`String<class_String>` name **)** |
  22. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>` **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Array<class_Array>` arrays, :ref:`Array<class_Array>` blend_shapes=[ ], :ref:`int<class_int>` compress_flags=97280 **)** |
  24. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`clear_blend_shapes<class_ArrayMesh_method_clear_blend_shapes>` **(** **)** |
  26. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_blend_shape_count<class_ArrayMesh_method_get_blend_shape_count>` **(** **)** const |
  28. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`String<class_String>` | :ref:`get_blend_shape_name<class_ArrayMesh_method_get_blend_shape_name>` **(** :ref:`int<class_int>` index **)** const |
  30. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`lightmap_unwrap<class_ArrayMesh_method_lightmap_unwrap>` **(** :ref:`Transform<class_Transform>` transform, :ref:`float<class_float>` texel_size **)** |
  32. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`regen_normalmaps<class_ArrayMesh_method_regen_normalmaps>` **(** **)** |
  34. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`surface_find_by_name<class_ArrayMesh_method_surface_find_by_name>` **(** :ref:`String<class_String>` name **)** const |
  36. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`surface_get_array_index_len<class_ArrayMesh_method_surface_get_array_index_len>` **(** :ref:`int<class_int>` surf_idx **)** const |
  38. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`surface_get_array_len<class_ArrayMesh_method_surface_get_array_len>` **(** :ref:`int<class_int>` surf_idx **)** const |
  40. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`surface_get_format<class_ArrayMesh_method_surface_get_format>` **(** :ref:`int<class_int>` surf_idx **)** const |
  42. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_String>` | :ref:`surface_get_name<class_ArrayMesh_method_surface_get_name>` **(** :ref:`int<class_int>` surf_idx **)** const |
  44. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` | :ref:`surface_get_primitive_type<class_ArrayMesh_method_surface_get_primitive_type>` **(** :ref:`int<class_int>` surf_idx **)** const |
  46. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`surface_remove<class_ArrayMesh_method_surface_remove>` **(** :ref:`int<class_int>` surf_idx **)** |
  48. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`surface_set_material<class_ArrayMesh_method_surface_set_material>` **(** :ref:`int<class_int>` surf_idx, :ref:`Material<class_Material>` material **)** |
  50. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`surface_set_name<class_ArrayMesh_method_surface_set_name>` **(** :ref:`int<class_int>` surf_idx, :ref:`String<class_String>` name **)** |
  52. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`surface_update_region<class_ArrayMesh_method_surface_update_region>` **(** :ref:`int<class_int>` surf_idx, :ref:`int<class_int>` offset, :ref:`PoolByteArray<class_PoolByteArray>` data **)** |
  54. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. Enumerations
  56. ------------
  57. .. _enum_ArrayMesh_ArrayType:
  58. .. _class_ArrayMesh_constant_ARRAY_VERTEX:
  59. .. _class_ArrayMesh_constant_ARRAY_NORMAL:
  60. .. _class_ArrayMesh_constant_ARRAY_TANGENT:
  61. .. _class_ArrayMesh_constant_ARRAY_COLOR:
  62. .. _class_ArrayMesh_constant_ARRAY_TEX_UV:
  63. .. _class_ArrayMesh_constant_ARRAY_TEX_UV2:
  64. .. _class_ArrayMesh_constant_ARRAY_BONES:
  65. .. _class_ArrayMesh_constant_ARRAY_WEIGHTS:
  66. .. _class_ArrayMesh_constant_ARRAY_INDEX:
  67. .. _class_ArrayMesh_constant_ARRAY_MAX:
  68. enum **ArrayType**:
  69. - **ARRAY_VERTEX** = **0** --- :ref:`PoolVector3Array<class_PoolVector3Array>`, :ref:`PoolVector2Array<class_PoolVector2Array>`, or :ref:`Array<class_Array>` of vertex positions.
  70. - **ARRAY_NORMAL** = **1** --- :ref:`PoolVector3Array<class_PoolVector3Array>` of vertex normals.
  71. - **ARRAY_TANGENT** = **2** --- :ref:`PoolRealArray<class_PoolRealArray>` of vertex tangents. Each element in groups of 4 floats, first 3 floats determine the tangent, and the last the binormal direction as -1 or 1.
  72. - **ARRAY_COLOR** = **3** --- :ref:`PoolColorArray<class_PoolColorArray>` of vertex colors.
  73. - **ARRAY_TEX_UV** = **4** --- :ref:`PoolVector2Array<class_PoolVector2Array>` for UV coordinates.
  74. - **ARRAY_TEX_UV2** = **5** --- :ref:`PoolVector2Array<class_PoolVector2Array>` for second UV coordinates.
  75. - **ARRAY_BONES** = **6** --- :ref:`PoolRealArray<class_PoolRealArray>` or :ref:`PoolIntArray<class_PoolIntArray>` of bone indices. Each element in groups of 4 floats.
  76. - **ARRAY_WEIGHTS** = **7** --- :ref:`PoolRealArray<class_PoolRealArray>` of bone weights. Each element in groups of 4 floats.
  77. - **ARRAY_INDEX** = **8** --- :ref:`PoolIntArray<class_PoolIntArray>` of integers used as indices referencing vertices, colors, normals, tangents, and textures. All of those arrays must have the same number of elements as the vertex array. No index can be beyond the vertex array size. When this index array is present, it puts the function into "index mode," where the index selects the \*i\*'th vertex, normal, tangent, color, UV, etc. This means if you want to have different normals or colors along an edge, you have to duplicate the vertices.
  78. For triangles, the index array is interpreted as triples, referring to the vertices of each triangle. For lines, the index array is in pairs indicating the start and end of each line.
  79. - **ARRAY_MAX** = **9**
  80. .. _enum_ArrayMesh_ArrayFormat:
  81. .. _class_ArrayMesh_constant_ARRAY_FORMAT_VERTEX:
  82. .. _class_ArrayMesh_constant_ARRAY_FORMAT_NORMAL:
  83. .. _class_ArrayMesh_constant_ARRAY_FORMAT_TANGENT:
  84. .. _class_ArrayMesh_constant_ARRAY_FORMAT_COLOR:
  85. .. _class_ArrayMesh_constant_ARRAY_FORMAT_TEX_UV:
  86. .. _class_ArrayMesh_constant_ARRAY_FORMAT_TEX_UV2:
  87. .. _class_ArrayMesh_constant_ARRAY_FORMAT_BONES:
  88. .. _class_ArrayMesh_constant_ARRAY_FORMAT_WEIGHTS:
  89. .. _class_ArrayMesh_constant_ARRAY_FORMAT_INDEX:
  90. enum **ArrayFormat**:
  91. - **ARRAY_FORMAT_VERTEX** = **1** --- Array format will include vertices (mandatory).
  92. - **ARRAY_FORMAT_NORMAL** = **2** --- Array format will include normals
  93. - **ARRAY_FORMAT_TANGENT** = **4** --- Array format will include tangents
  94. - **ARRAY_FORMAT_COLOR** = **8** --- Array format will include a color array.
  95. - **ARRAY_FORMAT_TEX_UV** = **16** --- Array format will include UVs.
  96. - **ARRAY_FORMAT_TEX_UV2** = **32** --- Array format will include another set of UVs.
  97. - **ARRAY_FORMAT_BONES** = **64** --- Array format will include bone indices.
  98. - **ARRAY_FORMAT_WEIGHTS** = **128** --- Array format will include bone weights.
  99. - **ARRAY_FORMAT_INDEX** = **256** --- Index array will be used.
  100. Constants
  101. ---------
  102. .. _class_ArrayMesh_constant_NO_INDEX_ARRAY:
  103. .. _class_ArrayMesh_constant_ARRAY_WEIGHTS_SIZE:
  104. - **NO_INDEX_ARRAY** = **-1** --- Default value used for index_array_len when no indices are present.
  105. - **ARRAY_WEIGHTS_SIZE** = **4** --- Amount of weights/bone indices per vertex (always 4).
  106. Description
  107. -----------
  108. The ``ArrayMesh`` is used to construct a :ref:`Mesh<class_Mesh>` by specifying the attributes as arrays. The most basic example is the creation of a single triangle
  109. ::
  110. var vertices = PoolVector3Array()
  111. vertices.push_back(Vector3(0, 1, 0))
  112. vertices.push_back(Vector3(1, 0, 0))
  113. vertices.push_back(Vector3(0, 0, 1))
  114. # Initialize the ArrayMesh.
  115. var arr_mesh = ArrayMesh.new()
  116. var arrays = []
  117. arrays.resize(ArrayMesh.ARRAY_MAX)
  118. arrays[ArrayMesh.ARRAY_VERTEX] = vertices
  119. # Create the Mesh.
  120. arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
  121. var m = MeshInstance.new()
  122. m.mesh = arr_mesh
  123. The ``MeshInstance`` is ready to be added to the SceneTree to be shown.
  124. Property Descriptions
  125. ---------------------
  126. .. _class_ArrayMesh_property_blend_shape_mode:
  127. - :ref:`BlendShapeMode<enum_Mesh_BlendShapeMode>` **blend_shape_mode**
  128. +----------+-----------------------------+
  129. | *Setter* | set_blend_shape_mode(value) |
  130. +----------+-----------------------------+
  131. | *Getter* | get_blend_shape_mode() |
  132. +----------+-----------------------------+
  133. .. _class_ArrayMesh_property_custom_aabb:
  134. - :ref:`AABB<class_AABB>` **custom_aabb**
  135. +----------+------------------------+
  136. | *Setter* | set_custom_aabb(value) |
  137. +----------+------------------------+
  138. | *Getter* | get_custom_aabb() |
  139. +----------+------------------------+
  140. An overriding bounding box for this mesh.
  141. Method Descriptions
  142. -------------------
  143. .. _class_ArrayMesh_method_add_blend_shape:
  144. - void **add_blend_shape** **(** :ref:`String<class_String>` name **)**
  145. .. _class_ArrayMesh_method_add_surface_from_arrays:
  146. - void **add_surface_from_arrays** **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Array<class_Array>` arrays, :ref:`Array<class_Array>` blend_shapes=[ ], :ref:`int<class_int>` compress_flags=97280 **)**
  147. Creates a new surface.
  148. Surfaces are created to be rendered using a "primitive", which may be PRIMITIVE_POINTS, PRIMITIVE_LINES, PRIMITIVE_LINE_STRIP, PRIMITIVE_LINE_LOOP, PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN. See :ref:`Mesh<class_Mesh>` for details. (As a note, when using indices, it is recommended to only use points, lines or triangles). :ref:`Mesh.get_surface_count<class_Mesh_method_get_surface_count>` will become the ``surf_idx`` for this new surface.
  149. The ``arrays`` argument is an array of arrays. See :ref:`ArrayType<enum_ArrayMesh_ArrayType>` for the values used in this array. For example, ``arrays[0]`` is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array or be empty, except for ``ARRAY_INDEX`` if it is used.
  150. Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data, and the index array defines the order of the vertices.
  151. Godot uses clockwise winding order for front faces of triangle primitive modes.
  152. .. _class_ArrayMesh_method_clear_blend_shapes:
  153. - void **clear_blend_shapes** **(** **)**
  154. Remove all blend shapes from this ``ArrayMesh``.
  155. .. _class_ArrayMesh_method_get_blend_shape_count:
  156. - :ref:`int<class_int>` **get_blend_shape_count** **(** **)** const
  157. Returns the number of blend shapes that the ``ArrayMesh`` holds.
  158. .. _class_ArrayMesh_method_get_blend_shape_name:
  159. - :ref:`String<class_String>` **get_blend_shape_name** **(** :ref:`int<class_int>` index **)** const
  160. Returns the name of the blend shape at this index.
  161. .. _class_ArrayMesh_method_lightmap_unwrap:
  162. - :ref:`Error<enum_@GlobalScope_Error>` **lightmap_unwrap** **(** :ref:`Transform<class_Transform>` transform, :ref:`float<class_float>` texel_size **)**
  163. Will perform a UV unwrap on the ``ArrayMesh`` to prepare the mesh for lightmapping.
  164. .. _class_ArrayMesh_method_regen_normalmaps:
  165. - void **regen_normalmaps** **(** **)**
  166. Will regenerate normal maps for the ``ArrayMesh``.
  167. .. _class_ArrayMesh_method_surface_find_by_name:
  168. - :ref:`int<class_int>` **surface_find_by_name** **(** :ref:`String<class_String>` name **)** const
  169. Return the index of the first surface with this name held within this ``ArrayMesh``. If none are found -1 is returned.
  170. .. _class_ArrayMesh_method_surface_get_array_index_len:
  171. - :ref:`int<class_int>` **surface_get_array_index_len** **(** :ref:`int<class_int>` surf_idx **)** const
  172. Return the length in indices of the index array in the requested surface (see :ref:`add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`).
  173. .. _class_ArrayMesh_method_surface_get_array_len:
  174. - :ref:`int<class_int>` **surface_get_array_len** **(** :ref:`int<class_int>` surf_idx **)** const
  175. Return the length in vertices of the vertex array in the requested surface (see :ref:`add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`).
  176. .. _class_ArrayMesh_method_surface_get_format:
  177. - :ref:`int<class_int>` **surface_get_format** **(** :ref:`int<class_int>` surf_idx **)** const
  178. Return the format mask of the requested surface (see :ref:`add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`).
  179. .. _class_ArrayMesh_method_surface_get_name:
  180. - :ref:`String<class_String>` **surface_get_name** **(** :ref:`int<class_int>` surf_idx **)** const
  181. Get the name assigned to this surface.
  182. .. _class_ArrayMesh_method_surface_get_primitive_type:
  183. - :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` **surface_get_primitive_type** **(** :ref:`int<class_int>` surf_idx **)** const
  184. Return the primitive type of the requested surface (see :ref:`add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`).
  185. .. _class_ArrayMesh_method_surface_remove:
  186. - void **surface_remove** **(** :ref:`int<class_int>` surf_idx **)**
  187. Remove a surface at position surf_idx, shifting greater surfaces one surf_idx slot down.
  188. .. _class_ArrayMesh_method_surface_set_material:
  189. - void **surface_set_material** **(** :ref:`int<class_int>` surf_idx, :ref:`Material<class_Material>` material **)**
  190. Set a :ref:`Material<class_Material>` for a given surface. Surface will be rendered using this material.
  191. .. _class_ArrayMesh_method_surface_set_name:
  192. - void **surface_set_name** **(** :ref:`int<class_int>` surf_idx, :ref:`String<class_String>` name **)**
  193. Set a name for a given surface.
  194. .. _class_ArrayMesh_method_surface_update_region:
  195. - void **surface_update_region** **(** :ref:`int<class_int>` surf_idx, :ref:`int<class_int>` offset, :ref:`PoolByteArray<class_PoolByteArray>` data **)**