class_surfacetool.rst 26 KB

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