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

如果 enabledtrue,则末端骨骼会延伸出一条尾巴。


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

如果 enabledtrue,则末端骨骼将从中间骨骼延伸为虚拟骨骼。