Class SpringBoneSimulator3D
A SkeletonModifier3D to apply inertial wavering to bone chains.
- Inheritance
-
SpringBoneSimulator3D
Remarks
This SkeletonModifier3D can be used to wiggle hair, cloth, and tails. This modifier behaves differently from PhysicalBoneSimulator3D as it attempts to return the original pose after modification.
If you setup SpringBoneSimulator3D.set_root_bone and SpringBoneSimulator3D.set_end_bone, it is treated as one bone chain. Note that it does not support a branched chain like Y-shaped chains.
When a bone chain is created, an array is generated from the bones that exist in between and listed in the joint list.
Several properties can be applied to each joint, such as SpringBoneSimulator3D.set_joint_stiffness, SpringBoneSimulator3D.set_joint_drag, and SpringBoneSimulator3D.set_joint_gravity.
For simplicity, you can set values to all joints at the same time by using a Curve. If you want to specify detailed values individually, set SpringBoneSimulator3D.set_individual_config to true
.
For physical simulation, SpringBoneSimulator3D can have children as self-standing collisions that are not related to PhysicsServer3D, see also SpringBoneCollision3D.
Warning: A scaled SpringBoneSimulator3D will likely not behave as expected. Make sure that the parent Skeleton3D and its bones are not scaled.
Properties
setting_count
The number of settings.
var setting_count : int = 0
Property Value
Remarks
Methods
are_all_child_collisions_enabled(int)
Qualifiers: const
Returns true
if the all child SpringBoneCollision3Ds are contained in the collision list at index
in the settings.
bool are_all_child_collisions_enabled(int index)
Parameters
index
int
clear_collisions(int)
Clears all collisions from the collision list at index
in the settings when SpringBoneSimulator3D.are_all_child_collisions_enabled is false
.
void clear_collisions(int index)
Parameters
index
int
clear_exclude_collisions(int)
Clears all exclude collisions from the collision list at index
in the settings when SpringBoneSimulator3D.are_all_child_collisions_enabled is true
.
void clear_exclude_collisions(int index)
Parameters
index
int
clear_settings
Clears all settings.
void clear_settings
get_center_bone(int)
Qualifiers: const
Returns the center bone index of the bone chain.
int get_center_bone(int index)
Parameters
index
int
get_center_bone_name(int)
Qualifiers: const
Returns the center bone name of the bone chain.
String get_center_bone_name(int index)
Parameters
index
int
get_center_from(int)
Qualifiers: const
Returns what the center originates from in the bone chain.
int get_center_from(int index)
Parameters
index
int
get_center_node(int)
Qualifiers: const
Returns the center node path of the bone chain.
NodePath get_center_node(int index)
Parameters
index
int
get_collision_count(int)
Qualifiers: const
Returns the collision count of the bone chain's collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is false
.
int get_collision_count(int index)
Parameters
index
int
get_collision_path(int, int)
Qualifiers: const
Returns the node path of the SpringBoneCollision3D at collision
in the bone chain's collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is false
.
NodePath get_collision_path(int index, int collision)
Parameters
get_drag(int)
Qualifiers: const
Returns the drag force damping curve of the bone chain.
float get_drag(int index)
Parameters
index
int
get_drag_damping_curve(int)
Qualifiers: const
Returns the drag force damping curve of the bone chain.
Curve get_drag_damping_curve(int index)
Parameters
index
int
get_end_bone(int)
Qualifiers: const
Returns the end bone index of the bone chain.
int get_end_bone(int index)
Parameters
index
int
get_end_bone_direction(int)
Qualifiers: const
Returns the end bone's tail direction of the bone chain when SpringBoneSimulator3D.is_end_bone_extended is true
.
int get_end_bone_direction(int index)
Parameters
index
int
get_end_bone_length(int)
Qualifiers: const
Returns the end bone's tail length of the bone chain when SpringBoneSimulator3D.is_end_bone_extended is true
.
float get_end_bone_length(int index)
Parameters
index
int
get_end_bone_name(int)
Qualifiers: const
Returns the end bone name of the bone chain.
String get_end_bone_name(int index)
Parameters
index
int
get_exclude_collision_count(int)
Qualifiers: const
Returns the exclude collision count of the bone chain's exclude collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is true
.
int get_exclude_collision_count(int index)
Parameters
index
int
get_exclude_collision_path(int, int)
Qualifiers: const
Returns the node path of the SpringBoneCollision3D at collision
in the bone chain's exclude collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is true
.
NodePath get_exclude_collision_path(int index, int collision)
Parameters
get_gravity(int)
Qualifiers: const
Returns the gravity amount of the bone chain.
float get_gravity(int index)
Parameters
index
int
get_gravity_damping_curve(int)
Qualifiers: const
Returns the gravity amount damping curve of the bone chain.
Curve get_gravity_damping_curve(int index)
Parameters
index
int
get_gravity_direction(int)
Qualifiers: const
Returns the gravity direction of the bone chain.
Vector3 get_gravity_direction(int index)
Parameters
index
int
get_joint_bone(int, int)
Qualifiers: const
Returns the bone index at joint
in the bone chain's joint list.
int get_joint_bone(int index, int joint)
Parameters
get_joint_bone_name(int, int)
Qualifiers: const
Returns the bone name at joint
in the bone chain's joint list.
String get_joint_bone_name(int index, int joint)
Parameters
get_joint_count(int)
Qualifiers: const
Returns the joint count of the bone chain's joint list.
int get_joint_count(int index)
Parameters
index
int
get_joint_drag(int, int)
Qualifiers: const
Returns the drag force at joint
in the bone chain's joint list.
float get_joint_drag(int index, int joint)
Parameters
get_joint_gravity(int, int)
Qualifiers: const
Returns the gravity amount at joint
in the bone chain's joint list.
float get_joint_gravity(int index, int joint)
Parameters
get_joint_gravity_direction(int, int)
Qualifiers: const
Returns the gravity direction at joint
in the bone chain's joint list.
Vector3 get_joint_gravity_direction(int index, int joint)
Parameters
get_joint_radius(int, int)
Qualifiers: const
Returns the radius at joint
in the bone chain's joint list.
float get_joint_radius(int index, int joint)
Parameters
get_joint_rotation_axis(int, int)
Qualifiers: const
Returns the rotation axis at joint
in the bone chain's joint list.
int get_joint_rotation_axis(int index, int joint)
Parameters
get_joint_stiffness(int, int)
Qualifiers: const
Returns the stiffness force at joint
in the bone chain's joint list.
float get_joint_stiffness(int index, int joint)
Parameters
get_radius(int)
Qualifiers: const
Returns the joint radius of the bone chain.
float get_radius(int index)
Parameters
index
int
get_radius_damping_curve(int)
Qualifiers: const
Returns the joint radius damping curve of the bone chain.
Curve get_radius_damping_curve(int index)
Parameters
index
int
get_root_bone(int)
Qualifiers: const
Returns the root bone index of the bone chain.
int get_root_bone(int index)
Parameters
index
int
get_root_bone_name(int)
Qualifiers: const
Returns the root bone name of the bone chain.
String get_root_bone_name(int index)
Parameters
index
int
get_rotation_axis(int)
Qualifiers: const
Returns the rotation axis of the bone chain.
int get_rotation_axis(int index)
Parameters
index
int
get_stiffness(int)
Qualifiers: const
Returns the stiffness force of the bone chain.
float get_stiffness(int index)
Parameters
index
int
get_stiffness_damping_curve(int)
Qualifiers: const
Returns the stiffness force damping curve of the bone chain.
Curve get_stiffness_damping_curve(int index)
Parameters
index
int
is_config_individual(int)
Qualifiers: const
Returns true
if the config can be edited individually for each joint.
bool is_config_individual(int index)
Parameters
index
int
is_end_bone_extended(int)
Qualifiers: const
Returns true
if the end bone is extended to have the tail.
bool is_end_bone_extended(int index)
Parameters
index
int
reset
Resets a simulating state with respect to the current bone pose.
It is useful to prevent the simulation result getting violent. For example, calling this immediately after a call to AnimationPlayer.play without a fading, or within the previous modification_processed signal if it's condition changes significantly.
void reset
set_center_bone(int, int)
Sets the center bone index of the bone chain.
void set_center_bone(int index, int bone)
Parameters
set_center_bone_name(int, String)
Sets the center bone name of the bone chain.
void set_center_bone_name(int index, String bone_name)
Parameters
set_center_from(int, int)
Sets what the center originates from in the bone chain.
Bone movement is calculated based on the difference in relative distance between center and bone in the previous and next frames.
For example, if the parent Skeleton3D is used as the center, the bones are considered to have not moved if the Skeleton3D moves in the world.
In this case, only a change in the bone pose is considered to be a bone movement.
void set_center_from(int index, int center_from)
Parameters
set_center_node(int, NodePath)
Sets the center node path of the bone chain.
void set_center_node(int index, NodePath node_path)
Parameters
set_collision_count(int, int)
Sets the number of collisions in the collision list at index
in the settings when SpringBoneSimulator3D.are_all_child_collisions_enabled is false
.
void set_collision_count(int index, int count)
Parameters
set_collision_path(int, int, NodePath)
Sets the node path of the SpringBoneCollision3D at collision
in the bone chain's collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is false
.
void set_collision_path(int index, int collision, NodePath node_path)
Parameters
set_drag(int, float)
Sets the drag force of the bone chain. The greater the value, the more suppressed the wiggling.
The value is scaled by SpringBoneSimulator3D.set_drag_damping_curve and cached in each joint setting in the joint list.
void set_drag(int index, float drag)
Parameters
set_drag_damping_curve(int, Curve)
Sets the drag force damping curve of the bone chain.
void set_drag_damping_curve(int index, Curve curve)
Parameters
set_enable_all_child_collisions(int, bool)
If sets enabled
to true
, the all child SpringBoneCollision3Ds are collided and SpringBoneSimulator3D.set_exclude_collision_path is enabled as an exclusion list at index
in the settings.
If sets enabled
to false
, you need to manually register all valid collisions with SpringBoneSimulator3D.set_collision_path.
void set_enable_all_child_collisions(int index, bool enabled)
Parameters
set_end_bone(int, int)
Sets the end bone index of the bone chain.
void set_end_bone(int index, int bone)
Parameters
set_end_bone_direction(int, int)
Sets the end bone tail direction of the bone chain when SpringBoneSimulator3D.is_end_bone_extended is true
.
void set_end_bone_direction(int index, int bone_direction)
Parameters
set_end_bone_length(int, float)
Sets the end bone tail length of the bone chain when SpringBoneSimulator3D.is_end_bone_extended is true
.
void set_end_bone_length(int index, float length)
Parameters
set_end_bone_name(int, String)
Sets the end bone name of the bone chain.
Note: End bone must be the root bone or a child of the root bone. If they are the same, the tail must be extended by SpringBoneSimulator3D.set_extend_end_bone to jiggle the bone.
void set_end_bone_name(int index, String bone_name)
Parameters
set_exclude_collision_count(int, int)
Sets the number of exclude collisions in the exclude collision list at index
in the settings when SpringBoneSimulator3D.are_all_child_collisions_enabled is true
.
void set_exclude_collision_count(int index, int count)
Parameters
set_exclude_collision_path(int, int, NodePath)
Sets the node path of the SpringBoneCollision3D at collision
in the bone chain's exclude collision list when SpringBoneSimulator3D.are_all_child_collisions_enabled is true
.
void set_exclude_collision_path(int index, int collision, NodePath node_path)
Parameters
set_extend_end_bone(int, bool)
If enabled
is true
, the end bone is extended to have the tail.
The extended tail config is allocated to the last element in the joint list.
In other words, if you set enabled
is false
, the config of last element in the joint list has no effect in the simulated result.
void set_extend_end_bone(int index, bool enabled)
Parameters
set_gravity(int, float)
Sets the gravity amount of the bone chain. This value is not an acceleration, but a constant velocity of movement in SpringBoneSimulator3D.set_gravity_direction.
If gravity
is not 0
, the modified pose will not return to the original pose since it is always affected by gravity.
The value is scaled by SpringBoneSimulator3D.set_gravity_damping_curve and cached in each joint setting in the joint list.
void set_gravity(int index, float gravity)
Parameters
set_gravity_damping_curve(int, Curve)
Sets the gravity amount damping curve of the bone chain.
void set_gravity_damping_curve(int index, Curve curve)
Parameters
set_gravity_direction(int, Vector3)
Sets the gravity direction of the bone chain. This value is internally normalized and then multiplied by SpringBoneSimulator3D.set_gravity.
The value is cached in each joint setting in the joint list.
void set_gravity_direction(int index, Vector3 gravity_direction)
Parameters
set_individual_config(int, bool)
If enabled
is true
, the config can be edited individually for each joint.
void set_individual_config(int index, bool enabled)
Parameters
set_joint_drag(int, int, float)
Sets the drag force at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_drag(int index, int joint, float drag)
Parameters
set_joint_gravity(int, int, float)
Sets the gravity amount at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_gravity(int index, int joint, float gravity)
Parameters
set_joint_gravity_direction(int, int, Vector3)
Sets the gravity direction at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_gravity_direction(int index, int joint, Vector3 gravity_direction)
Parameters
set_joint_radius(int, int, float)
Sets the joint radius at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_radius(int index, int joint, float radius)
Parameters
set_joint_rotation_axis(int, int, int)
Sets the rotation axis at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_rotation_axis(int index, int joint, int axis)
Parameters
set_joint_stiffness(int, int, float)
Sets the stiffness force at joint
in the bone chain's joint list when SpringBoneSimulator3D.is_config_individual is true
.
void set_joint_stiffness(int index, int joint, float stiffness)
Parameters
set_radius(int, float)
Sets the joint radius of the bone chain. It is used to move and slide with the SpringBoneCollision3D in the collision list.
The value is scaled by SpringBoneSimulator3D.set_radius_damping_curve and cached in each joint setting in the joint list.
void set_radius(int index, float radius)
Parameters
set_radius_damping_curve(int, Curve)
Sets the joint radius damping curve of the bone chain.
void set_radius_damping_curve(int index, Curve curve)
Parameters
set_root_bone(int, int)
Sets the root bone index of the bone chain.
void set_root_bone(int index, int bone)
Parameters
set_root_bone_name(int, String)
Sets the root bone name of the bone chain.
void set_root_bone_name(int index, String bone_name)
Parameters
set_rotation_axis(int, int)
Sets the rotation axis of the bone chain. If sets a specific axis, it acts like a hinge joint.
The value is cached in each joint setting in the joint list.
Note: The rotation axis and the forward vector shouldn't be colinear to avoid unintended rotation since SpringBoneSimulator3D does not factor in twisting forces.
void set_rotation_axis(int index, int axis)
Parameters
set_stiffness(int, float)
Sets the stiffness force of the bone chain. The greater the value, the faster it recovers to its initial pose.
If stiffness
is 0
, the modified pose will not return to the original pose.
The value is scaled by SpringBoneSimulator3D.set_stiffness_damping_curve and cached in each joint setting in the joint list.
void set_stiffness(int index, float stiffness)
Parameters
set_stiffness_damping_curve(int, Curve)
Sets the stiffness force damping curve of the bone chain.
void set_stiffness_damping_curve(int index, Curve curve)