Converting bone transforms into component space

In persona, when you click a bone you can see its transforms. These are either relative the bones parent, or relative the root (which confusingly is called world transform there). What I want to do is get those transforms, and convert them into component space.

I know how to convert an actual world transform into component space with the inverse transform location node, but I can’t seem to find a way of converting this bone data. I made it into a transform and tried adding the location vector to the actor world location vector, and it kind of worked but the transform didn’t follow the actor rotation, so I combined the rotators but to no avail since the transform seems to only rotate around itself. I just started working with these conversions so can somebody please help me?

Thanks in advance!

https://api.unrealengine.com/INT/API…orm/index.html

FTransform has TransformPosition and TransfromVector to do what you are asking

Thank you!

Was looking for a way to do it.
Its about composing the whole transform chain from the target bone up to the root bone.

There is the manual way: Get Ref Pose Bone Position in Component Space in UE4 | Noah Zuo's Blog

Or Unreal provides a function:



FAnimationRuntime::GetComponentSpaceTransform


Would you mind sharing an example on how to do that? I’ve been stuck on this for quite a while now…

// The world location is the hit location in world space. Find the location in bone space of the hit bone, so that this location can be found
// in the reference pose component space for the material effect.
FVector BoneSpaceLocation;
FRotator BoneSpaceRotation;
GetMesh()->TransformToBoneSpace(BoneName, WorldLocation, FRotator::ZeroRotator, BoneSpaceLocation, BoneSpaceRotation);

// Get the reference pose skeleton and transforms.
const FReferenceSkeleton& ReferenceSkeleton = GetMesh()->SkeletalMesh->GetRefSkeleton();
const TArray<FTransform>& ReferenceTransforms = ReferenceSkeleton.GetRefBonePose();

// Find the bone to component space transform and transform the bone space hit location into component space of the reference pose.
const int32 BoneIndex = GetMesh()->GetBoneIndex(BoneName);
const FTransform BoneToComponentTransform = FAnimationRuntime::GetComponentSpaceTransform(ReferenceSkeleton, ReferenceTransforms, BoneIndex);
const FVector ComponentSpaceLocation = BoneToComponentTransform.TransformPosition(BoneSpaceLocation);

DO NOT USE ABOVE ANSWER

Acutally, GetComponentSpaceTransform is not a way to correctly get transform, because it will effect your mesh!!!

You should using:

	auto ParentBone2 = SkeletalMeshComponent->GetParentBone(Bone.BoneName);
			auto ParentBoneIndex = SkeletalMeshComponent->GetBoneIndex(ParentBone2);
			UE_LOG(LogTemp, Warning, TEXT("[jj getpose] parent: %s "), *ParentBone2.ToString());
			auto WorldToParentBone = SkeletalMeshComponent->GetBoneTransform(ParentBoneIndex).GetRotation();
1 Like