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.

CSGPolygon3D

繼承: CSGPrimitive3D < CSGShape3D < GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

拉伸 2D 多邊形形狀以建立 3D 網格。

說明

擠出一組 2D 點,以快速輕鬆地建立各種 3D 網格。另請參閱 CSGMesh3D,以瞭解將 3D 網格用作 CSG 節點。

注意:CSG 節點旨在用於關卡原型設計。與使用 PrimitiveMesh 建立 MeshInstance3D 相比,建立 CSG 節點具有顯著的 CPU 成本。在另一個 CSG 節點中,移動一個 CSG 節點,也會大量消耗 CPU,因此在遊戲過程中,應該避免這種情況。

教學

屬性

float

depth

1.0

Material

material

Mode

mode

0

bool

path_continuous_u

float

path_interval

PathIntervalType

path_interval_type

bool

path_joined

bool

path_local

NodePath

path_node

PathRotation

path_rotation

bool

path_rotation_accurate

float

path_simplify_angle

float

path_u_distance

PackedVector2Array

polygon

PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)

bool

smooth_faces

false

float

spin_degrees

int

spin_sides


列舉

enum Mode: 🔗

Mode MODE_DEPTH = 0

polygon 形狀沿負 Z 軸擠出。

Mode MODE_SPIN = 1

polygon 形狀通過圍繞 Y 軸旋轉來擠出。

Mode MODE_PATH = 2

polygon 形狀沿 path_node 中指定的 Path3D 擠出。


enum PathRotation: 🔗

PathRotation PATH_ROTATION_POLYGON = 0

polygon 形狀不會被旋轉。

注意:要求路徑的 Z 座標不斷減少,以確保可行的形狀。

PathRotation PATH_ROTATION_PATH = 1

polygon 形狀沿路徑旋轉,但並不繞路徑軸旋轉。

注意:需要路徑的 Z 座標不斷減小,以確保可行的形狀。

PathRotation PATH_ROTATION_PATH_FOLLOW = 2

polygon 多邊形的形狀跟隨路徑及其圍繞路徑軸的旋轉。


enum PathIntervalType: 🔗

PathIntervalType PATH_INTERVAL_DISTANCE = 0

mode 被設定為 MODE_PATH 時,path_interval 將決定路徑的每個間隔將被擠出的距離,單位為米。

PathIntervalType PATH_INTERVAL_SUBDIVIDE = 1

mode 被設定為 MODE_PATH時,path_interval 將沿著路徑細分多邊形。


屬性說明

float depth = 1.0 🔗

modeMODE_DEPTH 時,擠出的深度。


Material material 🔗

用於生成的網格的材質。UV 將材質的上半部分對應到擠出形狀(U 沿著擠出的長度,V 圍繞 polygon 的輪廓),左下四分之一對應到前端面,右下四分之一對應到後端面。


Mode mode = 0 🔗

  • void set_mode(value: Mode)

  • Mode get_mode()

用於擠出 polygonmode


bool path_continuous_u 🔗

  • void set_path_continuous_u(value: bool)

  • bool is_path_continuous_u()

modeMODE_PATH 時,預設情況下,material 的上半部分會沿著擠出形狀的整個長度被拉伸。如果為 false,擠出的每一步都會重複材質的上半部分。


float path_interval 🔗

  • void set_path_interval(value: float)

  • float get_path_interval()

modeMODE_PATH 時,路徑間隔或路徑點比例擠出。


PathIntervalType path_interval_type 🔗

modeMODE_PATH 時,這將確定間隔是按距離(PATH_INTERVAL_DISTANCE)還是細分分數(PATH_INTERVAL_SUBDIVIDE)。


bool path_joined 🔗

  • void set_path_joined(value: bool)

  • bool is_path_joined()

modeMODE_PATH 時,如果 true 路徑的兩端會被連接起來,在路徑的最後一個點和第一個點之間新增擠出。


bool path_local 🔗

  • void set_path_local(value: bool)

  • bool is_path_local()

modeMODE_PATH 時,如果為 true,則該 CSGPolygon3DTransform3D 將被用作擠出的起點,而非 path_nodeTransform3D


NodePath path_node 🔗

modeMODE_PATH 時,用於擠出 polygonPath3D 物件的位置。


PathRotation path_rotation 🔗

When mode is MODE_PATH, the path rotation method used to rotate the polygon as it is extruded.


bool path_rotation_accurate 🔗

  • void set_path_rotation_accurate(value: bool)

  • bool get_path_rotation_accurate()

When mode is MODE_PATH, if true the polygon will be rotated according to the proper tangent of the path at the sampled points. If false an approximation is used, which decreases in accuracy as the number of subdivisions decreases.


float path_simplify_angle 🔗

  • void set_path_simplify_angle(value: float)

  • float get_path_simplify_angle()

modeMODE_PATH 時,小於此角度的擠出將合併在一起以減少多邊形數量。


float path_u_distance 🔗

  • void set_path_u_distance(value: float)

  • float get_path_u_distance()

modeMODE_PATH 時,這是紋理座標沿著路徑的距離,以米為單位,將進行平鋪。當設定為 0 時,紋理座標將與幾何圖形完全配對,沒有平鋪。


PackedVector2Array polygon = PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0) 🔗

頂點陣列,用於定義要擠出的 2D 多邊形。需要包含 3 個或更多頂點,可以是凸多邊形也可以是凹多邊形。該多邊形中不能存在相交的邊。否則,三角形化會失敗,不會生成任何網格。

注意:如果 polygon 中只定義了 1 個或 2 個頂點,則不會生成網格。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.


bool smooth_faces = false 🔗

  • void set_smooth_faces(value: bool)

  • bool get_smooth_faces()

如果為 true,則對擠出套用平滑著色。


float spin_degrees 🔗

  • void set_spin_degrees(value: float)

  • float get_spin_degrees()

modeMODE_SPINpolygon 在擠出時旋轉的總度數。


int spin_sides 🔗

  • void set_spin_sides(value: int)

  • int get_spin_sides()

modeMODE_SPIN 時,擠出的次數。