class_skeletonmodification2dccdik.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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/SkeletonModification2DCCDIK.xml.
  6. .. _class_SkeletonModification2DCCDIK:
  7. SkeletonModification2DCCDIK
  8. ===========================
  9. **Inherits:** :ref:`SkeletonModification2D<class_SkeletonModification2D>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This :ref:`SkeletonModification2D<class_SkeletonModification2D>` uses an algorithm called Cyclic Coordinate Descent Inverse Kinematics, or CCDIK, to manipulate a chain of bones in a :ref:`Skeleton2D<class_Skeleton2D>` so it reaches a defined target.
  15. CCDIK works by rotating a set of bones, typically called a "bone chain", on a single axis. Each bone is rotated to face the target from the tip (by default), which over a chain of bones allow it to rotate properly to reach the target. Because the bones only rotate on a single axis, CCDIK *can* look more robotic than other IK solvers.
  16. \ **Note:** The CCDIK modifier has ``ccdik_joints``, which are the data objects that hold the data for each joint in the CCDIK chain. This is different from a bone! CCDIK joints hold the data needed for each bone in the bone chain used by CCDIK.
  17. CCDIK also fully supports angle constraints, allowing for more control over how a solution is met.
  18. .. rst-class:: classref-reftable-group
  19. Properties
  20. ----------
  21. .. table::
  22. :widths: auto
  23. +---------------------------------+----------------------------------------------------------------------------------------------------+------------------+
  24. | :ref:`int<class_int>` | :ref:`ccdik_data_chain_length<class_SkeletonModification2DCCDIK_property_ccdik_data_chain_length>` | ``0`` |
  25. +---------------------------------+----------------------------------------------------------------------------------------------------+------------------+
  26. | :ref:`NodePath<class_NodePath>` | :ref:`target_nodepath<class_SkeletonModification2DCCDIK_property_target_nodepath>` | ``NodePath("")`` |
  27. +---------------------------------+----------------------------------------------------------------------------------------------------+------------------+
  28. | :ref:`NodePath<class_NodePath>` | :ref:`tip_nodepath<class_SkeletonModification2DCCDIK_property_tip_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_ccdik_joint_bone2d_node<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_bone2d_node>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  37. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_ccdik_joint_bone_index<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_bone_index>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  39. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`get_ccdik_joint_constraint_angle_invert<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_invert>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  41. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_ccdik_joint_constraint_angle_max<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_max>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  43. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_ccdik_joint_constraint_angle_min<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_min>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  45. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`get_ccdik_joint_enable_constraint<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_enable_constraint>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  47. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`get_ccdik_joint_rotate_from_joint<class_SkeletonModification2DCCDIK_method_get_ccdik_joint_rotate_from_joint>` **(** :ref:`int<class_int>` joint_idx **)** |const| |
  49. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_ccdik_joint_bone2d_node<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_bone2d_node>` **(** :ref:`int<class_int>` joint_idx, :ref:`NodePath<class_NodePath>` bone2d_nodepath **)** |
  51. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_ccdik_joint_bone_index<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_bone_index>` **(** :ref:`int<class_int>` joint_idx, :ref:`int<class_int>` bone_idx **)** |
  53. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_ccdik_joint_constraint_angle_invert<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_invert>` **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` invert **)** |
  55. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_ccdik_joint_constraint_angle_max<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_max>` **(** :ref:`int<class_int>` joint_idx, :ref:`float<class_float>` angle_max **)** |
  57. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_ccdik_joint_constraint_angle_min<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_min>` **(** :ref:`int<class_int>` joint_idx, :ref:`float<class_float>` angle_min **)** |
  59. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_ccdik_joint_enable_constraint<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_enable_constraint>` **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` enable_constraint **)** |
  61. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_ccdik_joint_rotate_from_joint<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_rotate_from_joint>` **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` rotate_from_joint **)** |
  63. +---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. .. rst-class:: classref-section-separator
  65. ----
  66. .. rst-class:: classref-descriptions-group
  67. Property Descriptions
  68. ---------------------
  69. .. _class_SkeletonModification2DCCDIK_property_ccdik_data_chain_length:
  70. .. rst-class:: classref-property
  71. :ref:`int<class_int>` **ccdik_data_chain_length** = ``0``
  72. .. rst-class:: classref-property-setget
  73. - void **set_ccdik_data_chain_length** **(** :ref:`int<class_int>` value **)**
  74. - :ref:`int<class_int>` **get_ccdik_data_chain_length** **(** **)**
  75. The number of CCDIK joints in the CCDIK modification.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_SkeletonModification2DCCDIK_property_target_nodepath:
  79. .. rst-class:: classref-property
  80. :ref:`NodePath<class_NodePath>` **target_nodepath** = ``NodePath("")``
  81. .. rst-class:: classref-property-setget
  82. - void **set_target_node** **(** :ref:`NodePath<class_NodePath>` value **)**
  83. - :ref:`NodePath<class_NodePath>` **get_target_node** **(** **)**
  84. The NodePath to the node that is the target for the CCDIK modification. This node is what the CCDIK chain will attempt to rotate the bone chain to.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_SkeletonModification2DCCDIK_property_tip_nodepath:
  88. .. rst-class:: classref-property
  89. :ref:`NodePath<class_NodePath>` **tip_nodepath** = ``NodePath("")``
  90. .. rst-class:: classref-property-setget
  91. - void **set_tip_node** **(** :ref:`NodePath<class_NodePath>` value **)**
  92. - :ref:`NodePath<class_NodePath>` **get_tip_node** **(** **)**
  93. The end position of the CCDIK chain. Typically, this should be a child of a :ref:`Bone2D<class_Bone2D>` node attached to the final :ref:`Bone2D<class_Bone2D>` in the CCDIK chain.
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Method Descriptions
  98. -------------------
  99. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_bone2d_node:
  100. .. rst-class:: classref-method
  101. :ref:`NodePath<class_NodePath>` **get_ccdik_joint_bone2d_node** **(** :ref:`int<class_int>` joint_idx **)** |const|
  102. Returns the :ref:`Bone2D<class_Bone2D>` node assigned to the CCDIK joint at ``joint_idx``.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_bone_index:
  106. .. rst-class:: classref-method
  107. :ref:`int<class_int>` **get_ccdik_joint_bone_index** **(** :ref:`int<class_int>` joint_idx **)** |const|
  108. Returns the index of the :ref:`Bone2D<class_Bone2D>` node assigned to the CCDIK joint at ``joint_idx``.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_invert:
  112. .. rst-class:: classref-method
  113. :ref:`bool<class_bool>` **get_ccdik_joint_constraint_angle_invert** **(** :ref:`int<class_int>` joint_idx **)** |const|
  114. Returns whether the CCDIK joint at ``joint_idx`` uses an inverted joint constraint. See :ref:`set_ccdik_joint_constraint_angle_invert<class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_invert>` for details.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_max:
  118. .. rst-class:: classref-method
  119. :ref:`float<class_float>` **get_ccdik_joint_constraint_angle_max** **(** :ref:`int<class_int>` joint_idx **)** |const|
  120. Returns the maximum angle constraint for the joint at ``joint_idx``.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_constraint_angle_min:
  124. .. rst-class:: classref-method
  125. :ref:`float<class_float>` **get_ccdik_joint_constraint_angle_min** **(** :ref:`int<class_int>` joint_idx **)** |const|
  126. Returns the minimum angle constraint for the joint at ``joint_idx``.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_enable_constraint:
  130. .. rst-class:: classref-method
  131. :ref:`bool<class_bool>` **get_ccdik_joint_enable_constraint** **(** :ref:`int<class_int>` joint_idx **)** |const|
  132. Returns whether angle constraints on the CCDIK joint at ``joint_idx`` are enabled.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_SkeletonModification2DCCDIK_method_get_ccdik_joint_rotate_from_joint:
  136. .. rst-class:: classref-method
  137. :ref:`bool<class_bool>` **get_ccdik_joint_rotate_from_joint** **(** :ref:`int<class_int>` joint_idx **)** |const|
  138. Returns whether the joint at ``joint_idx`` is set to rotate from the joint, ``true``, or to rotate from the tip, ``false``. The default is to rotate from the tip.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_bone2d_node:
  142. .. rst-class:: classref-method
  143. void **set_ccdik_joint_bone2d_node** **(** :ref:`int<class_int>` joint_idx, :ref:`NodePath<class_NodePath>` bone2d_nodepath **)**
  144. Sets the :ref:`Bone2D<class_Bone2D>` node assigned to the CCDIK joint at ``joint_idx``.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_bone_index:
  148. .. rst-class:: classref-method
  149. void **set_ccdik_joint_bone_index** **(** :ref:`int<class_int>` joint_idx, :ref:`int<class_int>` bone_idx **)**
  150. Sets the bone index, ``bone_idx``, of the CCDIK joint at ``joint_idx``. When possible, this will also update the ``bone2d_node`` of the CCDIK joint based on data provided by the linked skeleton.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_invert:
  154. .. rst-class:: classref-method
  155. void **set_ccdik_joint_constraint_angle_invert** **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` invert **)**
  156. Sets whether the CCDIK joint at ``joint_idx`` uses an inverted joint constraint.
  157. An inverted joint constraint only constraints the CCDIK joint to the angles *outside of* the inputted minimum and maximum angles. For this reason, it is referred to as an inverted joint constraint, as it constraints the joint to the outside of the inputted values.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_max:
  161. .. rst-class:: classref-method
  162. void **set_ccdik_joint_constraint_angle_max** **(** :ref:`int<class_int>` joint_idx, :ref:`float<class_float>` angle_max **)**
  163. Sets the maximum angle constraint for the joint at ``joint_idx``.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_constraint_angle_min:
  167. .. rst-class:: classref-method
  168. void **set_ccdik_joint_constraint_angle_min** **(** :ref:`int<class_int>` joint_idx, :ref:`float<class_float>` angle_min **)**
  169. Sets the minimum angle constraint for the joint at ``joint_idx``.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_enable_constraint:
  173. .. rst-class:: classref-method
  174. void **set_ccdik_joint_enable_constraint** **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` enable_constraint **)**
  175. Determines whether angle constraints on the CCDIK joint at ``joint_idx`` are enabled. When ``true``, constraints will be enabled and taken into account when solving.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_SkeletonModification2DCCDIK_method_set_ccdik_joint_rotate_from_joint:
  179. .. rst-class:: classref-method
  180. void **set_ccdik_joint_rotate_from_joint** **(** :ref:`int<class_int>` joint_idx, :ref:`bool<class_bool>` rotate_from_joint **)**
  181. Sets whether the joint at ``joint_idx`` is set to rotate from the joint, ``true``, or to rotate from the tip, ``false``.
  182. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  183. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  184. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  185. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  186. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  187. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  188. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`