class_immediatemesh.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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. .. code-tab:: csharp
  25. var mesh = new ImmediateMesh();
  26. mesh.SurfaceBegin(Mesh.PrimitiveType.Triangles);
  27. mesh.SurfaceAddVertex(Vector3.Left);
  28. mesh.SurfaceAddVertex(Vector3.Forward);
  29. mesh.SurfaceAddVertex(Vector3.Zero);
  30. mesh.SurfaceEnd();
  31. \ **Note:** Generating complex geometries with **ImmediateMesh** is highly inefficient. Instead, it is designed to generate simple geometry that changes often.
  32. .. rst-class:: classref-introduction-group
  33. Tutorials
  34. ---------
  35. - :doc:`Using ImmediateMesh <../tutorials/3d/procedural_geometry/immediatemesh>`
  36. .. rst-class:: classref-reftable-group
  37. Methods
  38. -------
  39. .. table::
  40. :widths: auto
  41. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`clear_surfaces<class_ImmediateMesh_method_clear_surfaces>` **(** **)** |
  43. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`surface_add_vertex<class_ImmediateMesh_method_surface_add_vertex>` **(** :ref:`Vector3<class_Vector3>` vertex **)** |
  45. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`surface_add_vertex_2d<class_ImmediateMesh_method_surface_add_vertex_2d>` **(** :ref:`Vector2<class_Vector2>` vertex **)** |
  47. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`surface_begin<class_ImmediateMesh_method_surface_begin>` **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Material<class_Material>` material=null **)** |
  49. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`surface_end<class_ImmediateMesh_method_surface_end>` **(** **)** |
  51. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`surface_set_color<class_ImmediateMesh_method_surface_set_color>` **(** :ref:`Color<class_Color>` color **)** |
  53. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`surface_set_normal<class_ImmediateMesh_method_surface_set_normal>` **(** :ref:`Vector3<class_Vector3>` normal **)** |
  55. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`surface_set_tangent<class_ImmediateMesh_method_surface_set_tangent>` **(** :ref:`Plane<class_Plane>` tangent **)** |
  57. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`surface_set_uv<class_ImmediateMesh_method_surface_set_uv>` **(** :ref:`Vector2<class_Vector2>` uv **)** |
  59. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`surface_set_uv2<class_ImmediateMesh_method_surface_set_uv2>` **(** :ref:`Vector2<class_Vector2>` uv2 **)** |
  61. +------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Method Descriptions
  66. -------------------
  67. .. _class_ImmediateMesh_method_clear_surfaces:
  68. .. rst-class:: classref-method
  69. void **clear_surfaces** **(** **)**
  70. Clear all surfaces.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_ImmediateMesh_method_surface_add_vertex:
  74. .. rst-class:: classref-method
  75. void **surface_add_vertex** **(** :ref:`Vector3<class_Vector3>` vertex **)**
  76. Add a 3D vertex using the current attributes previously set.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_ImmediateMesh_method_surface_add_vertex_2d:
  80. .. rst-class:: classref-method
  81. void **surface_add_vertex_2d** **(** :ref:`Vector2<class_Vector2>` vertex **)**
  82. Add a 2D vertex using the current attributes previously set.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_ImmediateMesh_method_surface_begin:
  86. .. rst-class:: classref-method
  87. void **surface_begin** **(** :ref:`PrimitiveType<enum_Mesh_PrimitiveType>` primitive, :ref:`Material<class_Material>` material=null **)**
  88. Begin a new surface.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_ImmediateMesh_method_surface_end:
  92. .. rst-class:: classref-method
  93. void **surface_end** **(** **)**
  94. End and commit current surface. Note that surface being created will not be visible until this function is called.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_ImmediateMesh_method_surface_set_color:
  98. .. rst-class:: classref-method
  99. void **surface_set_color** **(** :ref:`Color<class_Color>` color **)**
  100. Set the color attribute that will be pushed with the next vertex.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_ImmediateMesh_method_surface_set_normal:
  104. .. rst-class:: classref-method
  105. void **surface_set_normal** **(** :ref:`Vector3<class_Vector3>` normal **)**
  106. Set the normal attribute that will be pushed with the next vertex.
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _class_ImmediateMesh_method_surface_set_tangent:
  110. .. rst-class:: classref-method
  111. void **surface_set_tangent** **(** :ref:`Plane<class_Plane>` tangent **)**
  112. Set the tangent attribute that will be pushed with the next vertex.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_ImmediateMesh_method_surface_set_uv:
  116. .. rst-class:: classref-method
  117. void **surface_set_uv** **(** :ref:`Vector2<class_Vector2>` uv **)**
  118. Set the UV attribute that will be pushed with the next vertex.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_ImmediateMesh_method_surface_set_uv2:
  122. .. rst-class:: classref-method
  123. void **surface_set_uv2** **(** :ref:`Vector2<class_Vector2>` uv2 **)**
  124. Set the UV2 attribute that will be pushed with the next vertex.
  125. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  126. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  127. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  128. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  129. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  130. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  131. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`