It seems should be convert to component space? I just wanna know how to set local rotation.
I have tried to set it in an ordinary blueprint with poseable mesh component or skeletal mesh component, and I could get bones’ local Transform, but there is no node to set local transform.
I guess if I set values in from local to component space,it would be the same as “Set Bone Transform By Bone Name(component space)”.
So, it’s not what I really want.
Finally, I used in PoseMesh component in C++, and that works.
One thing you should pay attention to is we cannot use local space, but unreal offers us an array for accessing bone local transform instead.
Hello, I am looking forward to your answer as it seems to be related to the answer I am looking for.
I also want to change the local rotation of the bones during runtime. I want my character to do a finger V pose whenever I press a UI button.
So I’m trying to create a custom animnode in C++ to modify the local rotation of a bone.
We are currently experimenting by writing the logic in the following order.
- In an animation where the character is doing a V pose, I got the rotation of the finger bones making the pose. I thought I should bring the rotation value of the finger bones into Local Rotation so that the moving character can do the V-pose naturally.
1-1. So I used Anim BP’s Get Socket Transform node to get the local rotation of the RTS_ParentBoneSpace bone.
- Referring to the Transform(Modify) Bone node, I created a custom Anim node that can change the rotation of multiple bones at once.
2-1. RotationSpace is specified as BCS_ParentBoneSpace since we need to change the local rotation of the bone in the custom anim node.
void FAnimNode_ModifyBoneRotationList::EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms)
{
check(OutBoneTransforms.Num() == 0);
const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
const FCompactPose& Pose = Output.Pose.GetPose();
TArray<FBoneTransform> Temp;
for (const auto& BoneIndex : Pose.ForEachBoneIndex())
{
FBoneReference& BoneReference = BoneToModifies[BoneIndex.GetInt()];
const FName& SkeletonBoneName = BoneReference.BoneName;
FTransform NewBoneTM = Output.Pose.GetComponentSpaceTransform(BoneIndex);
FRotator& Rotation = *BoneList.Find(SkeletonBoneName); //TMap<FName, FRotator> BoneList
if (&Rotation != nullptr)
{
FTransform ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();
FAnimationRuntime::ConvertCSTransformToBoneSpace(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace);
FString HandBoneName = SkeletonBoneName.ToString();
if (WhichHandChecked == 0)
NewBoneTM.SetRotation(NewBoneTM.GetRotation() * FQuat(Rotation));
else if (WhichHandChecked == 1 && HandBoneName.Contains("_l"))
NewBoneTM.SetRotation(FQuat(Rotation));
else if (WhichHandChecked == 2 && HandBoneName.Contains("_r"))
NewBoneTM.SetRotation(FQuat(Rotation));
else if (WhichHandChecked == 3 && (HandBoneName.Contains("_l") || HandBoneName.Contains("_r")))
NewBoneTM.SetRotation(FQuat(Rotation));
FAnimationRuntime::ConvertBoneSpaceTransformToCS(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace);
}
Temp.Emplace(FBoneTransform(BoneIndex, NewBoneTM));
Output.Pose.LocalBlendCSBoneTransforms(Temp, Alpha);
Temp.Reset();
}
}
2-2.Output.Pose.GetComponentSpaceTransform() retrieves the current World Transform of the bone.
2-3.With FAnimationRuntime::ConvertCSTransformToBoneSpace(), I changed the world transform of the bone to BoneSpace and applied the local rotation value of the V pose (relative to RTS_ParentBoneSpace).
2-4.ConvertBoneSpaceTransformToCS() changes the Transform of Bone operating in BoneSpace to Component Space.
Updated the pose with 2-5.LocalBlendCSBoneTransforms().
Until now, the character’s fingers cannot represent the V pose…;o;
Could you please tell me how you changed and set the local rotation of the bone?
I would be very happy if you could give me even the smallest hint.