class_skeletonmodification2dtwoboneik.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/SkeletonModification2DTwoBoneIK.xml.
  6. .. _class_SkeletonModification2DTwoBoneIK:
  7. SkeletonModification2DTwoBoneIK
  8. ===============================
  9. **Inherits:** :ref:`SkeletonModification2D<class_SkeletonModification2D>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A modification that rotates two bones using the law of cosines to reach the target.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This :ref:`SkeletonModification2D<class_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.
  15. 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 :ref:`SkeletonModification2DFABRIK<class_SkeletonModification2DFABRIK>`, but gives similar, natural looking results.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------------+--------------------------------------------------------------------------------------------------------+------------------+
  22. | :ref:`bool<class_bool>` | :ref:`flip_bend_direction<class_SkeletonModification2DTwoBoneIK_property_flip_bend_direction>` | ``false`` |
  23. +---------------------------------+--------------------------------------------------------------------------------------------------------+------------------+
  24. | :ref:`float<class_float>` | :ref:`target_maximum_distance<class_SkeletonModification2DTwoBoneIK_property_target_maximum_distance>` | ``0.0`` |
  25. +---------------------------------+--------------------------------------------------------------------------------------------------------+------------------+
  26. | :ref:`float<class_float>` | :ref:`target_minimum_distance<class_SkeletonModification2DTwoBoneIK_property_target_minimum_distance>` | ``0.0`` |
  27. +---------------------------------+--------------------------------------------------------------------------------------------------------+------------------+
  28. | :ref:`NodePath<class_NodePath>` | :ref:`target_nodepath<class_SkeletonModification2DTwoBoneIK_property_target_nodepath>` | ``NodePath("")`` |
  29. +---------------------------------+--------------------------------------------------------------------------------------------------------+------------------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`NodePath<class_NodePath>` | :ref:`get_joint_one_bone2d_node<class_SkeletonModification2DTwoBoneIK_method_get_joint_one_bone2d_node>` **(** **)** |const| |
  37. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_joint_one_bone_idx<class_SkeletonModification2DTwoBoneIK_method_get_joint_one_bone_idx>` **(** **)** |const| |
  39. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`NodePath<class_NodePath>` | :ref:`get_joint_two_bone2d_node<class_SkeletonModification2DTwoBoneIK_method_get_joint_two_bone2d_node>` **(** **)** |const| |
  41. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_joint_two_bone_idx<class_SkeletonModification2DTwoBoneIK_method_get_joint_two_bone_idx>` **(** **)** |const| |
  43. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_joint_one_bone2d_node<class_SkeletonModification2DTwoBoneIK_method_set_joint_one_bone2d_node>` **(** :ref:`NodePath<class_NodePath>` bone2d_node **)** |
  45. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_joint_one_bone_idx<class_SkeletonModification2DTwoBoneIK_method_set_joint_one_bone_idx>` **(** :ref:`int<class_int>` bone_idx **)** |
  47. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_joint_two_bone2d_node<class_SkeletonModification2DTwoBoneIK_method_set_joint_two_bone2d_node>` **(** :ref:`NodePath<class_NodePath>` bone2d_node **)** |
  49. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_joint_two_bone_idx<class_SkeletonModification2DTwoBoneIK_method_set_joint_two_bone_idx>` **(** :ref:`int<class_int>` bone_idx **)** |
  51. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. .. rst-class:: classref-section-separator
  53. ----
  54. .. rst-class:: classref-descriptions-group
  55. Property Descriptions
  56. ---------------------
  57. .. _class_SkeletonModification2DTwoBoneIK_property_flip_bend_direction:
  58. .. rst-class:: classref-property
  59. :ref:`bool<class_bool>` **flip_bend_direction** = ``false``
  60. .. rst-class:: classref-property-setget
  61. - void **set_flip_bend_direction** **(** :ref:`bool<class_bool>` value **)**
  62. - :ref:`bool<class_bool>` **get_flip_bend_direction** **(** **)**
  63. 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.
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_SkeletonModification2DTwoBoneIK_property_target_maximum_distance:
  67. .. rst-class:: classref-property
  68. :ref:`float<class_float>` **target_maximum_distance** = ``0.0``
  69. .. rst-class:: classref-property-setget
  70. - void **set_target_maximum_distance** **(** :ref:`float<class_float>` value **)**
  71. - :ref:`float<class_float>` **get_target_maximum_distance** **(** **)**
  72. 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.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_SkeletonModification2DTwoBoneIK_property_target_minimum_distance:
  76. .. rst-class:: classref-property
  77. :ref:`float<class_float>` **target_minimum_distance** = ``0.0``
  78. .. rst-class:: classref-property-setget
  79. - void **set_target_minimum_distance** **(** :ref:`float<class_float>` value **)**
  80. - :ref:`float<class_float>` **get_target_minimum_distance** **(** **)**
  81. 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.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_SkeletonModification2DTwoBoneIK_property_target_nodepath:
  85. .. rst-class:: classref-property
  86. :ref:`NodePath<class_NodePath>` **target_nodepath** = ``NodePath("")``
  87. .. rst-class:: classref-property-setget
  88. - void **set_target_node** **(** :ref:`NodePath<class_NodePath>` value **)**
  89. - :ref:`NodePath<class_NodePath>` **get_target_node** **(** **)**
  90. The NodePath to the node that is the target for the TwoBoneIK modification. This node is what the modification will use when bending the :ref:`Bone2D<class_Bone2D>` nodes.
  91. .. rst-class:: classref-section-separator
  92. ----
  93. .. rst-class:: classref-descriptions-group
  94. Method Descriptions
  95. -------------------
  96. .. _class_SkeletonModification2DTwoBoneIK_method_get_joint_one_bone2d_node:
  97. .. rst-class:: classref-method
  98. :ref:`NodePath<class_NodePath>` **get_joint_one_bone2d_node** **(** **)** |const|
  99. Returns the :ref:`Bone2D<class_Bone2D>` node that is being used as the first bone in the TwoBoneIK modification.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_SkeletonModification2DTwoBoneIK_method_get_joint_one_bone_idx:
  103. .. rst-class:: classref-method
  104. :ref:`int<class_int>` **get_joint_one_bone_idx** **(** **)** |const|
  105. Returns the index of the :ref:`Bone2D<class_Bone2D>` node that is being used as the first bone in the TwoBoneIK modification.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_SkeletonModification2DTwoBoneIK_method_get_joint_two_bone2d_node:
  109. .. rst-class:: classref-method
  110. :ref:`NodePath<class_NodePath>` **get_joint_two_bone2d_node** **(** **)** |const|
  111. Returns the :ref:`Bone2D<class_Bone2D>` node that is being used as the second bone in the TwoBoneIK modification.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_SkeletonModification2DTwoBoneIK_method_get_joint_two_bone_idx:
  115. .. rst-class:: classref-method
  116. :ref:`int<class_int>` **get_joint_two_bone_idx** **(** **)** |const|
  117. Returns the index of the :ref:`Bone2D<class_Bone2D>` node that is being used as the second bone in the TwoBoneIK modification.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_SkeletonModification2DTwoBoneIK_method_set_joint_one_bone2d_node:
  121. .. rst-class:: classref-method
  122. void **set_joint_one_bone2d_node** **(** :ref:`NodePath<class_NodePath>` bone2d_node **)**
  123. Sets the :ref:`Bone2D<class_Bone2D>` node that is being used as the first bone in the TwoBoneIK modification.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_SkeletonModification2DTwoBoneIK_method_set_joint_one_bone_idx:
  127. .. rst-class:: classref-method
  128. void **set_joint_one_bone_idx** **(** :ref:`int<class_int>` bone_idx **)**
  129. Sets the index of the :ref:`Bone2D<class_Bone2D>` node that is being used as the first bone in the TwoBoneIK modification.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_SkeletonModification2DTwoBoneIK_method_set_joint_two_bone2d_node:
  133. .. rst-class:: classref-method
  134. void **set_joint_two_bone2d_node** **(** :ref:`NodePath<class_NodePath>` bone2d_node **)**
  135. Sets the :ref:`Bone2D<class_Bone2D>` node that is being used as the second bone in the TwoBoneIK modification.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_SkeletonModification2DTwoBoneIK_method_set_joint_two_bone_idx:
  139. .. rst-class:: classref-method
  140. void **set_joint_two_bone_idx** **(** :ref:`int<class_int>` bone_idx **)**
  141. Sets the index of the :ref:`Bone2D<class_Bone2D>` node that is being used as the second bone in the TwoBoneIK modification.
  142. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  143. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  144. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  145. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  146. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  147. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  148. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`