IterateIK3D
Inherits: ChainIK3D < IKModifier3D < SkeletonModifier3D < Entity3D < Entity < Object
Inherited by: CCDIK3D, FABRIK3D, JacobianIK3D
Description
Section titled “Description”A SkeletonModifier3D to approach the goal by repeating small rotations.
Base class of SkeletonModifier3D to approach the goal by repeating small rotations.
Each bone chain (setting) has one effector, which is processed in order of the setting list. You can set some limitations for each joint.
Note: All the methods in this class take an index parameter. This parameter specifies which setting list entry to return if the IK has multiple entries (e.g. settings/<index>/target_node).
Note: When set_joint_rotation_axis() or set_joint_limitation() is set, the IK tip may not reach the target. This occurs because IK calculates the path through iterations, and in some cases, it may hit a limit during the process and fail to resolve. In some cases, this can be resolved by splitting the IK into several SkeletonModifier3Ds and setting the iteration order manually.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| float | angular_delta_limit |
0.034906585 |
| bool | deterministic |
false |
| int | max_iterations |
4 |
| float | min_distance |
0.001 |
| int | setting_count |
0 |
Methods
Section titled “Methods”Property descriptions
Section titled “Property descriptions”angular_delta_limit
float angular_delta_limit = 0.034906585
The maximum amount each bone can rotate in a single iteration.
Note: This limitation is applied during each iteration. For example, if max_iterations is 4 and angular_delta_limit is 5 degrees, the maximum rotation possible in a single frame is 20 degrees.
deterministic
bool deterministic = false
If false, the result is calculated from the previous frame’s IterateIK3D result as the initial state.
If true, the previous frame’s IterateIK3D result is discarded. At this point, the new result is calculated from the bone pose excluding the IterateIK3D as the initial state. This means the result will be always equal as long as the target position and the previous bone pose are the same. However, if angular_delta_limit and max_iterations are set too small, the end bone of the chain will never reach the target.
max_iterations
int max_iterations = 4
The number of iteration loops used by the IK solver to produce more accurate results.
min_distance
float min_distance = 0.001
The minimum distance between the end bone and the target. If the distance is below this value, the IK solver stops any further iterations.
setting_count
int setting_count = 0
The number of settings.
Method descriptions
Section titled “Method descriptions”get_joint_limitation
JointLimitation3D get_joint_limitation(index: int, joint: int) const
Returns the joint limitation at joint in the bone chain’s joint list.
get_joint_limitation_right_axis
SkeletonModifier3D.SecondaryDirection get_joint_limitation_right_axis(index: int, joint: int) const
Returns the joint limitation right axis at joint in the bone chain’s joint list.
get_joint_limitation_right_axis_vector
Vector3 get_joint_limitation_right_axis_vector(index: int, joint: int) const
Returns the joint limitation right axis vector at joint in the bone chain’s joint list.
If get_joint_limitation_right_axis() is SkeletonModifier3D.SECONDARY_DIRECTION_NONE, this method returns Vector3(0, 0, 0).
get_joint_limitation_rotation_offset
Quaternion get_joint_limitation_rotation_offset(index: int, joint: int) const
Returns the joint limitation rotation offset at joint in the bone chain’s joint list.
Rotation is done in the local space which is constructed by the bone direction (in general parent to child) as the +Y axis and get_joint_limitation_right_axis_vector() as the +X axis.
If the +X and +Y axes are not orthogonal, the +X axis is implicitly modified to make it orthogonal.
Also, if the length of get_joint_limitation_right_axis_vector() is zero, the space is created by rotating the reference pose using the shortest arc that rotates the +Y axis of the reference pose to match the bone direction.
In here, the reference pose is the bone rest or bone pose immediately before processing IK depending on the is_joint_using_rest_for_limitation().
get_joint_rotation_axis
SkeletonModifier3D.RotationAxis get_joint_rotation_axis(index: int, joint: int) const
Returns the rotation axis at joint in the bone chain’s joint list.
get_joint_rotation_axis_vector
Vector3 get_joint_rotation_axis_vector(index: int, joint: int) const
Returns the rotation axis vector for the specified joint in the bone chain. This vector represents the axis around which the joint can rotate. It is determined based on the rotation axis set for the joint.
If get_joint_rotation_axis() is SkeletonModifier3D.ROTATION_AXIS_ALL, this method returns Vector3(0, 0, 0).
get_target_node
EntityPath get_target_node(index: int) const
Returns the target node that the end bone is trying to reach.
is_joint_using_rest_for_limitation
bool is_joint_using_rest_for_limitation(index: int, joint: int) const
Returns whether the limitation at joint in the bone chain’s joint list is applied based on the Skeleton3D.get_bone_rest().
set_joint_limitation
void set_joint_limitation(index: int, joint: int, limitation: JointLimitation3D)
Sets the joint limitation at joint in the bone chain’s joint list.
set_joint_limitation_right_axis
void set_joint_limitation_right_axis(index: int, joint: int, direction: SkeletonModifier3D.SecondaryDirection)
Sets the joint limitation right axis at joint in the bone chain’s joint list.
set_joint_limitation_right_axis_vector
void set_joint_limitation_right_axis_vector(index: int, joint: int, vector: Vector3)
Sets the optional joint limitation right axis vector at joint in the bone chain’s joint list.
set_joint_limitation_rotation_offset
void set_joint_limitation_rotation_offset(index: int, joint: int, offset: Quaternion)
Sets the joint limitation rotation offset at joint in the bone chain’s joint list.
Rotation is done in the local space which is constructed by the bone direction (in general parent to child) as the +Y axis and get_joint_limitation_right_axis_vector() as the +X axis.
If the +X and +Y axes are not orthogonal, the +X axis is implicitly modified to make it orthogonal.
Also, if the length of get_joint_limitation_right_axis_vector() is zero, the space is created by rotating the reference pose using the shortest arc that rotates the +Y axis of the reference pose to match the bone direction.
In here, the reference pose is the bone pose immediately before processing IK.
set_joint_rotation_axis
void set_joint_rotation_axis(index: int, joint: int, axis: SkeletonModifier3D.RotationAxis)
Sets the rotation axis at joint in the bone chain’s joint list.
The axes are based on the reference pose’s space, if axis is SkeletonModifier3D.ROTATION_AXIS_CUSTOM, you can specify any axis.
In here, the reference pose is the bone pose immediately before processing IK.
Note: The rotation axis and the forward vector shouldn’t be colinear to avoid unintended rotation since ChainIK3D does not factor in twisting forces.
Note: Since IterateIK3D never modifies the twist, the twist is not fixed by set_joint_rotation_axis() even if is_joint_using_rest_for_limitation() is true.
set_joint_rotation_axis_vector
void set_joint_rotation_axis_vector(index: int, joint: int, axis_vector: Vector3)
Sets the rotation axis vector for the specified joint in the bone chain.
This vector is normalized by an internal process and represents the axis around which the bone chain can rotate.
If the vector length is 0, it is considered synonymous with SkeletonModifier3D.ROTATION_AXIS_ALL.
set_joint_use_rest_for_limitation
void set_joint_use_rest_for_limitation(index: int, joint: int, enabled: bool)
Sets whether the limitation and the rotation axis at joint in the bone chain’s joint list are applied based on the Skeleton3D.get_bone_rest(). See also set_joint_rotation_axis().
Note: The limitation is applied to the rotation computed by this modifier. If the reference pose is rotated around the same axis, the limitation behaves as if it also limits the rotation of the reference pose. A rotation that this modifier does not change, such as the twist, is not limited.
Note: The rendered gizmo’s limitation shape will only respect the reference pose when this option is false and the modifier is active.
set_target_node
void set_target_node(index: int, target_node: EntityPath)
Sets the target node that the end bone is trying to reach.
