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?
// 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);