SpringBoneSimulator3D

package
v0.0.0-...-ff35923 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

This graphics.gd/classdb/SkeletonModifier3D can be used to wiggle hair, cloth, and tails. This modifier behaves differently from graphics.gd/classdb/PhysicalBoneSimulator3D as it attempts to return the original pose after modification.

If you setup Instance.SetRootBone and Instance.SetEndBone, 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 Instance.SetJointStiffness, Instance.SetJointDrag, and Instance.SetJointGravity.

For simplicity, you can set values to all joints at the same time by using a graphics.gd/classdb/Curve. If you want to specify detailed values individually, set Instance.SetIndividualConfig to true.

For physical simulation, graphics.gd/classdb/SpringBoneSimulator3D can have children as self-standing collisions that are not related to graphics.gd/classdb/PhysicsServer3D, see also graphics.gd/classdb/SpringBoneCollision3D.

Warning: A scaled graphics.gd/classdb/SpringBoneSimulator3D will likely not behave as expected. Make sure that the parent graphics.gd/classdb/Skeleton3D and its bones are not scaled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsSpringBoneSimulator3D() Instance
}

type BoneDirection

type BoneDirection int //gd:SpringBoneSimulator3D.BoneDirection
const (
	// Enumerated value for the +X axis.
	BoneDirectionPlusX BoneDirection = 0
	// Enumerated value for the -X axis.
	BoneDirectionMinusX BoneDirection = 1
	// Enumerated value for the +Y axis.
	BoneDirectionPlusY BoneDirection = 2
	// Enumerated value for the -Y axis.
	BoneDirectionMinusY BoneDirection = 3
	// Enumerated value for the +Z axis.
	BoneDirectionPlusZ BoneDirection = 4
	// Enumerated value for the -Z axis.
	BoneDirectionMinusZ BoneDirection = 5
	// Enumerated value for the axis from a parent bone to the child bone.
	BoneDirectionFromParent BoneDirection = 6
)

type CenterFrom

type CenterFrom int //gd:SpringBoneSimulator3D.CenterFrom
const (
	// The world origin is defined as center.
	CenterFromWorldOrigin CenterFrom = 0
	// The [graphics.gd/classdb/Node3D] specified by [Instance.SetCenterNode] is defined as center.
	//
	// If [graphics.gd/classdb/Node3D] is not found, the parent [graphics.gd/classdb/Skeleton3D] is treated as center.
	CenterFromNode CenterFrom = 1
	// The bone pose origin of the parent [graphics.gd/classdb/Skeleton3D] specified by [Instance.SetCenterBone] is defined as center.
	//
	// If [graphics.gd/classdb/Node3D] is not found, the parent [graphics.gd/classdb/Skeleton3D] is treated as center.
	CenterFromBone CenterFrom = 2
)

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode3D

func (self *Extension[T]) AsNode3D() Node3D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsSkeletonModifier3D

func (self *Extension[T]) AsSkeletonModifier3D() SkeletonModifier3D.Instance

func (*Extension[T]) AsSpringBoneSimulator3D

func (self *Extension[T]) AsSpringBoneSimulator3D() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.SpringBoneSimulator3D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AreAllChildCollisionsEnabled

func (self Instance) AreAllChildCollisionsEnabled(index int) bool

Returns true if all child [graphics.gd/classdb/SpringBoneCollision3D]s are contained in the collision list at 'index' in the settings.

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Node3D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsSkeletonModifier3D

func (self Instance) AsSkeletonModifier3D() SkeletonModifier3D.Instance

func (Instance) AsSpringBoneSimulator3D

func (self Instance) AsSpringBoneSimulator3D() Instance

func (Instance) ClearCollisions

func (self Instance) ClearCollisions(index int)

Clears all collisions from the collision list at 'index' in the settings when Instance.AreAllChildCollisionsEnabled is false.

func (Instance) ClearExcludeCollisions

func (self Instance) ClearExcludeCollisions(index int)

Clears all exclude collisions from the collision list at 'index' in the settings when Instance.AreAllChildCollisionsEnabled is true.

