class_skeleton.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Skeleton.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Skeleton:
  6. Skeleton
  7. ========
  8. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Skeleton for characters and animated objects.
  13. Methods
  14. -------
  15. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_bone<class_Skeleton_method_add_bone>` **(** :ref:`String<class_String>` name **)** |
  17. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`bind_child_node_to_bone<class_Skeleton_method_bind_child_node_to_bone>` **(** :ref:`int<class_int>` bone_idx, :ref:`Node<class_Node>` node **)** |
  19. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`clear_bones<class_Skeleton_method_clear_bones>` **(** **)** |
  21. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`find_bone<class_Skeleton_method_find_bone>` **(** :ref:`String<class_String>` name **)** const |
  23. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`get_bone_count<class_Skeleton_method_get_bone_count>` **(** **)** const |
  25. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Transform<class_Transform>` | :ref:`get_bone_global_pose<class_Skeleton_method_get_bone_global_pose>` **(** :ref:`int<class_int>` bone_idx **)** const |
  27. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`get_bone_name<class_Skeleton_method_get_bone_name>` **(** :ref:`int<class_int>` bone_idx **)** const |
  29. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`get_bone_parent<class_Skeleton_method_get_bone_parent>` **(** :ref:`int<class_int>` bone_idx **)** const |
  31. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Transform<class_Transform>` | :ref:`get_bone_pose<class_Skeleton_method_get_bone_pose>` **(** :ref:`int<class_int>` bone_idx **)** const |
  33. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Transform<class_Transform>` | :ref:`get_bone_rest<class_Skeleton_method_get_bone_rest>` **(** :ref:`int<class_int>` bone_idx **)** const |
  35. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Array<class_Array>` | :ref:`get_bound_child_nodes_to_bone<class_Skeleton_method_get_bound_child_nodes_to_bone>` **(** :ref:`int<class_int>` bone_idx **)** const |
  37. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_bone_rest_disabled<class_Skeleton_method_is_bone_rest_disabled>` **(** :ref:`int<class_int>` bone_idx **)** const |
  39. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`localize_rests<class_Skeleton_method_localize_rests>` **(** **)** |
  41. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`physical_bones_add_collision_exception<class_Skeleton_method_physical_bones_add_collision_exception>` **(** :ref:`RID<class_RID>` exception **)** |
  43. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`physical_bones_remove_collision_exception<class_Skeleton_method_physical_bones_remove_collision_exception>` **(** :ref:`RID<class_RID>` exception **)** |
  45. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`physical_bones_start_simulation<class_Skeleton_method_physical_bones_start_simulation>` **(** :ref:`Array<class_Array>` bones=[ ] **)** |
  47. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`physical_bones_stop_simulation<class_Skeleton_method_physical_bones_stop_simulation>` **(** **)** |
  49. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`SkinReference<class_SkinReference>` | :ref:`register_skin<class_Skeleton_method_register_skin>` **(** :ref:`Skin<class_Skin>` skin **)** |
  51. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_bone_disable_rest<class_Skeleton_method_set_bone_disable_rest>` **(** :ref:`int<class_int>` bone_idx, :ref:`bool<class_bool>` disable **)** |
  53. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_bone_global_pose_override<class_Skeleton_method_set_bone_global_pose_override>` **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` pose, :ref:`float<class_float>` amount, :ref:`bool<class_bool>` persistent=false **)** |
  55. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_bone_parent<class_Skeleton_method_set_bone_parent>` **(** :ref:`int<class_int>` bone_idx, :ref:`int<class_int>` parent_idx **)** |
  57. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_bone_pose<class_Skeleton_method_set_bone_pose>` **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` pose **)** |
  59. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_bone_rest<class_Skeleton_method_set_bone_rest>` **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` rest **)** |
  61. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`unbind_child_node_from_bone<class_Skeleton_method_unbind_child_node_from_bone>` **(** :ref:`int<class_int>` bone_idx, :ref:`Node<class_Node>` node **)** |
  63. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`unparent_bone_and_rest<class_Skeleton_method_unparent_bone_and_rest>` **(** :ref:`int<class_int>` bone_idx **)** |
  65. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. Constants
  67. ---------
  68. .. _class_Skeleton_constant_NOTIFICATION_UPDATE_SKELETON:
  69. - **NOTIFICATION_UPDATE_SKELETON** = **50**
  70. Description
  71. -----------
  72. Skeleton provides a hierarchical interface for managing bones, including pose, rest and animation (see :ref:`Animation<class_Animation>`). It can also use ragdoll physics.
  73. The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose.
  74. Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it not the actual global/world transform of the bone.
  75. Method Descriptions
  76. -------------------
  77. .. _class_Skeleton_method_add_bone:
  78. - void **add_bone** **(** :ref:`String<class_String>` name **)**
  79. Adds a bone, with name ``name``. :ref:`get_bone_count<class_Skeleton_method_get_bone_count>` will become the bone index.
  80. .. _class_Skeleton_method_bind_child_node_to_bone:
  81. - void **bind_child_node_to_bone** **(** :ref:`int<class_int>` bone_idx, :ref:`Node<class_Node>` node **)**
  82. *Deprecated soon.*
  83. .. _class_Skeleton_method_clear_bones:
  84. - void **clear_bones** **(** **)**
  85. Clear all the bones in this skeleton.
  86. .. _class_Skeleton_method_find_bone:
  87. - :ref:`int<class_int>` **find_bone** **(** :ref:`String<class_String>` name **)** const
  88. Returns the bone index that matches ``name`` as its name.
  89. .. _class_Skeleton_method_get_bone_count:
  90. - :ref:`int<class_int>` **get_bone_count** **(** **)** const
  91. Returns the amount of bones in the skeleton.
  92. .. _class_Skeleton_method_get_bone_global_pose:
  93. - :ref:`Transform<class_Transform>` **get_bone_global_pose** **(** :ref:`int<class_int>` bone_idx **)** const
  94. Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
  95. .. _class_Skeleton_method_get_bone_name:
  96. - :ref:`String<class_String>` **get_bone_name** **(** :ref:`int<class_int>` bone_idx **)** const
  97. Returns the name of the bone at index ``index``.
  98. .. _class_Skeleton_method_get_bone_parent:
  99. - :ref:`int<class_int>` **get_bone_parent** **(** :ref:`int<class_int>` bone_idx **)** const
  100. Returns the bone index which is the parent of the bone at ``bone_idx``. If -1, then bone has no parent.
  101. **Note:** The parent bone returned will always be less than ``bone_idx``.
  102. .. _class_Skeleton_method_get_bone_pose:
  103. - :ref:`Transform<class_Transform>` **get_bone_pose** **(** :ref:`int<class_int>` bone_idx **)** const
  104. Returns the pose transform of the specified bone. Pose is applied on top of the custom pose, which is applied on top the rest pose.
  105. .. _class_Skeleton_method_get_bone_rest:
  106. - :ref:`Transform<class_Transform>` **get_bone_rest** **(** :ref:`int<class_int>` bone_idx **)** const
  107. Returns the rest transform for a bone ``bone_idx``.
  108. .. _class_Skeleton_method_get_bound_child_nodes_to_bone:
  109. - :ref:`Array<class_Array>` **get_bound_child_nodes_to_bone** **(** :ref:`int<class_int>` bone_idx **)** const
  110. *Deprecated soon.*
  111. .. _class_Skeleton_method_is_bone_rest_disabled:
  112. - :ref:`bool<class_bool>` **is_bone_rest_disabled** **(** :ref:`int<class_int>` bone_idx **)** const
  113. .. _class_Skeleton_method_localize_rests:
  114. - void **localize_rests** **(** **)**
  115. .. _class_Skeleton_method_physical_bones_add_collision_exception:
  116. - void **physical_bones_add_collision_exception** **(** :ref:`RID<class_RID>` exception **)**
  117. .. _class_Skeleton_method_physical_bones_remove_collision_exception:
  118. - void **physical_bones_remove_collision_exception** **(** :ref:`RID<class_RID>` exception **)**
  119. .. _class_Skeleton_method_physical_bones_start_simulation:
  120. - void **physical_bones_start_simulation** **(** :ref:`Array<class_Array>` bones=[ ] **)**
  121. .. _class_Skeleton_method_physical_bones_stop_simulation:
  122. - void **physical_bones_stop_simulation** **(** **)**
  123. .. _class_Skeleton_method_register_skin:
  124. - :ref:`SkinReference<class_SkinReference>` **register_skin** **(** :ref:`Skin<class_Skin>` skin **)**
  125. .. _class_Skeleton_method_set_bone_disable_rest:
  126. - void **set_bone_disable_rest** **(** :ref:`int<class_int>` bone_idx, :ref:`bool<class_bool>` disable **)**
  127. .. _class_Skeleton_method_set_bone_global_pose_override:
  128. - void **set_bone_global_pose_override** **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` pose, :ref:`float<class_float>` amount, :ref:`bool<class_bool>` persistent=false **)**
  129. .. _class_Skeleton_method_set_bone_parent:
  130. - void **set_bone_parent** **(** :ref:`int<class_int>` bone_idx, :ref:`int<class_int>` parent_idx **)**
  131. Sets the bone index ``parent_idx`` as the parent of the bone at ``bone_idx``. If -1, then bone has no parent.
  132. **Note:** ``parent_idx`` must be less than ``bone_idx``.
  133. .. _class_Skeleton_method_set_bone_pose:
  134. - void **set_bone_pose** **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` pose **)**
  135. Returns the pose transform for bone ``bone_idx``.
  136. .. _class_Skeleton_method_set_bone_rest:
  137. - void **set_bone_rest** **(** :ref:`int<class_int>` bone_idx, :ref:`Transform<class_Transform>` rest **)**
  138. Sets the rest transform for bone ``bone_idx``.
  139. .. _class_Skeleton_method_unbind_child_node_from_bone:
  140. - void **unbind_child_node_from_bone** **(** :ref:`int<class_int>` bone_idx, :ref:`Node<class_Node>` node **)**
  141. *Deprecated soon.*
  142. .. _class_Skeleton_method_unparent_bone_and_rest:
  143. - void **unparent_bone_and_rest** **(** :ref:`int<class_int>` bone_idx **)**