PoseAI / PoseCameraAPI

Tools to work with the Pose Camera app
Apache License 2.0
147 stars 38 forks source link

How to re-write PoseAIRigMetaHuman::Configure() #32

Open DatanIMU opened 6 days ago

DatanIMU commented 6 days ago

We know metahuman have several skeletion. How to re-write PoseAIRigMetaHuman::Configure(), if I change body size of metahuman.

PoseAI commented 5 days ago

You may not need to rewrite code just for changing the body size, as the animation is driven by bone rotations rather than sizes per se, and the main thing that needs to change for scale is the root motion, which can be scaled with a field in the PoseAILiveLinkRetargetRotations (inherits from ULiveLinkRetargetAsset and is used as a substitute in the LiveLink Pose node in the animation graph).

If you do want to add your own Rig to handle specific skeletons, then I would suggest:

  1. create a new EPoseAIRigPreset enum, something like MetaHumanCustom.
  2. define a subclass for your custom rig at the bottom of PoseAIRig.h, like the others, call it say PoseAIRigMetaHumanCustom
  3. in PoseAIRig.cpp, in the PoseAIRigFactory method add a case to create the custom preset
  4. add the body for your custom rig in PoseAIRig.cpp. You could use the PoseAIMetahuman::Configure() code as a template if you need to change default bone lengths. Note that our engine sends the packets assuming either those bone names (when using Verbose), or in that specific order if using compact, so changing the hierarchy will likely break things. But Unreal can animate even if only some joints are passed, you would need to determine how the other joints are animated (or leave them with a base rotation).

if you needed to actually customize the rotations further, probably best place is in a custom PoseALLiveLinkRetargetRotations.cpp where you could check for the bone index and apply custom transforms appropriately.