class_immediatemesh.rst 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/ImmediateMesh.xml.
  6. .. _class_ImmediateMesh:
  7. ImmediateMesh
  8. =============
  9. **Inherits:** :ref:`Mesh<class_Mesh>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Mesh optimized for creating geometry manually.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A mesh type optimized for creating geometry manually, similar to OpenGL 1.x immediate mode.
  15. Here's a sample on how to generate a triangular face:
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. var mesh = ImmediateMesh.new()
  19. mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES)
  20. mesh.surface_add_vertex(Vector3.LEFT)
  21. mesh.surface_add_vertex(Vector3.FORWARD)
  22. mesh.surface_add_vertex(Vector3.ZERO)
  23. mesh.surface_end()
  24. \ **Note:** Generating complex geometries with **ImmediateMesh** is highly inefficient. Instead, it is designed to generate simple geometry that changes often.
  25. .. rst-class:: classref-introduction-group
  26. Tutorials
  27. ---------
  28. - :doc:`Using ImmediateMesh <../tutorials/3d/procedural_geometry/immediatemesh>`
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`clear_surfaces<class_ImmediateMesh_method_clear_surfaces>` **(** **)** |
  36. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`surface_add_vertex<class_ImmediateMesh_method_surface_add_vertex>` **(** :ref:`Vector3<class_Vector3>` vertex **)** |
  38. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`surface_add_vertex_2d<class_ImmediateMesh_method_surface_add_vertex_2d>` **(** :ref:`Vector2<class_Vector2>` vertex **)** |
  40. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`surface_begin<class_ImmediateMesh_method_surface_begin>` **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Material<class_Material>` material=null **)** |
  42. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`surface_end<class_ImmediateMesh_method_surface_end>` **(** **)** |
  44. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`surface_set_color<class_ImmediateMesh_method_surface_set_color>` **(** :ref:`Color<class_Color>` color **)** |
  46. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`surface_set_normal<class_ImmediateMesh_method_surface_set_normal>` **(** :ref:`Vector3<class_Vector3>` normal **)** |
  48. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`surface_set_tangent<class_ImmediateMesh_method_surface_set_tangent>` **(** :ref:`Plane<class_Plane>` tangent **)** |
  50. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`surface_set_uv<class_ImmediateMesh_method_surface_set_uv>` **(** :ref:`Vector2<class_Vector2>` uv **)** |
  52. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`surface_set_uv2<class_ImmediateMesh_method_surface_set_uv2>` **(** :ref:`Vector2<class_Vector2>` uv2 **)** |
  54. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. .. rst-class:: classref-section-separator
  56. ----
  57. .. rst-class:: classref-descriptions-group
  58. Method Descriptions
  59. -------------------
  60. .. _class_ImmediateMesh_method_clear_surfaces:
  61. .. rst-class:: classref-method
  62. void **clear_surfaces** **(** **)**
  63. Clear all surfaces.
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_ImmediateMesh_method_surface_add_vertex:
  67. .. rst-class:: classref-method
  68. void **surface_add_vertex** **(** :ref:`Vector3<class_Vector3>` vertex **)**
  69. Add a 3D vertex using the current attributes previously set.
  70. .. rst-class:: classref-item-separator
  71. ----
  72. .. _class_ImmediateMesh_method_surface_add_vertex_2d:
  73. .. rst-class:: classref-method
  74. void **surface_add_vertex_2d** **(** :ref:`Vector2<class_Vector2>` vertex **)**
  75. Add a 2D vertex using the current attributes previously set.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_ImmediateMesh_method_surface_begin:
  79. .. rst-class:: classref-method
  80. void **surface_begin** **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Material<class_Material>` material=null **)**
  81. Begin a new surface.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_ImmediateMesh_method_surface_end:
  85. .. rst-class:: classref-method
  86. void **surface_end** **(** **)**
  87. End and commit current surface. Note that surface being created will not be visible until this function is called.
  88. .. rst-class:: classref-item-separator
  89. ----
  90. .. _class_ImmediateMesh_method_surface_set_color:
  91. .. rst-class:: classref-method
  92. void **surface_set_color** **(** :ref:`Color<class_Color>` color **)**
  93. Set the color attribute that will be pushed with the next vertex.
  94. .. rst-class:: classref-item-separator
  95. ----
  96. .. _class_ImmediateMesh_method_surface_set_normal:
  97. .. rst-class:: classref-method
  98. void **surface_set_normal** **(** :ref:`Vector3<class_Vector3>` normal **)**
  99. Set the normal attribute that will be pushed with the next vertex.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_ImmediateMesh_method_surface_set_tangent:
  103. .. rst-class:: classref-method
  104. void **surface_set_tangent** **(** :ref:`Plane<class_Plane>` tangent **)**
  105. Set the tangent attribute that will be pushed with the next vertex.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_ImmediateMesh_method_surface_set_uv:
  109. .. rst-class:: classref-method
  110. void **surface_set_uv** **(** :ref:`Vector2<class_Vector2>` uv **)**
  111. Set the UV attribute that will be pushed with the next vertex.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_ImmediateMesh_method_surface_set_uv2:
  115. .. rst-class:: classref-method
  116. void **surface_set_uv2** **(** :ref:`Vector2<class_Vector2>` uv2 **)**
  117. Set the UV2 attribute that will be pushed with the next vertex.
  118. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  119. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  120. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  121. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  122. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  123. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`