RetargetingConfiguration
A configuration for retargeting skeletal animations between different skeletons.
Declaration
@MainActor class RetargetingConfigurationOverview
RetargetingConfiguration enables the transfer of animations from one skeleton to another, automatically mapping joints and adapting poses to accommodate different skeletal structures. This is particularly useful for applying animations across different character models or creatures.
Usage
Create configurations using the static factory methods for common skeleton types:
automatchBiped(_:to:jointOffsets:) for humanoid/bipedal characters
automatchQuadruped(_:sourceTransform:to:targetTransform:jointOffsets:) for four-legged creatures
Example
do {
// Basic biped retargeting
let config = try RetargetingConfiguration.automatchBiped(
sourceCharacterSkeleton,
to: targetCharacterSkeleton
)
// With joint offset adjustments applied during configuration creation
let jointOffsets: [String: simd_quatf] = [
"LeftShoulder": simd_quatf(angle: 0.1, axis: simd_float3(0, 1, 0)),
"RightShoulder": simd_quatf(angle: -0.1, axis: simd_float3(0, 1, 0))
]
let configWithOffsets = try RetargetingConfiguration.automatchBiped(
sourceCharacterSkeleton,
to: targetCharacterSkeleton,
jointOffsets: jointOffsets
)
} catch {
print("Failed to create retargeting configuration: \(error.localizedDescription)")
}Performance Considerations
Configuration creation is computationally expensive and should be cached when possible.
The automatic matching algorithm analyzes skeleton hierarchies to establish joint correspondences.
Joint offsets are baked into the configuration during creation, not applied at runtime.
Topics
Creating a configuration
automatchBiped(_:sourceTransform:to:targetTransform:jointOffsets:)automatchBiped(_:to:jointOffsets:)automatchQuadruped(_:sourceTransform:to:targetTransform:jointOffsets:)