Skeleton3D
A node containing a bone hierarchy, used to create a 3D skeletal animation.
Skeleton3D.swift:31class Skeleton3D
Skeleton3D
provides an interface for managing a hierarchy of 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 bone pose. Bone rest defines the initial transform of the bone pose.
Note that “global pose” below refers to the overall transform of the bone with respect to skeleton, so it is not the actual global/world transform of the bone.
This object emits the following signals:
Superclasses
class Node3D
Most basic 3D game object, parent of all 3D-related nodes.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
enum ModifierCallbackModeProcess
class Signal1
Signal support.
Type members
static let notificationUpdateSkeleton: Int
Notification received when this skeleton’s pose needs to be updated. In that case, this is called only once per frame in a deferred process.
class var godotClassName: StringName
Instance members
var boneEnabledChanged: Signal1
Emitted when the bone at
boneIdx
is toggled withsetBoneEnabled(boneIdx:enabled:)
. UseisBoneEnabled(boneIdx:)
to check the new value.var boneListChanged: SimpleSignal
To connect to this signal, reference this property and call the
var modifierCallbackModeProcess: Skeleton3D.ModifierCallbackModeProcess
Sets the processing timing for the Modifier.
var motionScale: Double
Multiplies the 3D position track animation.
var poseUpdated: SimpleSignal
Emitted when the pose is updated.
var showRestOnly: Bool
If
true
, forces the bones in their default rest pose, regardless of their values. In the editor, this also prevents the bones from being edited.var showRestOnlyChanged: SimpleSignal
Emitted when the value of
showRestOnly
changes.var skeletonUpdated: SimpleSignal
Emitted when the final pose has been calculated will be applied to the skin in the update process.
func addBone(name: String
) -> Int32 Adds a new bone with the given name. Returns the new bone’s index, or
-1
if this method fails.func clearBones(
) Clear all the bones in this skeleton.
func clearBonesGlobalPoseOverride(
) Removes the global pose override on all bones in the skeleton.
func createSkinFromRestTransforms(
) -> Skin? func findBone(name: String
) -> Int32 Returns the bone index that matches
name
as its name. Returns-1
if no bone with this name exists.func forceUpdateAllBoneTransforms(
) Force updates the bone transforms/poses for all bones in the skeleton.
func forceUpdateBoneChildTransform(boneIdx: Int32
) Force updates the bone transform for the bone at
boneIdx
and all of its children.func getAnimatePhysicalBones(
) -> Bool func getBoneChildren(boneIdx: Int32
) -> PackedInt32Array Returns an array containing the bone indexes of all the child node of the passed in bone,
boneIdx
.func getBoneCount(
) -> Int32 Returns the number of bones in the skeleton.
func getBoneGlobalPose(boneIdx: Int32
) -> Transform3D 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.
func getBoneGlobalPoseNoOverride(boneIdx: Int32
) -> Transform3D 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.
func getBoneGlobalPoseOverride(boneIdx: Int32
) -> Transform3D Returns the global pose override transform for
boneIdx
.func getBoneGlobalRest(boneIdx: Int32
) -> Transform3D Returns the global rest transform for
boneIdx
.func getBoneName(boneIdx: Int32
) -> String Returns the name of the bone at index
boneIdx
.func getBoneParent(boneIdx: Int32
) -> Int32 Returns the bone index which is the parent of the bone at
boneIdx
. If -1, then bone has no parent.func getBonePose(boneIdx: Int32
) -> Transform3D Returns the pose transform of the specified bone.
func getBonePosePosition(boneIdx: Int32
) -> Vector3 Returns the pose position of the bone at
boneIdx
. The returnedVector3
is in the local coordinate space of theSkeleton3D
node.func getBonePoseRotation(boneIdx: Int32
) -> Quaternion Returns the pose rotation of the bone at
boneIdx
. The returnedQuaternion
is local to the bone with respect to the rotation of any parent bones.func getBonePoseScale(boneIdx: Int32
) -> Vector3 Returns the pose scale of the bone at
boneIdx
.func getBoneRest(boneIdx: Int32
) -> Transform3D Returns the rest transform for a bone
boneIdx
.func getConcatenatedBoneNames(
) -> StringName Returns all bone names concatenated with commas (
,
) as a singleStringName
.func getParentlessBones(
) -> PackedInt32Array 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.
func getVersion(
) -> UInt Returns the number of times the bone hierarchy has changed within this skeleton, including renames.
func isBoneEnabled(boneIdx: Int32
) -> Bool Returns whether the bone pose for the bone at
boneIdx
is enabled.func localizeRests(
) Returns all bones in the skeleton to their rest poses.
func physicalBonesAddCollisionException(RID
) Adds a collision exception to the physical bone.
func physicalBonesRemoveCollisionException(RID
) Removes a collision exception to the physical bone.
func physicalBonesStartSimulation(bones: VariantCollection<StringName>
) Tells the
PhysicalBone3D
nodes in the Skeleton to start simulating and reacting to the physics world.func physicalBonesStopSimulation(
) Tells the
PhysicalBone3D
nodes in the Skeleton to stop simulating.func registerSkin(Skin?
) -> SkinReference? Binds the given Skin to the Skeleton.
func resetBonePose(boneIdx: Int32
) Sets the bone pose to rest for
boneIdx
.func resetBonePoses(
) Sets all bone poses to rests.
func setAnimatePhysicalBones(enabled: Bool
) This method exists for compatibility with old structures in which the
Skeleton3D
does not have aPhysicalBoneSimulator3D
as a child, but directly hasPhysicalBone3D
s as children.func setBoneEnabled(boneIdx: Int32, enabled: Bool
) Disables the pose for the bone at
boneIdx
iffalse
, enables the bone pose iftrue
.func setBoneGlobalPose(boneIdx: Int32, pose: Transform3D
) Sets the global pose transform,
pose
, for the bone atboneIdx
.func setBoneGlobalPoseOverride(boneIdx: Int32, pose: Transform3D, amount: Double, persistent: Bool
) Sets the global pose transform,
pose
, for the bone atboneIdx
.func setBoneName(boneIdx: Int32, name: String
) Sets the bone name,
name
, for the bone atboneIdx
.func setBoneParent(boneIdx: Int32, parentIdx: Int32
) Sets the bone index
parentIdx
as the parent of the bone atboneIdx
. If -1, then bone has no parent.func setBonePose(boneIdx: Int32, pose: Transform3D
) Sets the pose transform,
pose
, for the bone atboneIdx
.func setBonePosePosition(boneIdx: Int32, position: Vector3
) Sets the pose position of the bone at
boneIdx
toposition
.position
is aVector3
describing a position local to theSkeleton3D
node.func setBonePoseRotation(boneIdx: Int32, rotation: Quaternion
) Sets the pose rotation of the bone at
boneIdx
torotation
.rotation
is aQuaternion
describing a rotation in the bone’s local coordinate space with respect to the rotation of any parent bones.func setBonePoseScale(boneIdx: Int32, scale: Vector3
) Sets the pose scale of the bone at
boneIdx
toscale
.func setBoneRest(boneIdx: Int32, rest: Transform3D
) Sets the rest transform for bone
boneIdx
.func unparentBoneAndRest(boneIdx: Int32
) Unparents the bone at
boneIdx
and sets its rest position to that of its parent prior to being reset.