Skeleton3D

Inherits: Node3D < Node < Object

Skeleton for characters and animated objects.

Description

Skeleton3D provides a hierarchical interface for managing bones, including pose, rest and animation (see Animation). It can also use ragdoll physics.

The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose.

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.

Tutorials

Properties

bool

animate_physical_bones

true

float

motion_scale

1.0

bool

show_rest_only

false

Methods

void

add_bone ( String name )

void

clear_bones ( )

void

clear_bones_global_pose_override ( )

void

clear_bones_local_pose_override ( )

Skin

create_skin_from_rest_transforms ( )

void

execute_modifications ( float delta, int execution_mode )

int

find_bone ( String name ) const

void

force_update_all_bone_transforms ( )

void

force_update_bone_child_transform ( int bone_idx )

PackedInt32Array

get_bone_children ( int bone_idx ) const

int

get_bone_count ( ) const

Transform3D

get_bone_global_pose ( int bone_idx ) const

Transform3D

get_bone_global_pose_no_override ( int bone_idx ) const

Transform3D

get_bone_global_pose_override ( int bone_idx ) const

Transform3D

get_bone_global_rest ( int bone_idx ) const

Transform3D

get_bone_local_pose_override ( int bone_idx ) const

String

get_bone_name ( int bone_idx ) const

int

get_bone_parent ( int bone_idx ) const

Transform3D

get_bone_pose ( int bone_idx ) const

Vector3

get_bone_pose_position ( int bone_idx ) const

Quaternion

get_bone_pose_rotation ( int bone_idx ) const

Vector3

get_bone_pose_scale ( int bone_idx ) const

Transform3D

get_bone_rest ( int bone_idx ) const

SkeletonModificationStack3D

get_modification_stack ( )

PackedInt32Array

get_parentless_bones ( ) const

Transform3D

global_pose_to_local_pose ( int bone_idx, Transform3D global_pose )

Transform3D

global_pose_to_world_transform ( Transform3D global_pose )

Basis

global_pose_z_forward_to_bone_forward ( int bone_idx, Basis basis )

bool

is_bone_enabled ( int bone_idx ) const

Transform3D

local_pose_to_global_pose ( int bone_idx, Transform3D local_pose )

void

localize_rests ( )

void

physical_bones_add_collision_exception ( RID exception )

void

physical_bones_remove_collision_exception ( RID exception )

void

physical_bones_start_simulation ( StringName[] bones=[] )

void

physical_bones_stop_simulation ( )

SkinReference

register_skin ( Skin skin )

void

reset_bone_pose ( int bone_idx )

void

reset_bone_poses ( )

void

set_bone_enabled ( int bone_idx, bool enabled=true )

void

set_bone_global_pose_override ( int bone_idx, Transform3D pose, float amount, bool persistent=false )

void

set_bone_local_pose_override ( int bone_idx, Transform3D pose, float amount, bool persistent=false )

void

set_bone_name ( int bone_idx, String name )

void

set_bone_parent ( int bone_idx, int parent_idx )

void

set_bone_pose_position ( int bone_idx, Vector3 position )

void

set_bone_pose_rotation ( int bone_idx, Quaternion rotation )

void

set_bone_pose_scale ( int bone_idx, Vector3 scale )

void

set_bone_rest ( int bone_idx, Transform3D rest )

void

set_modification_stack ( SkeletonModificationStack3D modification_stack )

void

unparent_bone_and_rest ( int bone_idx )

Transform3D

world_transform_to_global_pose ( Transform3D world_transform )

Signals

  • bone_enabled_changed ( int bone_idx )


  • bone_pose_changed ( int bone_idx )

This signal is emitted when one of the bones in the Skeleton3D node have changed their pose. This is used to inform nodes that rely on bone positions that one of the bones in the Skeleton3D have changed their transform/pose.


  • pose_updated ( )


  • show_rest_only_changed ( )

Constants

  • NOTIFICATION_UPDATE_SKELETON = 50

Property Descriptions

  • bool animate_physical_bones

Default

true

Setter

set_animate_physical_bones(value)

Getter

get_animate_physical_bones()


Default

1.0

Setter

set_motion_scale(value)

Getter

get_motion_scale()

Multiplies the position 3D track animation.

Note: Unless this value is 1.0, the key value in animation will not match the actual position value.


  • bool show_rest_only

Default

false

Setter

set_show_rest_only(value)

Getter

is_show_rest_only()

Method Descriptions

  • void add_bone ( String name )

Adds a bone, with name name. get_bone_count will become the bone index.


  • void clear_bones ( )

Clear all the bones in this skeleton.


  • void clear_bones_global_pose_override ( )

Removes the global pose override on all bones in the skeleton.


  • void clear_bones_local_pose_override ( )

Deprecated. Local pose overrides will be removed.

Removes the local pose override on all bones in the skeleton.


  • Skin create_skin_from_rest_transforms ( )


  • void execute_modifications ( float delta, int execution_mode )

