SkeletonModification2DTwoBoneIK
实验性: This class may be changed or removed in future versions.
继承: SkeletonModification2D
< Resource
< RefCounted
< Object
A modification that rotates two bones using the law of cosines to reach the target.
描述
This SkeletonModification2D
uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosines and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only operate on two bones.
TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than SkeletonModification2DFABRIK
, but gives similar, natural looking results.
属性
bool | flip_bend_direction |
float | target_maximum_distance |
float | target_minimum_distance |
NodePath | target_nodepath |
方法
NodePath | get_joint_one_bone2d_node ( ) const1 |
int | get_joint_one_bone_idx ( ) const1 |
NodePath | get_joint_two_bone2d_node ( ) const1 |
int | get_joint_two_bone_idx ( ) const1 |
void | set_joint_one_bone2d_node ( bone2d_node: NodePath ) |
void | set_joint_one_bone_idx ( bone_idx: int ) |
void | set_joint_two_bone2d_node ( bone2d_node: NodePath ) |
void | set_joint_two_bone_idx ( bone_idx: int ) |
属性说明
bool
flip_bend_direction = false
If true
, the bones in the modification will blend outward as opposed to inwards when contracting. If false
, the bones will bend inwards when contracting.
float
target_maximum_distance = 0.0
The maximum distance the target can be at. If the target is farther than this distance, the modification will solve as if it's at this maximum distance. When set to 0
, the modification will solve without distance constraints.
float
target_minimum_distance = 0.0
The minimum distance the target can be at. If the target is closer than this distance, the modification will solve as if it's at this minimum distance. When set to 0
, the modification will solve without distance constraints.
NodePath
target_nodepath = NodePath("")
The NodePath to the node that is the target for the TwoBoneIK modification. This node is what the modification will use when bending the Bone2D
nodes.
方法说明
NodePath
get_joint_one_bone2d_node ( ) const1
Returns the Bone2D
node that is being used as the first bone in the TwoBoneIK modification.
int
get_joint_one_bone_idx ( ) const1
Returns the index of the Bone2D
node that is being used as the first bone in the TwoBoneIK modification.
NodePath
get_joint_two_bone2d_node ( ) const1
Returns the Bone2D
node that is being used as the second bone in the TwoBoneIK modification.
int
get_joint_two_bone_idx ( ) const1
Returns the index of the Bone2D
node that is being used as the second bone in the TwoBoneIK modification.
void
set_joint_one_bone2d_node ( bone2d_node: NodePath
)
Sets the Bone2D
node that is being used as the first bone in the TwoBoneIK modification.
void
set_joint_one_bone_idx ( bone_idx: int
)
Sets the index of the Bone2D
node that is being used as the first bone in the TwoBoneIK modification.
void
set_joint_two_bone2d_node ( bone2d_node: NodePath
)
Sets the Bone2D
node that is being used as the second bone in the TwoBoneIK modification.
void
set_joint_two_bone_idx ( bone_idx: int
)
Sets the index of the Bone2D
node that is being used as the second bone in the TwoBoneIK modification.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。