class_skeletonmodification2dtwoboneik.rst 14 KB

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