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.

BoneTwistDisperser3D

继承: SkeletonModifier3D < Node3D < Node < Object

将子骨骼的扭转传播并分散到其父骨骼上的节点。

描述

BoneTwistDisperser3D 节点通过将末端骨骼的扭转分散到父骨骼,来实现多个骨骼间的平滑扭转插值。它只会改变扭转角度,而不会改变每个关节的全局位置。

CopyTransformModifier3D 和反向动力学(IK)结合使用时,可用于实现骨骼的平滑扭转效果。

注意:如果提取的扭转角度超过 180 度,则会发生翻转。这一点与 ConvertTransformModifier3D 类似。

注意:该类中的大多数方法都接受一个 index 参数。如果 IK 包含多个条目(例如 settings/<index>/root_bone_name),则该参数用于指定应返回哪个设置列表条目。

属性

bool

mutable_bone_axes

true

int

setting_count

0

方法

void

clear_settings()

Curve

get_damping_curve(index: int) const

DisperseMode

get_disperse_mode(index: int) const

int

get_end_bone(index: int) const

BoneDirection

get_end_bone_direction(index: int) const

String

get_end_bone_name(index: int) const

int

get_joint_bone(index: int, joint: int) const

String

get_joint_bone_name(index: int, joint: int) const

int

get_joint_count(index: int) const

float

get_joint_twist_amount(index: int, joint: int) const

int

get_reference_bone(index: int) const

String

get_reference_bone_name(index: int) const

int

get_root_bone(index: int) const

String

get_root_bone_name(index: int) const

Quaternion

get_twist_from(index: int) const

float

get_weight_position(index: int) const

bool

is_end_bone_extended(index: int) const

bool

is_twist_from_rest(index: int) const

void

set_damping_curve(index: int, curve: Curve)

void

set_disperse_mode(index: int, disperse_mode: DisperseMode)

void

set_end_bone(index: int, bone: int)

void

set_end_bone_direction(index: int, bone_direction: BoneDirection)

void

set_end_bone_name(index: int, bone_name: String)

void

set_extend_end_bone(index: int, enabled: bool)

void

set_joint_twist_amount(index: int, joint: int, twist_amount: float)

void

set_root_bone(index: int, bone: int)

void

set_root_bone_name(index: int, bone_name: String)

void

set_twist_from(index: int, from: Quaternion)

void

set_twist_from_rest(index: int, enabled: bool)

void

set_weight_position(index: int, weight_position: float)


枚举

enum DisperseMode: 🔗

DisperseMode DISPERSE_MODE_EVEN = 0

分配数值,使其从 0.01.0 单调递增,并确保所有权重相等。例如,如果有五个关节,从根骨骼开始的数值将依次为 0.20.40.60.81.0

DisperseMode DISPERSE_MODE_WEIGHTED = 1

根据关节节段之间骨骼的长度,分配数值,使其从 0.0 单调递增到 1.0。另见 set_weight_position()

DisperseMode DISPERSE_MODE_CUSTOM = 2

可以为关节列表分配任意值。另见 set_joint_twist_amount()

is_end_bone_extended()false 时,参考骨骼的子骨骼仅用于确定扭转轴,因此其自定义量完全没有效果。


属性说明

bool mutable_bone_axes = true 🔗

  • void set_mutable_bone_axes(value: bool)

  • bool are_bone_axes_mutable()

如果为 true,则求解器每帧从骨骼姿态中检索骨骼轴。

如果为 false,则求解器将从骨骼放松中检索骨骼轴并将其缓存。


int setting_count = 0 🔗

  • void set_setting_count(value: int)

  • int get_setting_count()

设置的数量。


方法说明

void clear_settings() 🔗

清空所有设置。


Curve get_damping_curve(index: int) const 🔗

get_disperse_mode() 的值为 DISPERSE_MODE_CUSTOM 时,返回阻尼曲线。


DisperseMode get_disperse_mode(index: int) const 🔗

返回是使用自动分配还是允许手动分配。


int get_end_bone(index: int) const 🔗

返回骨骼链末尾骨骼的索引。


BoneDirection get_end_bone_direction(index: int) const 🔗

