Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Update skeleton rest pose of one instance of skeletal mesh

Hi all,

I'm currently trying to update the rest pose of the skeleton of my character to make it match some shape change.

To do this, I'm using the following code where MeshCmp is a USkeletalMeshComponenent and MyOffsets and MyBoneNames are my inputs.

 TArray<FVector> MyOffsets;
 TArray<FName> MyBoneNames;
 FReferenceSkeleton NewSkeletonRef;
 FReferenceSkeleton RefSkeleton = MeshCmp->SkeletalMesh->Skeleton->GetReferenceSkeleton();
 TArray<FMeshBoneInfo> SkelRefBonesInfo = RefSkeleton.GetRefBoneInfo();
 FReferenceSkeletonModifier SkeletonModifier(NewSkeletonRef, MeshCmp->SkeletalMesh->Skeleton);
 TArray<FTransform> BonesRestBonesTr = RefSkeleton.GetRefBonePose();
 for (int j = 0; j < MyOffsets.Num(); j++)
     FTransform boneTransform;
     int32 SkeletonIndex = RefSkeleton.FindBoneIndex(MyBoneNames[j]);
     if (SkeletonIndex >= 0)
         // get rest bone for this bone
         FTransform boneRestTr = BonesRestBonesTr[SkeletonIndex];
         boneTransform.SetLocation(boneRestTr.GetLocation() + (MyOffsets[j] * Value));
         // update pose transform
         FMeshBoneInfo boneInfo;
         boneInfo.ExportName = SkelRefBonesInfo[SkeletonIndex].ExportName;
         boneInfo.Name = SkelRefBonesInfo[SkeletonIndex].Name;
         boneInfo.ParentIndex = SkelRefBonesInfo[SkeletonIndex].ParentIndex;
         SkeletonModifier.Add(boneInfo, boneTransform);

This kind of works since my skeleton rest pose is indeed modified as expected by it is modified for all characters using the same skeletal mesh. Since most of my characters use the same base skeletal mesh, it's not what I'm after. So my question is : how could I modify the rest pose of the skeleton only for the instance of the given skeletal mesh component?

Thanks for your help.

Product Version: UE 4.17
more ▼

asked Nov 12 '17 at 05:53 PM in C++ Programming

avatar image

21 2 10 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

So I answer my own question in case someone ever stumbles on this question and hasn't figured out yet how to do.

It's so simple that I don't even understand how I missed it before: in fact, there is a function all set up for specifically doing that in the USkeletalMeshComponent class : SetRefPoseOverride which takes an array of FTransform as input and there you go...

more ▼

answered Nov 19 '17 at 04:42 PM

avatar image

21 2 10 9

avatar image RobotBerry Sep 05 '18 at 11:59 AM

You're my lifesaver!! many thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question