func (Instance) ClearSettings

func (self Instance) ClearSettings()

Clears all settings.

func (Instance) ExternalForce

func (self Instance) ExternalForce() Vector3.XYZ

func (Instance) GetCenterBone

func (self Instance) GetCenterBone(index int) int

Returns the center bone index of the bone chain.

func (Instance) GetCenterBoneName

func (self Instance) GetCenterBoneName(index int) string

Returns the center bone name of the bone chain.

func (Instance) GetCenterFrom

func (self Instance) GetCenterFrom(index int) CenterFrom

Returns what the center originates from in the bone chain.

func (Instance) GetCenterNode

func (self Instance) GetCenterNode(index int) string

Returns the center node path of the bone chain.

func (Instance) GetCollisionCount

func (self Instance) GetCollisionCount(index int) int

Returns the collision count of the bone chain's collision list when Instance.AreAllChildCollisionsEnabled is false.

func (Instance) GetCollisionPath

func (self Instance) GetCollisionPath(index int, collision int) string

Returns the node path of the graphics.gd/classdb/SpringBoneCollision3D at 'collision' in the bone chain's collision list when Instance.AreAllChildCollisionsEnabled is false.

func (Instance) GetDrag

func (self Instance) GetDrag(index int) Float.X

Returns the drag force damping curve of the bone chain.

func (Instance) GetDragDampingCurve

func (self Instance) GetDragDampingCurve(index int) Curve.Instance

Returns the drag force damping curve of the bone chain.

func (Instance) GetEndBone

func (self Instance) GetEndBone(index int) int

Returns the end bone index of the bone chain.

func (Instance) GetEndBoneDirection

func (self Instance) GetEndBoneDirection(index int) BoneDirection

Returns the end bone's tail direction of the bone chain when Instance.IsEndBoneExtended is true.

func (Instance) GetEndBoneLength

func (self Instance) GetEndBoneLength(index int) Float.X

Returns the end bone's tail length of the bone chain when Instance.IsEndBoneExtended is true.

func (Instance) GetEndBoneName

func (self Instance) GetEndBoneName(index int) string

Returns the end bone name of the bone chain.

func (Instance) GetExcludeCollisionCount

func (self Instance) GetExcludeCollisionCount(index int) int

Returns the exclude collision count of the bone chain's exclude collision list when Instance.AreAllChildCollisionsEnabled is true.

func (Instance) GetExcludeCollisionPath

func (self Instance) GetExcludeCollisionPath(index int, collision int) string

Returns the node path of the graphics.gd/classdb/SpringBoneCollision3D at 'collision' in the bone chain's exclude collision list when Instance.AreAllChildCollisionsEnabled is true.

func (Instance) GetGravity

func (self Instance) GetGravity(index int) Float.X

Returns the gravity amount of the bone chain.

func (Instance) GetGravityDampingCurve

func (self Instance) GetGravityDampingCurve(index int) Curve.Instance

Returns the gravity amount damping curve of the bone chain.

func (Instance) GetGravityDirection

func (self Instance) GetGravityDirection(index int) Vector3.XYZ

Returns the gravity direction of the bone chain.

func (Instance) GetJointBone

func (self Instance) GetJointBone(index int, joint int) int

Returns the bone index at 'joint' in the bone chain's joint list.

func (Instance) GetJointBoneName

func (self Instance) GetJointBoneName(index int, joint int) string

Returns the bone name at 'joint' in the bone chain's joint list.

func (Instance) GetJointCount

func (self Instance) GetJointCount(index int) int

Returns the joint count of the bone chain's joint list.

func (Instance) GetJointDrag

func (self Instance) GetJointDrag(index int, joint int) Float.X

Returns the drag force at 'joint' in the bone chain's joint list.

func (Instance) GetJointGravity

func (self Instance) GetJointGravity(index int, joint int) Float.X

Returns the gravity amount at 'joint' in the bone chain's joint list.

func (Instance) GetJointGravityDirection

