SpringBoneSimulator3D
Inherits:SkeletonModifier3D<Node3D<Node<Object
ASkeletonModifier3D to apply inertial wavering to bone chains.
Description
ThisSkeletonModifier3D can be used to wiggle hair, cloth, and tails. This modifier behaves differently fromPhysicalBoneSimulator3D as it attempts to return the original pose after modification.
If you setupset_root_bone() andset_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 asset_joint_stiffness(),set_joint_drag(), andset_joint_gravity().
For simplicity, you can set values to all joints at the same time by using aCurve. If you want to specify detailed values individually, setset_individual_config() totrue
.
For physical simulation,SpringBoneSimulator3D can have children as self-standing collisions that are not related toPhysicsServer3D, see alsoSpringBoneCollision3D.
Warning: A scaledSpringBoneSimulator3D will likely not behave as expected. Make sure that the parentSkeleton3D and its bones are not scaled.
Properties
|
Methods
Enumerations
enumBoneDirection:🔗
BoneDirectionBONE_DIRECTION_PLUS_X =0
Enumerated value for the +X axis.
BoneDirectionBONE_DIRECTION_MINUS_X =1
Enumerated value for the -X axis.
BoneDirectionBONE_DIRECTION_PLUS_Y =2
Enumerated value for the +Y axis.
BoneDirectionBONE_DIRECTION_MINUS_Y =3
Enumerated value for the -Y axis.
BoneDirectionBONE_DIRECTION_PLUS_Z =4
Enumerated value for the +Z axis.
BoneDirectionBONE_DIRECTION_MINUS_Z =5
Enumerated value for the -Z axis.
BoneDirectionBONE_DIRECTION_FROM_PARENT =6
Enumerated value for the axis from a parent bone to the child bone.
enumCenterFrom:🔗
CenterFromCENTER_FROM_WORLD_ORIGIN =0
The world origin is defined as center.
CenterFromCENTER_FROM_NODE =1
TheNode3D specified byset_center_node() is defined as center.
IfNode3D is not found, the parentSkeleton3D is treated as center.
CenterFromCENTER_FROM_BONE =2
The bone pose origin of the parentSkeleton3D specified byset_center_bone() is defined as center.
IfNode3D is not found, the parentSkeleton3D is treated as center.
enumRotationAxis:🔗
RotationAxisROTATION_AXIS_X =0
Enumerated value for the rotation of the X axis.
RotationAxisROTATION_AXIS_Y =1
Enumerated value for the rotation of the Y axis.
RotationAxisROTATION_AXIS_Z =2
Enumerated value for the rotation of the Z axis.
RotationAxisROTATION_AXIS_ALL =3
Enumerated value for the unconstrained rotation.
Property Descriptions
intget_setting_count()
The number of settings.
Method Descriptions
boolare_all_child_collisions_enabled(index:int)const🔗
Returnstrue
if the all childSpringBoneCollision3Ds are contained in the collision list atindex
in the settings.
voidclear_collisions(index:int)🔗
Clears all collisions from the collision list atindex
in the settings whenare_all_child_collisions_enabled() isfalse
.
voidclear_exclude_collisions(index:int)🔗
Clears all exclude collisions from the collision list atindex
in the settings whenare_all_child_collisions_enabled() istrue
.
Clears all settings.
intget_center_bone(index:int)const🔗
Returns the center bone index of the bone chain.
Stringget_center_bone_name(index:int)const🔗
Returns the center bone name of the bone chain.
CenterFromget_center_from(index:int)const🔗
Returns what the center originates from in the bone chain.
NodePathget_center_node(index:int)const🔗
Returns the center node path of the bone chain.
intget_collision_count(index:int)const🔗
Returns the collision count of the bone chain's collision list whenare_all_child_collisions_enabled() isfalse
.
NodePathget_collision_path(index:int, collision:int)const🔗
Returns the node path of theSpringBoneCollision3D atcollision
in the bone chain's collision list whenare_all_child_collisions_enabled() isfalse
.
floatget_drag(index:int)const🔗
Returns the drag force damping curve of the bone chain.
Curveget_drag_damping_curve(index:int)const🔗
Returns the drag force damping curve of the bone chain.
intget_end_bone(index:int)const🔗
Returns the end bone index of the bone chain.
BoneDirectionget_end_bone_direction(index:int)const🔗
Returns the end bone's tail direction of the bone chain whenis_end_bone_extended() istrue
.
floatget_end_bone_length(index:int)const🔗
Returns the end bone's tail length of the bone chain whenis_end_bone_extended() istrue
.
Stringget_end_bone_name(index:int)const🔗
Returns the end bone name of the bone chain.
intget_exclude_collision_count(index:int)const🔗
Returns the exclude collision count of the bone chain's exclude collision list whenare_all_child_collisions_enabled() istrue
.
NodePathget_exclude_collision_path(index:int, collision:int)const🔗
Returns the node path of theSpringBoneCollision3D atcollision
in the bone chain's exclude collision list whenare_all_child_collisions_enabled() istrue
.
floatget_gravity(index:int)const🔗
Returns the gravity amount of the bone chain.
Curveget_gravity_damping_curve(index:int)const🔗
Returns the gravity amount damping curve of the bone chain.
Vector3get_gravity_direction(index:int)const🔗
Returns the gravity direction of the bone chain.
intget_joint_bone(index:int, joint:int)const🔗
Returns the bone index atjoint
in the bone chain's joint list.
Stringget_joint_bone_name(index:int, joint:int)const🔗
Returns the bone name atjoint
in the bone chain's joint list.
intget_joint_count(index:int)const🔗
Returns the joint count of the bone chain's joint list.
floatget_joint_drag(index:int, joint:int)const🔗
Returns the drag force atjoint
in the bone chain's joint list.
floatget_joint_gravity(index:int, joint:int)const🔗
Returns the gravity amount atjoint
in the bone chain's joint list.
Vector3get_joint_gravity_direction(index:int, joint:int)const🔗
Returns the gravity direction atjoint
in the bone chain's joint list.
floatget_joint_radius(index:int, joint:int)const🔗
Returns the radius atjoint
in the bone chain's joint list.
RotationAxisget_joint_rotation_axis(index:int, joint:int)const🔗
Returns the rotation axis atjoint
in the bone chain's joint list.
floatget_joint_stiffness(index:int, joint:int)const🔗
Returns the stiffness force atjoint
in the bone chain's joint list.
floatget_radius(index:int)const🔗
Returns the joint radius of the bone chain.
Curveget_radius_damping_curve(index:int)const🔗
Returns the joint radius damping curve of the bone chain.
intget_root_bone(index:int)const🔗
Returns the root bone index of the bone chain.
Stringget_root_bone_name(index:int)const🔗
Returns the root bone name of the bone chain.
RotationAxisget_rotation_axis(index:int)const🔗
Returns the rotation axis of the bone chain.
floatget_stiffness(index:int)const🔗
Returns the stiffness force of the bone chain.
Curveget_stiffness_damping_curve(index:int)const🔗
Returns the stiffness force damping curve of the bone chain.
boolis_config_individual(index:int)const🔗
Returnstrue
if the config can be edited individually for each joint.
boolis_end_bone_extended(index:int)const🔗
Returnstrue
if the end bone is extended to have the tail.
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 toAnimationPlayer.play() without a fading, or within the previousSkeletonModifier3D.modification_processed signal if it's condition changes significantly.
voidset_center_bone(index:int, bone:int)🔗
Sets the center bone index of the bone chain.
voidset_center_bone_name(index:int, bone_name:String)🔗
Sets the center bone name of the bone chain.
voidset_center_from(index:int, center_from:CenterFrom)🔗
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 parentSkeleton3D is used as the center, the bones are considered to have not moved if theSkeleton3D moves in the world.
In this case, only a change in the bone pose is considered to be a bone movement.
voidset_center_node(index:int, node_path:NodePath)🔗
Sets the center node path of the bone chain.
voidset_collision_count(index:int, count:int)🔗
Sets the number of collisions in the collision list atindex
in the settings whenare_all_child_collisions_enabled() isfalse
.
voidset_collision_path(index:int, collision:int, node_path:NodePath)🔗
Sets the node path of theSpringBoneCollision3D atcollision
in the bone chain's collision list whenare_all_child_collisions_enabled() isfalse
.
voidset_drag(index:int, drag:float)🔗
Sets the drag force of the bone chain. The greater the value, the more suppressed the wiggling.
The value is scaled byset_drag_damping_curve() and cached in each joint setting in the joint list.
voidset_drag_damping_curve(index:int, curve:Curve)🔗
Sets the drag force damping curve of the bone chain.
voidset_enable_all_child_collisions(index:int, enabled:bool)🔗
If setsenabled
totrue
, the all childSpringBoneCollision3Ds are collided andset_exclude_collision_path() is enabled as an exclusion list atindex
in the settings.
If setsenabled
tofalse
, you need to manually register all valid collisions withset_collision_path().
voidset_end_bone(index:int, bone:int)🔗
Sets the end bone index of the bone chain.
voidset_end_bone_direction(index:int, bone_direction:BoneDirection)🔗
Sets the end bone tail direction of the bone chain whenis_end_bone_extended() istrue
.
voidset_end_bone_length(index:int, length:float)🔗
Sets the end bone tail length of the bone chain whenis_end_bone_extended() istrue
.
voidset_end_bone_name(index:int, bone_name: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 byset_extend_end_bone() to jiggle the bone.
voidset_exclude_collision_count(index:int, count:int)🔗
Sets the number of exclude collisions in the exclude collision list atindex
in the settings whenare_all_child_collisions_enabled() istrue
.
voidset_exclude_collision_path(index:int, collision:int, node_path:NodePath)🔗
Sets the node path of theSpringBoneCollision3D atcollision
in the bone chain's exclude collision list whenare_all_child_collisions_enabled() istrue
.
voidset_extend_end_bone(index:int, enabled:bool)🔗
Ifenabled
istrue
, 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 setenabled
isfalse
, the config of last element in the joint list has no effect in the simulated result.
voidset_gravity(index:int, gravity:float)🔗
Sets the gravity amount of the bone chain. This value is not an acceleration, but a constant velocity of movement inset_gravity_direction().
Ifgravity
is not0
, the modified pose will not return to the original pose since it is always affected by gravity.
The value is scaled byset_gravity_damping_curve() and cached in each joint setting in the joint list.
voidset_gravity_damping_curve(index:int, curve:Curve)🔗
Sets the gravity amount damping curve of the bone chain.
voidset_gravity_direction(index:int, gravity_direction:Vector3)🔗
Sets the gravity direction of the bone chain. This value is internally normalized and then multiplied byset_gravity().
The value is cached in each joint setting in the joint list.
voidset_individual_config(index:int, enabled:bool)🔗
Ifenabled
istrue
, the config can be edited individually for each joint.
voidset_joint_drag(index:int, joint:int, drag:float)🔗
Sets the drag force atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_joint_gravity(index:int, joint:int, gravity:float)🔗
Sets the gravity amount atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_joint_gravity_direction(index:int, joint:int, gravity_direction:Vector3)🔗
Sets the gravity direction atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_joint_radius(index:int, joint:int, radius:float)🔗
Sets the joint radius atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_joint_rotation_axis(index:int, joint:int, axis:RotationAxis)🔗
Sets the rotation axis atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_joint_stiffness(index:int, joint:int, stiffness:float)🔗
Sets the stiffness force atjoint
in the bone chain's joint list whenis_config_individual() istrue
.
voidset_radius(index:int, radius:float)🔗
Sets the joint radius of the bone chain. It is used to move and slide with theSpringBoneCollision3D in the collision list.
The value is scaled byset_radius_damping_curve() and cached in each joint setting in the joint list.
voidset_radius_damping_curve(index:int, curve:Curve)🔗
Sets the joint radius damping curve of the bone chain.
voidset_root_bone(index:int, bone:int)🔗
Sets the root bone index of the bone chain.
voidset_root_bone_name(index:int, bone_name:String)🔗
Sets the root bone name of the bone chain.
voidset_rotation_axis(index:int, axis:RotationAxis)🔗
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 sinceSpringBoneSimulator3D does not factor in twisting forces.
voidset_stiffness(index:int, stiffness:float)🔗
Sets the stiffness force of the bone chain. The greater the value, the faster it recovers to its initial pose.
Ifstiffness
is0
, the modified pose will not return to the original pose.
The value is scaled byset_stiffness_damping_curve() and cached in each joint setting in the joint list.
voidset_stiffness_damping_curve(index:int, curve:Curve)🔗
Sets the stiffness force damping curve of the bone chain.