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...
BoneTwistDisperser3D
继承: SkeletonModifier3D < Node3D < Node < Object
将子骨骼的扭转传播并分散到其父骨骼上的节点。
描述
此 BoneTwistDisperser3D 节点通过将末端骨骼的扭转分散到父骨骼,来实现多个骨骼间的平滑扭转插值。它只会改变扭转角度,而不会改变每个关节的全局位置。
与 CopyTransformModifier3D 和反向动力学(IK)结合使用时,可用于实现骨骼的平滑扭转效果。
注意:如果提取的扭转角度超过 180 度,则会发生翻转。这一点与 ConvertTransformModifier3D 类似。
注意:该类中的大多数方法都接受一个 index 参数。如果 IK 包含多个条目(例如 settings/<index>/root_bone_name),则该参数用于指定应返回哪个设置列表条目。
属性
|
||
|
方法
枚举
enum DisperseMode: 🔗
DisperseMode DISPERSE_MODE_EVEN = 0
分配数值,使其从 0.0 到 1.0 单调递增,并确保所有权重相等。例如,如果有五个关节,从根骨骼开始的数值将依次为 0.2、0.4、0.6、0.8 和 1.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 🔗
如果为 true,则求解器每帧从骨骼姿态中检索骨骼轴。
如果为 false,则求解器将从骨骼放松中检索骨骼轴并将其缓存。
设置的数量。
方法说明
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) 🔗
如果 enabled 为 true,则会延伸末端骨骼形成尾部。
如果 enabled 为 false,则 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 时提取扭转。
换言之,通过对特定 SkeletonModifier3D 的 SkeletonModifier3D.modification_processed 调用 set_twist_from(),可以仅提取在该 BoneTwistDisperser3D 之前处理的修改器生成的扭转。
void set_twist_from_rest(index: int, enabled: bool) 🔗
如果 enabled 为 true,则从骨骼放松姿势和当前骨骼姿势之间的差异中提取扭转量。
如果 enabled 为 false,则从 get_twist_from() 和当前骨骼姿势之间的差异中提取扭转量。另见 set_twist_from()。
void set_weight_position(index: int, weight_position: float) 🔗
当 get_disperse_mode() 的值为 DISPERSE_MODE_WEIGHTED 时,设置在关节之间分割线段以进行权重分配的位置。
例如,当 weight_position 为 0.5 时,如果三个关节之间存在两段长度为 1.0 的骨骼,则从根关节到末端关节,每个关节的权重分配比例分别为 0.5、1.0 和 0.5。然后,最终的权重值将分别变为 0.25、0.75 和 1.0。