func (self Instance) GetJointGravityDirection(index int, joint int) Vector3.XYZ

Returns the gravity direction at 'joint' in the bone chain's joint list.

func (Instance) GetJointRadius

func (self Instance) GetJointRadius(index int, joint int) Float.X

Returns the radius at 'joint' in the bone chain's joint list.

func (Instance) GetJointRotationAxis

func (self Instance) GetJointRotationAxis(index int, joint int) RotationAxis

Returns the rotation axis at 'joint' in the bone chain's joint list.

func (Instance) GetJointRotationAxisVector

func (self Instance) GetJointRotationAxisVector(index int, joint int) Vector3.XYZ

Returns the rotation axis vector for the specified joint in the bone chain. This vector represents the axis around which the joint can rotate. It is determined based on the rotation axis set for the joint.

If Instance.GetJointRotationAxis is RotationAxisAll, this method returns Vector3(0, 0, 0).

func (Instance) GetJointStiffness

func (self Instance) GetJointStiffness(index int, joint int) Float.X

Returns the stiffness force at 'joint' in the bone chain's joint list.

func (Instance) GetRadius

func (self Instance) GetRadius(index int) Float.X

Returns the joint radius of the bone chain.

func (Instance) GetRadiusDampingCurve

func (self Instance) GetRadiusDampingCurve(index int) Curve.Instance

Returns the joint radius damping curve of the bone chain.

func (Instance) GetRootBone

func (self Instance) GetRootBone(index int) int

Returns the root bone index of the bone chain.

func (Instance) GetRootBoneName

func (self Instance) GetRootBoneName(index int) string

Returns the root bone name of the bone chain.

func (Instance) GetRotationAxis

func (self Instance) GetRotationAxis(index int) RotationAxis

Returns the rotation axis of the bone chain.

func (Instance) GetRotationAxisVector

func (self Instance) GetRotationAxisVector(index int) Vector3.XYZ

Returns the rotation axis vector of the bone chain. This vector represents the axis around which the bone chain can rotate. It is determined based on the rotation axis set for the bone chain.

If Instance.GetRotationAxis is RotationAxisAll, this method returns Vector3(0, 0, 0).

func (Instance) GetStiffness

func (self Instance) GetStiffness(index int) Float.X

Returns the stiffness force of the bone chain.

func (Instance) GetStiffnessDampingCurve

func (self Instance) GetStiffnessDampingCurve(index int) Curve.Instance

Returns the stiffness force damping curve of the bone chain.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsConfigIndividual

func (self Instance) IsConfigIndividual(index int) bool

Returns true if the config can be edited individually for each joint.

func (Instance) IsEndBoneExtended

func (self Instance) IsEndBoneExtended(index int) bool

Returns true if the end bone is extended to have the tail.

func (Instance) Reset

func (self Instance) 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 graphics.gd/classdb/AnimationPlayer.Instance.Play without a fading, or within the previous [Instance.OnSkeletonmodifier3d.ModificationProcessed] signal if it's condition changes significantly.

func (Instance) SetCenterBone

func (self Instance) SetCenterBone(index int, bone int)

Sets the center bone index of the bone chain.

func (Instance) SetCenterBoneName

func (self Instance) SetCenterBoneName(index int, bone_name string)

Sets the center bone name of the bone chain.

func (Instance) SetCenterFrom

