SkeletonModification3DTwoBoneIK

Inherits: SkeletonModification3D < Resource < RefCounted < Object

A modification that moves two bones to reach the target.

Description

This SkeletonModification3D uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns 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 verticies of the triangle. Because the algorithm works by making a triangle, it can only opperate 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 SkeletonModification3DFABRIK, but gives similar, natural looking results.

A Node3D-based node can be used to define the pole, or bend direction, allowing control over which direction the joint takes when bending to reach the target when the target is within reach.

Properties

NodePath

target_nodepath

NodePath("")

Methods

bool

get_auto_calculate_joint_length ( ) const

int

get_joint_one_bone_idx ( ) const

String

get_joint_one_bone_name ( ) const

float

get_joint_one_length ( ) const

float

get_joint_one_roll ( ) const

int

get_joint_two_bone_idx ( ) const

String

get_joint_two_bone_name ( ) const

float

get_joint_two_length ( ) const

float

get_joint_two_roll ( ) const

NodePath

get_pole_node ( ) const

NodePath

get_tip_node ( ) const

bool

get_use_pole_node ( ) const

bool

get_use_tip_node ( ) const

void

set_auto_calculate_joint_length ( bool auto_calculate_joint_length )

void

set_joint_one_bone_idx ( int bone_idx )

void

set_joint_one_bone_name ( String bone_name )

void

set_joint_one_length ( float bone_length )

void

set_joint_one_roll ( float roll )

void

set_joint_two_bone_idx ( int bone_idx )

void

set_joint_two_bone_name ( String bone_name )

void

set_joint_two_length ( float bone_length )

void

set_joint_two_roll ( float roll )

void

set_pole_node ( NodePath pole_nodepath )

void

set_tip_node ( NodePath tip_nodepath )

void

set_use_pole_node ( bool use_pole_node )

void

set_use_tip_node ( bool use_tip_node )

Property Descriptions

Default

NodePath("")

Setter

set_target_node(value)

Getter

get_target_node()

The NodePath to the node that is the target for the TwoBoneIK modification. This node is what the modification will attempt to rotate the bones to reach.

Method Descriptions

  • bool get_auto_calculate_joint_length ( ) const

Returns whether the TwoBoneIK modification will attempt to autocalculate the lengths of the two bones.


  • int get_joint_one_bone_idx ( ) const

Returns the bone index of the first bone in the TwoBoneIK modification.


  • String get_joint_one_bone_name ( ) const

Returns the name of the first bone in the TwoBoneIK modification.


  • float get_joint_one_length ( ) const

Returns the length of the first bone in the TwoBoneIK modification.


  • float get_joint_one_roll ( ) const

Returns the amount of roll/twist applied to the first bone in the TwoBoneIK modification.


  • int get_joint_two_bone_idx ( ) const

Returns the bone index of the second bone in the TwoBoneIK modification.


  • String get_joint_two_bone_name ( ) const

Returns the name of the second bone in the TwoBoneIK modification.


  • float get_joint_two_length ( ) const

Returns the length of the second bone in the TwoBoneIK modification.


  • float get_joint_two_roll ( ) const

Returns the amount of roll/twist applied to the second bone in the TwoBoneIK modification.


Returns the node that is being used as the pole node for the TwoBoneIK modification, if a pole node has been set.


Returns the node that is being used to calculate the tip position of the second bone in the TwoBoneIK modification, if a tip node has been set.


  • bool get_use_pole_node ( ) const

Returns whether the TwoBoneIK modification will attempt to use the pole node to figure out which direction to bend, if a pole node has been set.


  • bool get_use_tip_node ( ) const

Returns whether the TwoBoneIK modification will attempt to use the tip node to figure out the length and position of the tip of the second bone.


  • void set_auto_calculate_joint_length ( bool auto_calculate_joint_length )

If true, the TwoBoneIK modification will attempt to autocalculate the lengths of the bones being used. The first bone will be calculated by using the distance from the origin of the first bone to the origin of the second bone.

The second bone will be calculated either using the tip node if that setting is enabled, or by using the distances of the second bone's children. If the tip node is not enabled and the bone has no children, then the length cannot be autocalculated. In this case, the length will either have to be manually inputted or a tip node used to calculate the length.


  • void set_joint_one_bone_idx ( int bone_idx )

Sets the bone index, bone_index, of the first bone. When possible, this will also update the bone_name of the first bone based on data provided by the Skeleton3D.


  • void set_joint_one_bone_name ( String bone_name )

Sets the bone name, bone_name, of the first bone. When possible, this will also update the bone_index of the first bone based on data provided by the Skeleton3D.


  • void set_joint_one_length ( float bone_length )

Sets the length of the first bone in the TwoBoneIK modification.


  • void set_joint_one_roll ( float roll )

Sets the amount of roll/twist applied to the first bone in the TwoBoneIK modification.


  • void set_joint_two_bone_idx ( int bone_idx )

Sets the bone index, bone_index, of the second bone. When possible, this will also update the bone_name of the second bone based on data provided by the Skeleton3D.


  • void set_joint_two_bone_name ( String bone_name )

Sets the bone name, bone_name, of the second bone. When possible, this will also update the bone_index of the second bone based on data provided by the Skeleton3D.


  • void set_joint_two_length ( float bone_length )

Sets the length of the second bone in the TwoBoneIK modification.


  • void set_joint_two_roll ( float roll )

Sets the amount of roll/twist applied to the second bone in the TwoBoneIK modification.


  • void set_pole_node ( NodePath pole_nodepath )

Sets the node to be used as the for the pole of the TwoBoneIK. When a node is set and the modification is set to use the pole node, the TwoBoneIK modification will bend the nodes in the direction towards this node when the bones need to bend.


  • void set_tip_node ( NodePath tip_nodepath )

Sets the node to be used as the tip for the second bone. This is used to calculate the length and position of the end of the second bone in the TwoBoneIK modification.

Note: The tip node should generally be a child node of a BoneAttachment3D node attached to the second bone, with the child node being offset so it is at the end of the bone.


  • void set_use_pole_node ( bool use_pole_node )

When true, the TwoBoneIK modification will bend the bones towards the pole node, if one has been set. This gives control over the direction the TwoBoneIK solver will bend, which is helpful for joints like elbows that only bend in certain directions.


  • void set_use_tip_node ( bool use_tip_node )

When true, the TwoBoneIK modification will use the tip node to calculate the distance and position of the end/tip of the second bone. This is the most stable solution for knowing the tip position and length of the second bone.