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.

TwoBoneIK3D

繼承: IKModifier3D < SkeletonModifier3D < Node3D < Node < Object

基於旋轉的兩圓相交反向動力學求解器。

說明

這個 IKModifier3D(3D IK 修改器)需要設定一個極點目標(pole target)。它通過從每個關節和極點目標建置出一個平面,並計算兩個圓(在 3D 空間中實際上是圓盤)的交點,從而提供確定性的計算結果。

這種 IK 可以通過設定極點方向(pole direction)來處理骨骼的扭轉(twist)。如果在每組設定的骨骼之間包含多於一根骨頭,這些中間骨骼的旋轉會被忽略,系統會將連接“根節點-中間節點”和“中間節點-末端節點”的直線視為虛擬骨骼來處理。

注意: 這個類中的所有方法都帶有一個 index(索引)參數。如果該 IK 包含多個條目(例如 settings//root_bone_name),這個參數用來指定要回傳哪一個設定清單項。

屬性

int

setting_count

0

方法

int

get_end_bone(index: int) const

BoneDirection

get_end_bone_direction(index: int) const

float

get_end_bone_length(index: int) const

String

get_end_bone_name(index: int) const

int

get_middle_bone(index: int) const

String

get_middle_bone_name(index: int) const

SecondaryDirection

get_pole_direction(index: int) const

Vector3

get_pole_direction_vector(index: int) const

NodePath

get_pole_node(index: int) const

int

get_root_bone(index: int) const

String

get_root_bone_name(index: int) const

NodePath

get_target_node(index: int) const

bool

is_end_bone_extended(index: int) const

bool

is_using_virtual_end(index: int) const

void

set_end_bone(index: int, bone: int)

void

set_end_bone_direction(index: int, bone_direction: BoneDirection)

void

set_end_bone_length(index: int, length: float)

void

set_end_bone_name(index: int, bone_name: String)

void

set_extend_end_bone(index: int, enabled: bool)

void

set_middle_bone(index: int, bone: int)

void

set_middle_bone_name(index: int, bone_name: String)

void

set_pole_direction(index: int, direction: SecondaryDirection)

void

set_pole_direction_vector(index: int, vector: Vector3)

void

set_pole_node(index: int, pole_node: NodePath)

void

set_root_bone(index: int, bone: int)

void

set_root_bone_name(index: int, bone_name: String)

void

set_target_node(index: int, target_node: NodePath)

void

set_use_virtual_end(index: int, enabled: bool)


屬性說明

int setting_count = 0 🔗

  • void set_setting_count(value: int)

  • int get_setting_count()

設定的數量。


方法說明

int get_end_bone(index: int) const 🔗

回傳末端骨骼的索引。


BoneDirection get_end_bone_direction(index: int) const 🔗

當 is_end_bone_extended() 為 true 時,回傳末端骨骼的尾部方向。


float get_end_bone_length(index: int) const 🔗

當 is_end_bone_extended() 為 true 時,回傳骨骼鏈的末端骨骼尾部長度。


String get_end_bone_name(index: int) const 🔗

回傳末端骨骼的名稱。


int get_middle_bone(index: int) const 🔗

回傳中間骨骼的索引。


String get_middle_bone_name(index: int) const 🔗

回傳中間骨骼的名稱。


SecondaryDirection get_pole_direction(index: int) const 🔗

回傳極點方向。


Vector3 get_pole_direction_vector(index: int) const 🔗

回傳極點方向向量。

如果 get_pole_direction() 為 SkeletonModifier3D.SECONDARY_DIRECTION_NONE,則該方法回傳 Vector3(0, 0, 0)。


NodePath get_pole_node(index: int) const 🔗

回傳極點目標節點,該節點建置一個平面,所有關節都位於該平面上,並且極點試圖指向該平面。


int get_root_bone(index: int) const 🔗

回傳根骨骼的索引。


String get_root_bone_name(index: int) const 🔗

回傳根骨骼的名稱。


NodePath get_target_node(index: int) const 🔗

回傳末端骨骼試圖到達的目標節點。


bool is_end_bone_extended(index: int) const 🔗

如果末端骨骼被擴充形成尾部,則回傳 true。


bool is_using_virtual_end(index: int) const 🔗

如果末端骨骼作為虛擬骨骼從中間骨骼延伸出來,則回傳 true。


void set_end_bone(index: int, bone: int) 🔗

設定末端骨骼索引。


void set_end_bone_direction(index: int, bone_direction: BoneDirection) 🔗

當 is_end_bone_extended() 為 true 時,設定末端骨骼的尾部方向。


void set_end_bone_length(index: int, length: float) 🔗

當 is_end_bone_extended() 為 true 時,設定末端骨骼的尾部長度。


void set_end_bone_name(index: int, bone_name: String) 🔗

設定末端骨骼的名稱。

注意:末端骨骼必須是中間骨骼的子級。


void set_extend_end_bone(index: int, enabled: bool) 🔗

如果 enabled 為 true,則末端骨骼會延伸出一條尾巴。


void set_middle_bone(index: int, bone: int) 🔗

設定中間骨骼的索引。


void set_middle_bone_name(index: int, bone_name: String) 🔗

設定中間骨骼的名稱。

注意:中間骨骼必須是根骨骼的子級。


void set_pole_direction(index: int, direction: SecondaryDirection) 🔗

設定極點方向。

極點位於中間骨骼上,並指向極點目標。

旋轉軸是一個與該向量和前向向量正交的向量。

注意:極點方向和前向向量不應共線,以避免意外旋轉。


void set_pole_direction_vector(index: int, vector: Vector3) 🔗

設定極點方向向量。

該向量會經過內部處理進行正規化。

如果向量長度為 0,則被視為與 SkeletonModifier3D.SECONDARY_DIRECTION_NONE 同義。


void set_pole_node(index: int, pole_node: NodePath) 🔗

設定極點目標節點,該節點建置一個平面,所有關節都位於該平面上,極點試圖指向該平面。


void set_root_bone(index: int, bone: int) 🔗

設定根骨骼索引。


void set_root_bone_name(index: int, bone_name: String) 🔗

設定根骨骼名稱。


void set_target_node(index: int, target_node: NodePath) 🔗

設定末端骨骼試圖到達的目標節點。


void set_use_virtual_end(index: int, enabled: bool) 🔗

如果 enabled 為 true,則末端骨骼將從中間骨骼延伸為虛擬骨骼。