is_end_bone_extended()true 时,返回骨骼链末端骨骼的尾部方向。


String get_end_bone_name(index: int) const 🔗

返回骨骼链末尾骨骼的名称。


int get_joint_bone(index: int, joint: int) const 🔗

返回骨骼链关节列表中位于 joint 的骨骼的索引。


String get_joint_bone_name(index: int, joint: int) const 🔗

返回骨骼链关节列表中位于 joint 的骨骼的名称。


int get_joint_count(index: int) const 🔗

返回骨骼链关节列表中的关节数量。


float get_joint_twist_amount(index: int, joint: int) const 🔗

get_disperse_mode()DISPERSE_MODE_CUSTOM 时,返回骨骼链关节列表中 joint 处的扭转量。


int get_reference_bone(index: int) const 🔗

返回参考骨骼,以提取 index 处的设置项的扭曲。

根据 is_end_bone_extended(),该骨骼要么是链的末端,要么是它的父级。


String get_reference_bone_name(index: int) const 🔗

返回参考骨骼名称,以提取 index 处的设置项的扭曲。

根据 is_end_bone_extended(),该骨骼要么是链的末端,要么是它的父级。


int get_root_bone(index: int) const 🔗

返回骨骼链根骨骼的索引。


String get_root_bone_name(index: int) const 🔗

返回骨骼链根骨骼的名称。


Quaternion get_twist_from(index: int) const 🔗

is_twist_from_rest()false 时,返回当前骨骼姿势在扭转之前恢复到任意状态时的旋转,以便提取扭转角度。


float get_weight_position(index: int) const 🔗

返回当 get_disperse_mode()DISPERSE_MODE_WEIGHTED 时,在关节之间分割线段以进行权重分配的位置。


bool is_end_bone_extended(index: int) const 🔗

如果末端骨骼被扩展形成尾部,则返回 true


bool is_twist_from_rest(index: int) const 🔗

如果能够从骨骼放松姿势和当前骨骼姿势之间的差异中提取扭转量,则返回 true


void set_damping_curve(index: int, curve: Curve) 🔗

get_disperse_mode()DISPERSE_MODE_CUSTOM 时,用于设置阻尼曲线。


void set_disperse_mode(index: int, disperse_mode: DisperseMode) 🔗

设置是使用自动分配还是允许手动分配。


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_name(index: int, bone_name: String) 🔗

设置骨骼链的末端骨骼名称。

注意:末端骨骼必须是根骨骼的子骨骼。


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

如果 enabledtrue,则会延伸末端骨骼形成尾部。

如果 enabledfalse,则 get_reference_bone() 会成为末端骨骼的父骨骼,并使用到末端骨骼的向量作为扭转轴。


void set_joint_twist_amount(index: int, joint: int, twist_amount: float) 🔗

get_disperse_mode()DISPERSE_MODE_CUSTOM 时,设置骨骼链关节列表中 joint 处的扭转量。


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

设置骨骼链中根骨骼的索引。


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

设置骨骼链中根骨骼的名称。


void set_twist_from(index: int, from: Quaternion) 🔗

在扭转当前骨骼姿势之前,将旋转设置为任意状态,以便在 is_twist_from_rest()false 时提取扭转。

换言之,通过对特定 SkeletonModifier3DSkeletonModifier3D.modification_processed 调用 set_twist_from(),可以仅提取在该 BoneTwistDisperser3D 之前处理的修改器生成的扭转。


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

如果 enabledtrue,则从骨骼放松姿势和当前骨骼姿势之间的差异中提取扭转量。

如果 enabledfalse,则从 get_twist_from() 和当前骨骼姿势之间的差异中提取扭转量。另见 set_twist_from()


void set_weight_position(index: int, weight_position: float) 🔗

get_disperse_mode() 的值为 DISPERSE_MODE_WEIGHTED 时,设置在关节之间分割线段以进行权重分配的位置。

例如,当 weight_position0.5 时,如果三个关节之间存在两段长度为 1.0 的骨骼,则从根关节到末端关节,每个关节的权重分配比例分别为 0.51.00.5。然后,最终的权重值将分别变为 0.250.751.0