class_surfacetool.rst 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the SurfaceTool.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_SurfaceTool:
  5. SurfaceTool
  6. ===========
  7. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Helper tool to create geometry.
  12. Member Functions
  13. ----------------
  14. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`add_bones<class_SurfaceTool_add_bones>` **(** :ref:`PoolIntArray<class_poolintarray>` bones **)** |
  16. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_color<class_SurfaceTool_add_color>` **(** :ref:`Color<class_color>` color **)** |
  18. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`add_index<class_SurfaceTool_add_index>` **(** :ref:`int<class_int>` index **)** |
  20. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`add_normal<class_SurfaceTool_add_normal>` **(** :ref:`Vector3<class_vector3>` normal **)** |
  22. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`add_smooth_group<class_SurfaceTool_add_smooth_group>` **(** :ref:`bool<class_bool>` smooth **)** |
  24. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_tangent<class_SurfaceTool_add_tangent>` **(** :ref:`Plane<class_plane>` tangent **)** |
  26. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`add_to_format<class_SurfaceTool_add_to_format>` **(** :ref:`int<class_int>` flags **)** |
  28. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`add_triangle_fan<class_SurfaceTool_add_triangle_fan>` **(** :ref:`PoolVector3Array<class_poolvector3array>` vertexes, :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=[ ] **)** |
  30. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`add_uv<class_SurfaceTool_add_uv>` **(** :ref:`Vector2<class_vector2>` uv **)** |
  32. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`add_uv2<class_SurfaceTool_add_uv2>` **(** :ref:`Vector2<class_vector2>` uv2 **)** |
  34. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`add_vertex<class_SurfaceTool_add_vertex>` **(** :ref:`Vector3<class_vector3>` vertex **)** |
  36. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`add_weights<class_SurfaceTool_add_weights>` **(** :ref:`PoolRealArray<class_poolrealarray>` weights **)** |
  38. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`append_from<class_SurfaceTool_append_from>` **(** :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_transform>` transform **)** |
  40. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`begin<class_SurfaceTool_begin>` **(** :ref:`int<class_int>` primitive **)** |
  42. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`clear<class_SurfaceTool_clear>` **(** **)** |
  44. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`ArrayMesh<class_arraymesh>` | :ref:`commit<class_SurfaceTool_commit>` **(** :ref:`ArrayMesh<class_arraymesh>` existing=null, :ref:`int<class_int>` flags=97792 **)** |
  46. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`create_from<class_SurfaceTool_create_from>` **(** :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface **)** |
  48. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`deindex<class_SurfaceTool_deindex>` **(** **)** |
  50. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`generate_normals<class_SurfaceTool_generate_normals>` **(** **)** |
  52. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`generate_tangents<class_SurfaceTool_generate_tangents>` **(** **)** |
  54. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`index<class_SurfaceTool_index>` **(** **)** |
  56. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_material<class_SurfaceTool_set_material>` **(** :ref:`Material<class_material>` material **)** |
  58. +------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. Description
  60. -----------
  61. 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 script. All properties except index need to be added before a call to :ref:`add_vertex<class_SurfaceTool_add_vertex>`. For example adding vertex colors and UVs looks like
  62. ::
  63. var st = SurfaceTool.new()
  64. st.begin(Mesh.PRIMITIVE_TRIANGLES)
  65. st.add_color(Color(1, 0, 0))
  66. st.add_uv(Vector2(0, 0))
  67. st.add_vertex(Vector3(0, 0, 0))
  68. The ``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 calls to :ref:`add_uv<class_SurfaceTool_add_uv>` or :ref:`add_color<class_SurfaceTool_add_color>` then the last values would be used.
  69. It is very important that vertex attributes are passed **before** the call to :ref:`add_vertex<class_SurfaceTool_add_vertex>`, failure to do this will result in an error when committing the vertex information to a mesh.
  70. Member Function Description
  71. ---------------------------
  72. .. _class_SurfaceTool_add_bones:
  73. - void **add_bones** **(** :ref:`PoolIntArray<class_poolintarray>` bones **)**
  74. Add an array of bones for the next Vertex to use.
  75. .. _class_SurfaceTool_add_color:
  76. - void **add_color** **(** :ref:`Color<class_color>` color **)**
  77. Specify a :ref:`Color<class_color>` for the next Vertex to use.
  78. .. _class_SurfaceTool_add_index:
  79. - void **add_index** **(** :ref:`int<class_int>` index **)**
  80. Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.
  81. .. _class_SurfaceTool_add_normal:
  82. - void **add_normal** **(** :ref:`Vector3<class_vector3>` normal **)**
  83. Specify a normal for the next Vertex to use.
  84. .. _class_SurfaceTool_add_smooth_group:
  85. - void **add_smooth_group** **(** :ref:`bool<class_bool>` smooth **)**
  86. Specify whether current Vertex (if using only Vertex arrays) or current index (if also using index arrays) should utilize smooth normals for normal calculation.
  87. .. _class_SurfaceTool_add_tangent:
  88. - void **add_tangent** **(** :ref:`Plane<class_plane>` tangent **)**
  89. Specify a Tangent for the next Vertex to use.
  90. .. _class_SurfaceTool_add_to_format:
  91. - void **add_to_format** **(** :ref:`int<class_int>` flags **)**
  92. .. _class_SurfaceTool_add_triangle_fan:
  93. - void **add_triangle_fan** **(** :ref:`PoolVector3Array<class_poolvector3array>` vertexes, :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=[ ] **)**
  94. Insert a triangle fan made of array data into :ref:`Mesh<class_mesh>` being constructed.
  95. .. _class_SurfaceTool_add_uv:
  96. - void **add_uv** **(** :ref:`Vector2<class_vector2>` uv **)**
  97. Specify UV Coordinate for next Vertex to use.
  98. .. _class_SurfaceTool_add_uv2:
  99. - void **add_uv2** **(** :ref:`Vector2<class_vector2>` uv2 **)**
  100. Specify an optional second set of UV coordinates for next Vertex to use.
  101. .. _class_SurfaceTool_add_vertex:
  102. - void **add_vertex** **(** :ref:`Vector3<class_vector3>` vertex **)**
  103. Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
  104. .. _class_SurfaceTool_add_weights:
  105. - void **add_weights** **(** :ref:`PoolRealArray<class_poolrealarray>` weights **)**
  106. Specify weight value for next Vertex to use.
  107. .. _class_SurfaceTool_append_from:
  108. - void **append_from** **(** :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface, :ref:`Transform<class_transform>` transform **)**
  109. .. _class_SurfaceTool_begin:
  110. - void **begin** **(** :ref:`int<class_int>` primitive **)**
  111. Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).
  112. .. _class_SurfaceTool_clear:
  113. - void **clear** **(** **)**
  114. Clear all information passed into the surface tool so far.
  115. .. _class_SurfaceTool_commit:
  116. - :ref:`ArrayMesh<class_arraymesh>` **commit** **(** :ref:`ArrayMesh<class_arraymesh>` existing=null, :ref:`int<class_int>` flags=97792 **)**
  117. 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>`.
  118. .. _class_SurfaceTool_create_from:
  119. - void **create_from** **(** :ref:`Mesh<class_mesh>` existing, :ref:`int<class_int>` surface **)**
  120. .. _class_SurfaceTool_deindex:
  121. - void **deindex** **(** **)**
  122. Removes index array by expanding Vertex array.
  123. .. _class_SurfaceTool_generate_normals:
  124. - void **generate_normals** **(** **)**
  125. Generates normals from Vertices so you do not have to do it manually.
  126. .. _class_SurfaceTool_generate_tangents:
  127. - void **generate_tangents** **(** **)**
  128. .. _class_SurfaceTool_index:
  129. - void **index** **(** **)**
  130. Shrinks Vertex array by creating an index array. Avoids reusing Vertices.
  131. .. _class_SurfaceTool_set_material:
  132. - void **set_material** **(** :ref:`Material<class_material>` material **)**
  133. Sets :ref:`Material<class_material>` to be used by the :ref:`Mesh<class_mesh>` you are constructing.