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.
Checking the stable version of the documentation...
CSGShape3D
繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object
被繼承: CSGCombiner3D, CSGPrimitive3D
CSG 基底類別。
說明
This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
Performance: CSG nodes are only intended for prototyping as they have a significant CPU performance cost. Consider baking final CSG operation results into static geometry that replaces the CSG nodes.
Individual CSG root node results can be baked to nodes with static resources with the editor menu that appears when a CSG root node is selected.
Individual CSG root nodes can also be baked to static resources with scripts by calling bake_static_mesh() for the visual mesh or bake_collision_shape() for the physics collision.
Entire scenes of CSG nodes can be baked to static geometry and exported with the editor glTF scene exporter: Scene > Export As... > glTF 2.0 Scene...
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
get_collision_layer_value(layer_number: int) const |
|
get_collision_mask_value(layer_number: int) const |
|
get_meshes() const |
|
is_root_shape() const |
|
void |
set_collision_layer_value(layer_number: int, value: bool) |
void |
set_collision_mask_value(layer_number: int, value: bool) |
列舉
enum Operation: 🔗
Operation OPERATION_UNION = 0
合併兩個圖元的幾何體,移除相交的幾何體。
Operation OPERATION_INTERSECTION = 1
僅保留相交的幾何,其餘的將被移除。
Operation OPERATION_SUBTRACTION = 2
從第一個形狀減去第二個形狀,留下一個帶有其形狀的凹痕。
屬性說明
Enables automatic smoothing. This overrides any smoothing on the CSG node and instead uses smoothing_angle to calculate normals based on the angle between faces.
Children of a CSGCombiner3D node will be treated as a single mesh.
bool calculate_tangents = true 🔗
Calculate tangents for the CSG shape which allows the use of normal and height maps. This is only applied on the root shape, this setting is ignored on any child. Setting this to false can speed up shape generation slightly.
這個區域所處的實體層。
可碰撞的物體可以存在於 32 個不同層中的任何一個。這些層的工作就像一個標籤系統,而不是視覺化的。一個可碰撞物體可以使用這些層來選擇它可以與哪些物體碰撞,使用 collision_mask 屬性。
如果物件 A 在物件 B 所掃描的任何層中,或者物件 B 在物件 A 所掃描的任何層中,就會偵測到接觸。詳情請參閱文件中的《碰撞層與遮罩》。
該 CSG 形狀掃描碰撞的實體層。僅當 use_collision 為 true 時有效。有關更多資訊,請參閱文件中的《碰撞層與遮罩》。
float collision_priority = 1.0 🔗
發生穿透時用於解算碰撞的優先順序。僅當 use_collision 為 true 時有效。優先順序越高,對對象的穿透力就越低。例如,這可以用來防止玩家突破關卡的邊界。
在此形狀上執行的操作。對於第一個 CSG 子節點,將忽略此操作,因為操作是在此節點與該節點父級的上一個子級之間進行的。
float smoothing_angle = 50.0 🔗
When autosmooth is enabled, faces with an angle between them greater than this will be smoothed, while faces with a smaller angle will remain sharp.
Note: An angle lower than 0.1 will cause all smoothing to be disabled, this can be used to increase performance.
已棄用: The CSG library no longer uses snapping.
This property does nothing.
為我們的 CSG 形狀向物理引擎新增碰撞形狀。這樣行為就始終與靜態物體類似。請注意,即使 CSG 形狀本身被隱藏,碰撞形狀仍處於活動狀態。另見 collision_mask 和 collision_priority。
方法說明
ConcavePolygonShape3D bake_collision_shape() 🔗
Returns a baked physics ConcavePolygonShape3D of this node's CSG operation result. Returns an empty shape if the node is not a CSG root node or has no valid geometry.
Performance: If the CSG operation results in a very detailed geometry with many faces physics performance will be very slow. Concave shapes should in general only be used for static level geometry and not with dynamic objects that are moving.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call await get_tree().process_frame before using bake_collision_shape() in Node._ready() or after changing properties on the CSGShape3D.
ArrayMesh bake_static_mesh() 🔗
Returns a baked static ArrayMesh of this node's CSG operation result. Materials from involved CSG nodes are added as extra mesh surfaces. Returns an empty mesh if the node is not a CSG root node or has no valid geometry.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty mesh or outdated mesh data, make sure to call await get_tree().process_frame before using bake_static_mesh() in Node._ready() or after changing properties on the CSGShape3D.
bool get_collision_layer_value(layer_number: int) const 🔗
返回 collision_layer 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。
bool get_collision_mask_value(layer_number: int) const 🔗
返回 collision_mask 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。
Returns an Array with two elements, the first is the Transform3D of this node and the second is the root Mesh of this node. Only works when this node is the root shape.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call await get_tree().process_frame before using get_meshes() in Node._ready() or after changing properties on the CSGShape3D.
如果這是根形狀,因此是算繪的物件,則返回 true。
void set_collision_layer_value(layer_number: int, value: bool) 🔗
根據 value,啟用或禁用 collision_layer 中指定的層,給定的 layer_number 應在 1 和 32 之間。
void set_collision_mask_value(layer_number: int, value: bool) 🔗
根據 value,啟用或禁用 collision_mask 中指定的層,給定的 layer_number 應在 1 和 32 之間。