class_skeletonmodification2dfabrik.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/doc/classes/SkeletonModification2DFABRIK.xml.
  6. .. _class_SkeletonModification2DFABRIK:
  7. SkeletonModification2DFABRIK
  8. ============================
  9. **Inherits:** :ref:`SkeletonModification2D<class_SkeletonModification2D>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A modification that uses FABRIK to manipulate a series of :ref:`Bone2D<class_Bone2D>` nodes to reach a target.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This :ref:`SkeletonModification2D<class_SkeletonModification2D>` uses an algorithm called Forward And Backward Reaching Inverse Kinematics, or FABRIK, to rotate a bone chain so that it reaches a target.
  15. FABRIK works by knowing the positions and lengths of a series of bones, typically called a "bone chain". It first starts by running a forward pass, which places the final bone at the target's position. Then all other bones are moved towards the tip bone, so they stay at the defined bone length away. Then a backwards pass is performed, where the root/first bone in the FABRIK chain is placed back at the origin. Then all other bones are moved so they stay at the defined bone length away. This positions the bone chain so that it reaches the target when possible, but all of the bones stay the correct length away from each other.
  16. Because of how FABRIK works, it often gives more natural results than those seen in :ref:`SkeletonModification2DCCDIK<class_SkeletonModification2DCCDIK>`. FABRIK also supports angle constraints, which are fully taken into account when solving.
  17. \ **Note:** The FABRIK modifier has ``fabrik_joints``, which are the data objects that hold the data for each joint in the FABRIK chain. This is different from :ref:`Bone2D<class_Bone2D>` nodes! FABRIK joints hold the data needed for each :ref:`Bone2D<class_Bone2D>` in the bone chain used by FABRIK.
  18. To help control how the FABRIK joints move, a magnet vector can be passed, which can nudge the bones in a certain direction prior to solving, giving a level of control over the final result.
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +---------------------------------+-------------------------------------------------------------------------------------------------------+------------------+
  25. | :ref:`int<class_int>` | :ref:`fabrik_data_chain_length<class_SkeletonModification2DFABRIK_property_fabrik_data_chain_length>` | ``0`` |
  26. +---------------------------------+-------------------------------------------------------------------------------------------------------+------------------+
  27. | :ref:`NodePath<class_NodePath>` | :ref:`target_nodepath<class_SkeletonModification2DFABRIK_property_target_nodepath>` | ``NodePath("")`` |
  28. +---------------------------------+-------------------------------------------------------------------------------------------------------+------------------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`NodePath<class_NodePath>` | :ref:`get_fabrik_joint_bone2d_node<class_SkeletonModification2DFABRIK_method_get_fabrik_joint_bone2d_node>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  36. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`get_fabrik_joint_bone_index<class_SkeletonModification2DFABRIK_method_get_fabrik_joint_bone_index>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  38. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector2<class_Vector2>` | :ref:`get_fabrik_joint_magnet_position<class_SkeletonModification2DFABRIK_method_get_fabrik_joint_magnet_position>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  40. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`get_fabrik_joint_use_target_rotation<class_SkeletonModification2DFABRIK_method_get_fabrik_joint_use_target_rotation>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  42. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_fabrik_joint_bone2d_node<class_SkeletonModification2DFABRIK_method_set_fabrik_joint_bone2d_node>` **(** :ref:`int<class_int>` joint_idx, :ref:`NodePath<class_NodePath>` bone2d_nodepath **)** |
  44. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_fabrik_joint_bone_index<class_SkeletonModification2DFABRIK_method_set_fabrik_joint_bone_index>` **(** :ref:`int<class_int>` joint_idx, :ref:`int<class_int>` bone_idx **)** |
  46. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_fabrik_joint_magnet_position<class_SkeletonModification2DFABRIK_method_set_fabrik_joint_magnet_position>` **(** :ref:`int<class_int>` joint_idx, :ref:`Vector2<class_Vector2>` magnet_position **)** |
  48. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_fabrik_joint_use_target_rotation<class_SkeletonModification2DFABRIK_method_set_fabrik_joint_use_target_rotation>` **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` use_target_rotation **)** |
  50. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. .. rst-class:: classref-section-separator
  52. ----
  53. .. rst-class:: classref-descriptions-group
  54. Property Descriptions
  55. ---------------------
  56. .. _class_SkeletonModification2DFABRIK_property_fabrik_data_chain_length:
  57. .. rst-class:: classref-property
  58. :ref:`int<class_int>` **fabrik_data_chain_length** = ``0``
  59. .. rst-class:: classref-property-setget
  60. - void **set_fabrik_data_chain_length** **(** :ref:`int<class_int>` value **)**
  61. - :ref:`int<class_int>` **get_fabrik_data_chain_length** **(** **)**
  62. The number of FABRIK joints in the FABRIK modification.
  63. .. rst-class:: classref-item-separator
  64. ----
  65. .. _class_SkeletonModification2DFABRIK_property_target_nodepath:
  66. .. rst-class:: classref-property
  67. :ref:`NodePath<class_NodePath>` **target_nodepath** = ``NodePath("")``
  68. .. rst-class:: classref-property-setget
  69. - void **set_target_node** **(** :ref:`NodePath<class_NodePath>` value **)**
  70. - :ref:`NodePath<class_NodePath>` **get_target_node** **(** **)**
  71. The NodePath to the node that is the target for the FABRIK modification. This node is what the FABRIK chain will attempt to rotate the bone chain to.
  72. .. rst-class:: classref-section-separator
  73. ----
  74. .. rst-class:: classref-descriptions-group
  75. Method Descriptions
  76. -------------------
  77. .. _class_SkeletonModification2DFABRIK_method_get_fabrik_joint_bone2d_node:
  78. .. rst-class:: classref-method
  79. :ref:`NodePath<class_NodePath>` **get_fabrik_joint_bone2d_node** **(** :ref:`int<class_int>` joint_idx **)** |const|
  80. Returns the :ref:`Bone2D<class_Bone2D>` node assigned to the FABRIK joint at ``joint_idx``.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_SkeletonModification2DFABRIK_method_get_fabrik_joint_bone_index:
  84. .. rst-class:: classref-method
  85. :ref:`int<class_int>` **get_fabrik_joint_bone_index** **(** :ref:`int<class_int>` joint_idx **)** |const|
  86. Returns the index of the :ref:`Bone2D<class_Bone2D>` node assigned to the FABRIK joint at ``joint_idx``.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_SkeletonModification2DFABRIK_method_get_fabrik_joint_magnet_position:
  90. .. rst-class:: classref-method
  91. :ref:`Vector2<class_Vector2>` **get_fabrik_joint_magnet_position** **(** :ref:`int<class_int>` joint_idx **)** |const|
  92. Returns the magnet position vector for the joint at ``joint_idx``.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_SkeletonModification2DFABRIK_method_get_fabrik_joint_use_target_rotation:
  96. .. rst-class:: classref-method
  97. :ref:`bool<class_bool>` **get_fabrik_joint_use_target_rotation** **(** :ref:`int<class_int>` joint_idx **)** |const|
  98. Returns whether the joint is using the target's rotation rather than allowing FABRIK to rotate the joint. This option only applies to the tip/final joint in the chain.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_SkeletonModification2DFABRIK_method_set_fabrik_joint_bone2d_node:
  102. .. rst-class:: classref-method
  103. void **set_fabrik_joint_bone2d_node** **(** :ref:`int<class_int>` joint_idx, :ref:`NodePath<class_NodePath>` bone2d_nodepath **)**
  104. Sets the :ref:`Bone2D<class_Bone2D>` node assigned to the FABRIK joint at ``joint_idx``.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_SkeletonModification2DFABRIK_method_set_fabrik_joint_bone_index:
  108. .. rst-class:: classref-method
  109. void **set_fabrik_joint_bone_index** **(** :ref:`int<class_int>` joint_idx, :ref:`int<class_int>` bone_idx **)**
  110. Sets the bone index, ``bone_idx``, of the FABRIK joint at ``joint_idx``. When possible, this will also update the ``bone2d_node`` of the FABRIK joint based on data provided by the linked skeleton.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_SkeletonModification2DFABRIK_method_set_fabrik_joint_magnet_position:
  114. .. rst-class:: classref-method
  115. void **set_fabrik_joint_magnet_position** **(** :ref:`int<class_int>` joint_idx, :ref:`Vector2<class_Vector2>` magnet_position **)**
  116. Sets the magnet position vector for the joint at ``joint_idx``.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_SkeletonModification2DFABRIK_method_set_fabrik_joint_use_target_rotation:
  120. .. rst-class:: classref-method
  121. void **set_fabrik_joint_use_target_rotation** **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` use_target_rotation **)**
  122. Sets whether the joint at ``joint_idx`` will use the target node's rotation rather than letting FABRIK rotate the node.
  123. \ **Note:** This option only works for the tip/final joint in the chain. For all other nodes, this option will be ignored.
  124. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  125. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  126. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  127. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  128. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  129. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  130. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`