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.

PrimitiveMesh

繼承: Mesh < Resource < RefCounted < Object

被繼承: BoxMesh, CapsuleMesh, CylinderMesh, PlaneMesh, PointMesh, PrismMesh, RibbonTrailMesh, SphereMesh, TextMesh, TorusMesh, TubeTrailMesh

所有圖元網格的基底類別。處理將 Material 套用到圖元網格的問題。

說明

所有基本網格的基底類別,能夠處理將 Material 套用到基本網格的操作。有 BoxMeshCapsuleMeshCylinderMeshPlaneMeshPrismMeshSphereMesh 等基本網格。

屬性

bool

add_uv2

false

AABB

custom_aabb

AABB(0, 0, 0, 0, 0, 0)

bool

flip_faces

false

Material

material

float

uv2_padding

2.0

方法

Array

_create_mesh_array() virtual const

Array

get_mesh_arrays() const

void

request_update()


屬性說明

bool add_uv2 = false 🔗

  • void set_add_uv2(value: bool)

  • bool get_add_uv2()

打開後將生成 UV2 UV 座標,使用 uv2_padding 設定的間距。光照對應需要 UV2。


AABB custom_aabb = AABB(0, 0, 0, 0, 0, 0) 🔗

  • void set_custom_aabb(value: AABB)

  • AABB get_custom_aabb()

使用使用者自訂的 AABB 取代預設值,供視錐剔除使用。當著色器會偏移頂點時,可避免被意外剔除。


bool flip_faces = false 🔗

  • void set_flip_faces(value: bool)

  • bool get_flip_faces()

If true, the order of the vertices in each triangle is reversed, resulting in the backside of the mesh being drawn.

This gives the same result as using BaseMaterial3D.CULL_FRONT in BaseMaterial3D.cull_mode.


Material material 🔗

該圖元網格的目前 Material


float uv2_padding = 2.0 🔗

  • void set_uv2_padding(value: float)

  • float get_uv2_padding()

如果設定了 add_uv2,則指定沿網格接縫被套用的以圖元為單位的填充。較低的填充值允許更好地利用光照貼圖紋理(導致更高的紋素密度),但可能會沿邊緣引入可見的光照貼圖滲色。

如果在生成網格時無法確定光照貼圖紋理的大小,則計算 UV2 時假定紋理大小為 1024x1024。


方法說明

Array _create_mesh_array() virtual const 🔗

Override this method to customize how this primitive mesh should be generated. Should return an Array where each element is another Array of values required for the mesh (see the ArrayType constants).


Array get_mesh_arrays() const 🔗

Returns the mesh arrays used to make up the surface of this primitive mesh.

Example: Pass the result to ArrayMesh.add_surface_from_arrays() to create a new surface:

var c = CylinderMesh.new()
var arr_mesh = ArrayMesh.new()
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, c.get_mesh_arrays())

void request_update() 🔗

Request an update of this primitive mesh based on its properties.