Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

ImmediateMesh

繼承: Mesh < Resource < RefCounted < Object

為手動建立幾何體,而優化的網格。

說明

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:

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()

Note: Generating complex geometries with ImmediateMesh is highly inefficient. Instead, it is designed to generate simple geometry that changes often.

教學

方法

void

clear_surfaces()

void

surface_add_vertex(vertex: Vector3)

void

surface_add_vertex_2d(vertex: Vector2)

void

surface_begin(primitive: PrimitiveType, material: Material = null)

void

surface_end()

void

surface_set_color(color: Color)

void

surface_set_normal(normal: Vector3)

void

surface_set_tangent(tangent: Plane)

void

surface_set_uv(uv: Vector2)

void

surface_set_uv2(uv2: Vector2)


方法說明

void clear_surfaces() 🔗

清除所有表面。


void surface_add_vertex(vertex: Vector3) 🔗

使用先前設定的目前屬性,新增一個 3D 頂點。


void surface_add_vertex_2d(vertex: Vector2) 🔗

使用先前設定的目前屬性,新增一個 2D 頂點。


void surface_begin(primitive: PrimitiveType, material: Material = null) 🔗

開始一個新的表面。


void surface_end() 🔗

結束並提交目前表面。請注意,在該函式被呼叫之前,建立的表面將不可見。


void surface_set_color(color: Color) 🔗

設定將與下一個頂點一起推送的顏色屬性。


void surface_set_normal(normal: Vector3) 🔗

設定將與下一個頂點一起推送的法線屬性。


void surface_set_tangent(tangent: Plane) 🔗

Set the tangent attribute that will be pushed with the next vertex.

Note: Even though tangent is a Plane, it does not directly represent the tangent plane. Its Plane.x, Plane.y, and Plane.z represent the tangent vector and Plane.d should be either -1 or 1. See also Mesh.ARRAY_TANGENT.


void surface_set_uv(uv: Vector2) 🔗

設定將與下一個頂點一起推送的 UV 屬性。


void surface_set_uv2(uv2: Vector2) 🔗

設定將與下一個頂點一起推送的 UV2 屬性。