Executes all the modifications on the SkeletonModificationStack3D, if the Skeleton3D has one assigned.


Returns the bone index that matches name as its name.


  • void force_update_all_bone_transforms ( )

Force updates the bone transforms/poses for all bones in the skeleton.


  • void force_update_bone_child_transform ( int bone_idx )

Force updates the bone transform for the bone at bone_idx and all of its children.


Returns an array containing the bone indexes of all the children node of the passed in bone, bone_idx.


  • int get_bone_count ( ) const

Returns the number of bones in the skeleton.


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.


Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.


Returns the global pose override transform for bone_idx.


Returns the global rest transform for bone_idx.


Returns the local pose override transform for bone_idx.


  • String get_bone_name ( int bone_idx ) const

Returns the name of the bone at index bone_idx.


  • int get_bone_parent ( int bone_idx ) const

Returns the bone index which is the parent of the bone at bone_idx. If -1, then bone has no parent.

Note: The parent bone returned will always be less than bone_idx.


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.


  • Vector3 get_bone_pose_position ( int bone_idx ) const



  • Vector3 get_bone_pose_scale ( int bone_idx ) const


Returns the rest transform for a bone bone_idx.


Returns the modification stack attached to this skeleton, if one exists.


Returns an array with all of the bones that are parentless. Another way to look at this is that it returns the indexes of all the bones that are not dependent or modified by other bones in the Skeleton.


Takes the passed-in global pose and converts it to local pose transform.

This can be used to easily convert a global pose from get_bone_global_pose to a global transform in set_bone_local_pose_override.


Deprecated. Use Node3D apis instead.

Takes the passed-in global pose and converts it to a world transform.

This can be used to easily convert a global pose from get_bone_global_pose to a global transform usable with a node's transform, like Node3D.global_transform for example.


  • Basis global_pose_z_forward_to_bone_forward ( int bone_idx, Basis basis )

Rotates the given Basis so that the forward axis of the Basis is facing in the forward direction of the bone at bone_idx.

This is helper function to make using Transform3D.looking_at easier with bone poses.


  • bool is_bone_enabled ( int bone_idx ) const

Returns whether the bone pose for the bone at bone_idx is enabled.


Converts the passed-in local pose to a global pose relative to the inputted bone, bone_idx.

This could be used to convert get_bone_pose for use with the set_bone_global_pose_override function.


  • void localize_rests ( )

Returns all bones in the skeleton to their rest poses.


  • void physical_bones_add_collision_exception ( RID exception )

Adds a collision exception to the physical bone.

Works just like the RigidBody3D node.


  • void physical_bones_remove_collision_exception ( RID exception )

Removes a collision exception to the physical bone.

Works just like the RigidBody3D node.


  • void physical_bones_start_simulation ( StringName[] bones=[] )

Tells the PhysicalBone3D nodes in the Skeleton to start simulating and reacting to the physics world.

Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated.


  • void physical_bones_stop_simulation ( )

Tells the PhysicalBone3D nodes in the Skeleton to stop simulating.


Binds the given Skin to the Skeleton.


  • void reset_bone_pose ( int bone_idx )

Sets the bone pose to rest for bone_idx.


  • void reset_bone_poses ( )

Sets all bone poses to rests.


  • void set_bone_enabled ( int bone_idx, bool enabled=true )

Disables the pose for the bone at bone_idx if false, enables the bone pose if true.


Sets the global pose transform, pose, for the bone at bone_idx.

amount is the interpolation strength that will be used when applying the pose, and persistent determines if the applied pose will remain.

Note: The pose transform needs to be a global pose! To convert a world transform from a Node3D to a global bone pose, multiply the Transform3D.affine_inverse of the node's Node3D.global_transform by the desired world transform


Deprecated. Local pose overrides will be removed.

Sets the local pose transform, pose, for the bone at bone_idx.

amount is the interpolation strength that will be used when applying the pose, and persistent determines if the applied pose will remain.

Note: The pose transform needs to be a local pose! Use global_pose_to_local_pose to convert a global pose to a local pose.


  • void set_bone_name ( int bone_idx, String name )


  • void set_bone_parent ( int bone_idx, int parent_idx )

Sets the bone index parent_idx as the parent of the bone at bone_idx. If -1, then bone has no parent.

Note: parent_idx must be less than bone_idx.


  • void set_bone_pose_position ( int bone_idx, Vector3 position )


  • void set_bone_pose_rotation ( int bone_idx, Quaternion rotation )


  • void set_bone_pose_scale ( int bone_idx, Vector3 scale )


Sets the rest transform for bone bone_idx.


Sets the modification stack for this skeleton to the passed-in modification stack, modification_stack.


  • void unparent_bone_and_rest ( int bone_idx )

Unparents the bone at bone_idx and sets its rest position to that of its parent prior to being reset.


Deprecated. Use Node3D apis instead.

Takes the passed-in global transform and converts it to a global pose.

This can be used to easily convert a global transform from Node3D.global_transform to a global pose usable with set_bone_global_pose_override, for example.