godot/doc/classes/SkeletonModification2DTwoBo...

95 lines
4.6 KiB
XML
Raw Normal View History

New and improved IK system for Skeleton2D This PR and commit adds a new IK system for 2D with the Skeleton2D node that adds several new IK solvers, a way to control bones in a Skeleton2D node similar to that in Skeleton3D. It also adds additional changes and functionality. This work was sponsored by GSoC 2020 and TwistedTwigleg. Full list of changes: * Adds a SkeletonModifier2D resource * This resource is the base where all IK code is written and executed * Has a function for clamping angles, since it is so commonly used * Modifiers are unique when duplicated so it works with instancing * Adds a SkeletonModifierStack2D resource * This resource manages a series of SkeletonModification2Ds * This is what the Skeleton2D directly interfaces with to make IK possible * Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK * Each modification is in its own file * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together * Adds a PhysicalBone2D node * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node * Changes to Skeleton2D listed below: * Skeleton2D now holds a single SkeletonModificationStack2D for IK * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D * Changes to Bone2D listed below: * The default_length property has been changed to length. Length is the length of the bone to its child bone node * New bone_angle property, which is the angle the bone has to its first child bone node * Bone2D caches its transform when not modified by IK for IK interpolation purposes * Bone2D draws its own editor gizmo, though this is stated to change in the future * Changes to CanvasItemEditor listed below: * Bone2D gizmo drawing code removed * The 2D IK code is removed. Now Bone2D is the only bone system for 2D * Transform2D now has a looking_at function for rotating to face a position * Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE * These notifications only are called in the editor right before and after saving a scene * Needed for not saving the IK position when executing IK in the editor * Documentation for all the changes listed above.
2020-08-03 18:02:24 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SkeletonModification2DTwoBoneIK" inherits="SkeletonModification2D" version="4.0">
<brief_description>
A modification that rotates two bones using the law of cosigns to reach the target.
</brief_description>
<description>
This [SkeletonModification2D] 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 [SkeletonModification2DFABRIK], but gives similar, natural looking results.
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_joint_one_bone2d_node" qualifiers="const">
<return type="NodePath">
</return>
<description>
Returns the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification.
</description>
</method>
<method name="get_joint_one_bone_idx" qualifiers="const">
<return type="int">
</return>
<description>
Returns the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification.
</description>
</method>
<method name="get_joint_two_bone2d_node" qualifiers="const">
<return type="NodePath">
</return>
<description>
Returns the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification.
</description>
</method>
<method name="get_joint_two_bone_idx" qualifiers="const">
<return type="int">
</return>
<description>
Returns the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification.
</description>
</method>
<method name="set_joint_one_bone2d_node">
<return type="void">
</return>
<argument index="0" name="bone2d_node" type="NodePath">
</argument>
<description>
Sets the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification.
</description>
</method>
<method name="set_joint_one_bone_idx">
<return type="void">
</return>
<argument index="0" name="bone_idx" type="int">
</argument>
<description>
Sets the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification.
</description>
</method>
<method name="set_joint_two_bone2d_node">
<return type="void">
</return>
<argument index="0" name="bone2d_node" type="NodePath">
</argument>
<description>
Sets the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification.
</description>
</method>
<method name="set_joint_two_bone_idx">
<return type="void">
</return>
<argument index="0" name="bone_idx" type="int">
</argument>
<description>
Sets the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification.
</description>
</method>
</methods>
<members>
<member name="flip_bend_direction" type="bool" setter="set_flip_bend_direction" getter="get_flip_bend_direction" default="false">
If [code]true[/code], the bones in the modification will blend outward as opposed to inwards when contracting. If [code]false[/code], the bones will bend inwards when contracting.
</member>
<member name="target_maximum_distance" type="float" setter="set_target_maximum_distance" getter="get_target_maximum_distance" default="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 [code]0[/code], the modification will solve without distance constraints.
</member>
<member name="target_minimum_distance" type="float" setter="set_target_minimum_distance" getter="get_target_minimum_distance" default="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 [code]0[/code], the modification will solve without distance constraints.
</member>
<member name="target_nodepath" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath(&quot;&quot;)">
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.
</member>
</members>
<constants>
</constants>
</class>