func (self Instance) SetCenterFrom(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 parent graphics.gd/classdb/Skeleton3D is used as the center, the bones are considered to have not moved if the graphics.gd/classdb/Skeleton3D moves in the world.

In this case, only a change in the bone pose is considered to be a bone movement.

func (Instance) SetCenterNode

func (self Instance) SetCenterNode(index int, node_path string)

Sets the center node path of the bone chain.

func (Instance) SetCollisionCount

func (self Instance) SetCollisionCount(index int, count int)

Sets the number of collisions in the collision list at 'index' in the settings when Instance.AreAllChildCollisionsEnabled is false.

func (Instance) SetCollisionPath

func (self Instance) SetCollisionPath(index int, collision int, node_path string)

Sets the node path of the graphics.gd/classdb/SpringBoneCollision3D at 'collision' in the bone chain's collision list when Instance.AreAllChildCollisionsEnabled is false.

func (Instance) SetDrag

func (self Instance) SetDrag(index int, drag Float.X)

Sets the drag force of the bone chain. The greater the value, the more suppressed the wiggling.

The value is scaled by Instance.SetDragDampingCurve and cached in each joint setting in the joint list.

func (Instance) SetDragDampingCurve

func (self Instance) SetDragDampingCurve(index int, curve Curve.Instance)

Sets the drag force damping curve of the bone chain.

func (Instance) SetEnableAllChildCollisions

func (self Instance) SetEnableAllChildCollisions(index int, enabled bool)

If 'enabled' is true, all child [graphics.gd/classdb/SpringBoneCollision3D]s are colliding and Instance.SetExcludeCollisionPath is enabled as an exclusion list at 'index' in the settings.

If 'enabled' is false, you need to manually register all valid collisions with Instance.SetCollisionPath.

func (Instance) SetEndBone

func (self Instance) SetEndBone(index int, bone int)

Sets the end bone index of the bone chain.

func (Instance) SetEndBoneDirection

func (self Instance) SetEndBoneDirection(index int, bone_direction BoneDirection)

Sets the end bone tail direction of the bone chain when Instance.IsEndBoneExtended is true.

func (Instance) SetEndBoneLength

func (self Instance) SetEndBoneLength(index int, length Float.X)

Sets the end bone tail length of the bone chain when Instance.IsEndBoneExtended is true.

func (Instance) SetEndBoneName

func (self Instance) SetEndBoneName(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 by Instance.SetExtendEndBone to jiggle the bone.

func (Instance) SetExcludeCollisionCount

func (self Instance) SetExcludeCollisionCount(index int, count int)

Sets the number of exclude collisions in the exclude collision list at 'index' in the settings when Instance.AreAllChildCollisionsEnabled is true.

func (Instance) SetExcludeCollisionPath

func (self Instance) SetExcludeCollisionPath(index int, collision int, node_path string)

Sets the node path of the graphics.gd/classdb/SpringBoneCollision3D at 'collision' in the bone chain's exclude collision list when Instance.AreAllChildCollisionsEnabled is true.

func (Instance) SetExtendEndBone

func (self Instance) SetExtendEndBone(index int, enabled 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.

func (Instance) SetExternalForce

func (self Instance) SetExternalForce(value Vector3.XYZ)

func (Instance) SetGravity

func (self Instance) SetGravity(index int, gravity Float.X)

Sets the gravity amount of the bone chain. This value is not an acceleration, but a constant velocity of movement in Instance.SetGravityDirection.

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 Instance.SetGravityDampingCurve and cached in each joint setting in the joint list.

func (Instance) SetGravityDampingCurve

func (self Instance) SetGravityDampingCurve(index int, curve Curve.Instance)

Sets the gravity amount damping curve of the bone chain.

func (Instance) SetGravityDirection

func (self Instance) SetGravityDirection(index int, gravity_direction Vector3.XYZ)

Sets the gravity direction of the bone chain. This value is internally normalized and then multiplied by Instance.SetGravity.

The value is cached in each joint setting in the joint list.

func (Instance) SetIndividualConfig

func (self Instance) SetIndividualConfig(index int, enabled bool)

If 'enabled' is true, the config can be edited individually for each joint.

func (Instance) SetJointDrag

func (self Instance) SetJointDrag(index int, joint int, drag Float.X)

Sets the drag force at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

func (Instance) SetJointGravity

func (self Instance) SetJointGravity(index int, joint int, gravity Float.X)

Sets the gravity amount at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

func (Instance) SetJointGravityDirection

func (self Instance) SetJointGravityDirection(index int, joint int, gravity_direction Vector3.XYZ)

Sets the gravity direction at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

func (Instance) SetJointRadius

func (self Instance) SetJointRadius(index int, joint int, radius Float.X)

Sets the joint radius at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

func (Instance) SetJointRotationAxis

func (self Instance) SetJointRotationAxis(index int, joint int, axis RotationAxis)

Sets the rotation axis at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

The axes are based on the graphics.gd/classdb/Skeleton3D.Instance.GetBoneRest's space, if 'axis' is RotationAxisCustom, you can specify any axis.

Note: The rotation axis and the forward vector shouldn't be colinear to avoid unintended rotation since graphics.gd/classdb/SpringBoneSimulator3D does not factor in twisting forces.

func (Instance) SetJointRotationAxisVector

func (self Instance) SetJointRotationAxisVector(index int, joint int, vector Vector3.XYZ)

Sets the rotation axis vector for the specified joint in the bone chain.

This vector is normalized by an internal process and represents the axis around which the bone chain can rotate.

If the vector length is 0, it is considered synonymous with RotationAxisAll.

func (Instance) SetJointStiffness

func (self Instance) SetJointStiffness(index int, joint int, stiffness Float.X)

Sets the stiffness force at 'joint' in the bone chain's joint list when Instance.IsConfigIndividual is true.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetRadius

func (self Instance) SetRadius(index int, radius Float.X)

Sets the joint radius of the bone chain. It is used to move and slide with the graphics.gd/classdb/SpringBoneCollision3D in the collision list.

The value is scaled by Instance.SetRadiusDampingCurve and cached in each joint setting in the joint list.

func (Instance) SetRadiusDampingCurve

func (self Instance) SetRadiusDampingCurve(index int, curve Curve.Instance)

Sets the joint radius damping curve of the bone chain.

func (Instance) SetRootBone

func (self Instance) SetRootBone(index int, bone int)

Sets the root bone index of the bone chain.

func (Instance) SetRootBoneName

func (self Instance) SetRootBoneName(index int, bone_name string)

Sets the root bone name of the bone chain.

func (Instance) SetRotationAxis

func (self Instance) SetRotationAxis(index int, axis RotationAxis)

Sets the rotation axis of the bone chain. If set to a specific axis, it acts like a hinge joint. The value is cached in each joint setting in the joint list.

The axes are based on the graphics.gd/classdb/Skeleton3D.Instance.GetBoneRest's space, if 'axis' is RotationAxisCustom, you can specify any axis.

Note: The rotation axis vector and the forward vector shouldn't be colinear to avoid unintended rotation since graphics.gd/classdb/SpringBoneSimulator3D does not factor in twisting forces.

func (Instance) SetRotationAxisVector

func (self Instance) SetRotationAxisVector(index int, vector Vector3.XYZ)

Sets the rotation axis vector of the bone chain. The value is cached in each joint setting in the joint list.

This vector is normalized by an internal process and represents the axis around which the bone chain can rotate.

If the vector length is 0, it is considered synonymous with RotationAxisAll.

func (Instance) SetSettingCount

func (self Instance) SetSettingCount(value int)

func (Instance) SetStiffness

func (self Instance) SetStiffness(index int, stiffness Float.X)

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 Instance.SetStiffnessDampingCurve and cached in each joint setting in the joint list.

func (Instance) SetStiffnessDampingCurve

func (self Instance) SetStiffnessDampingCurve(index int, curve Curve.Instance)

Sets the stiffness force damping curve of the bone chain.

func (Instance) SettingCount

func (self Instance) SettingCount() int

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type RotationAxis

type RotationAxis int //gd:SpringBoneSimulator3D.RotationAxis
const (
	// Enumerated value for the rotation of the X axis.
	RotationAxisX RotationAxis = 0
	// Enumerated value for the rotation of the Y axis.
	RotationAxisY RotationAxis = 1
	// Enumerated value for the rotation of the Z axis.
	RotationAxisZ RotationAxis = 2
	// Enumerated value for the unconstrained rotation.
	RotationAxisAll RotationAxis = 3
	// Enumerated value for an optional rotation axis. See also [Instance.SetJointRotationAxisVector].
	RotationAxisCustom RotationAxis = 4
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL