:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/ImmediateMesh.xml. .. _class_ImmediateMesh: ImmediateMesh ============= **Inherits:** :ref:`Mesh` **<** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` Mesh optimized for creating geometry manually. .. rst-class:: classref-introduction-group Description ----------- A mesh type optimized for creating geometry manually, similar to OpenGL 1.x immediate mode. Here's a sample on how to generate a triangular face: .. tabs:: .. code-tab:: gdscript var mesh = ImmediateMesh.new() mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES) mesh.surface_add_vertex(Vector3.LEFT) mesh.surface_add_vertex(Vector3.FORWARD) mesh.surface_add_vertex(Vector3.ZERO) mesh.surface_end() .. code-tab:: csharp var mesh = new ImmediateMesh(); mesh.SurfaceBegin(Mesh.PrimitiveType.Triangles); mesh.SurfaceAddVertex(Vector3.Left); mesh.SurfaceAddVertex(Vector3.Forward); mesh.SurfaceAddVertex(Vector3.Zero); mesh.SurfaceEnd(); \ **Note:** Generating complex geometries with **ImmediateMesh** is highly inefficient. Instead, it is designed to generate simple geometry that changes often. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Using ImmediateMesh <../tutorials/3d/procedural_geometry/immediatemesh>` .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_surfaces`\ (\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_add_vertex`\ (\ vertex\: :ref:`Vector3`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_add_vertex_2d`\ (\ vertex\: :ref:`Vector2`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_begin`\ (\ primitive\: :ref:`PrimitiveType`, material\: :ref:`Material` = null\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_end`\ (\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_set_color`\ (\ color\: :ref:`Color`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_set_normal`\ (\ normal\: :ref:`Vector3`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_set_tangent`\ (\ tangent\: :ref:`Plane`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_set_uv`\ (\ uv\: :ref:`Vector2`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`surface_set_uv2`\ (\ uv2\: :ref:`Vector2`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_ImmediateMesh_method_clear_surfaces: .. rst-class:: classref-method |void| **clear_surfaces**\ (\ ) :ref:`🔗` Clear all surfaces. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_add_vertex: .. rst-class:: classref-method |void| **surface_add_vertex**\ (\ vertex\: :ref:`Vector3`\ ) :ref:`🔗` Add a 3D vertex using the current attributes previously set. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_add_vertex_2d: .. rst-class:: classref-method |void| **surface_add_vertex_2d**\ (\ vertex\: :ref:`Vector2`\ ) :ref:`🔗` Add a 2D vertex using the current attributes previously set. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_begin: .. rst-class:: classref-method |void| **surface_begin**\ (\ primitive\: :ref:`PrimitiveType`, material\: :ref:`Material` = null\ ) :ref:`🔗` Begin a new surface. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_end: .. rst-class:: classref-method |void| **surface_end**\ (\ ) :ref:`🔗` End and commit current surface. Note that surface being created will not be visible until this function is called. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_set_color: .. rst-class:: classref-method |void| **surface_set_color**\ (\ color\: :ref:`Color`\ ) :ref:`🔗` Set the color attribute that will be pushed with the next vertex. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_set_normal: .. rst-class:: classref-method |void| **surface_set_normal**\ (\ normal\: :ref:`Vector3`\ ) :ref:`🔗` Set the normal attribute that will be pushed with the next vertex. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_set_tangent: .. rst-class:: classref-method |void| **surface_set_tangent**\ (\ tangent\: :ref:`Plane`\ ) :ref:`🔗` Set the tangent attribute that will be pushed with the next vertex. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_set_uv: .. rst-class:: classref-method |void| **surface_set_uv**\ (\ uv\: :ref:`Vector2`\ ) :ref:`🔗` Set the UV attribute that will be pushed with the next vertex. .. rst-class:: classref-item-separator ---- .. _class_ImmediateMesh_method_surface_set_uv2: .. rst-class:: classref-method |void| **surface_set_uv2**\ (\ uv2\: :ref:`Vector2`\ ) :ref:`🔗` Set the UV2 attribute that will be pushed with the next vertex. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`