Hi,
I'm not familar enough with FBX to say whether there is a better way to solve this when generating the FBX or when importing the FBX in another package.
However, I can provide some advice on baking the pivot animation in Maya.
To bake the pivot animation you would need to set a keyframe per frame since as you have discovered bake pivot works on a single frame. (and the results of bake pivot will be different depending on the scaling/rotation at that frame)
For example, this MEL script generates a simple animation from frame 1 to 120 on a cone where the pivot has been moved to the tip of the cone.
currentTime 1; // Time 1
CreatePolygonCone; // Cone
move 0 1 0 pCone1.sp pCone1.rp; // Move pivot to tip
move -rpr 0 0 0; // Move tip to origin
rotate -r -os -fo -90 0 0; // Rotate -90 in X
setKeyframe;
currentTime 120; // Time 120
move -rpr 0 0 -12; // Move tip to -12 in Z
rotate -r -os -fo 180 0 0; // Rotate 180 in X
setKeyframe;
currentTime 60; // Time 60
move -r 0 -6 0; // Translate -6 in Y
setKeyframe;
currentTime 1;
To bake this per frame we need to first bake the translation curves and then compute the pivot change for each frame and then apply that to the baked translation keyframes.
string $object = "pCone1";
// Bake translation channels (key per frame)
bakeResults ($object + ".tx");
bakeResults ($object + ".ty");
bakeResults ($object + ".tz");
float $otx[], $oty[], $otz[];
float $ntx[], $nty[], $ntz[];
for ($t = 1; $t <= 120; ++$t) {
currentTime $t;
// Get current translation
$otx[size($otx)] = getAttr ($object + ".tx");
$oty[size($oty)] = getAttr ($object + ".ty");
$otz[size($otz)] = getAttr ($object + ".tz");
// Zero pivots
xform -zeroTransformPivots;
// Get translation with baked pivots
$ntx[size($ntx)] = getAttr ($object + ".tx");
$nty[size($nty)] = getAttr ($object + ".ty");
$ntz[size($ntz)] = getAttr ($object + ".tz");
// Undo zero pivots
undo;
}
// Zero transform pivots
xform -zeroTransformPivots;
// Update translation keys
for ($t = 1; $t <= 120; ++$t) {
int $i = $t-1;
float $dx = $ntx[$i]-$otx[$i];
float $dy = $nty[$i]-$oty[$i];
float $dz = $ntz[$i]-$otz[$i];
keyframe -r -t $t -vc $dx -at tx $object;
keyframe -r -t $t -vc $dy -at ty $object;
keyframe -r -t $t -vc $dz -at tz $object;
}
Obviously this is a very simple example and things will get more complicated if dealing with a hierarchy etc. but maybe this will help you solve your specific issue.
Brent McPherson
Principle Software Developer