The pivot of the local space is not being baked in cases of animation

The pivot of the local space is not being baked in cases of animation

guilherme_garciaK4SB8
Observer Observer
336 Views
2 Replies
Message 1 of 3

The pivot of the local space is not being baked in cases of animation

guilherme_garciaK4SB8
Observer
Observer

Hello,

I would like some help from the community regarding the Local Space Pivot attribute. I'm having a problem exporting the FBX with non-zero pivot values ​​and importing it into other software. In Blender and Unreal, the objects have the wrong displacement. Apparently, only Maya handles these pivots in FBX correctly.

Maya has a Bake Pivot option. I believed this would generate keyframes to compensate for the pivot displacement, but it doesn't. It only generates the value for the current frame, leaving all other frames in the wrong position. This seems like a problem because it's quite difficult to fix the displaced pivot without an appropriate tool.

I tried generating a script that bakes each frame and sets the keyframe, but the problem is bigger than I imagined. mel.eval('performBakeCustomToolPivot 0') and cmds.xform( ztp=True) don't seem to perform the correct evaluation when the frame is updated.

I would appreciate some help on what to do in this situation, thank you.

0 Likes
Accepted solutions (1)
337 Views
2 Replies
Replies (2)
Message 2 of 3

brentmc
Autodesk
Autodesk
Accepted solution

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
0 Likes
Message 3 of 3

lauri_barnhart
Autodesk
Autodesk

Hello, @guilherme_garciaK4SB8,

Just checking in—did the responses shared by @brentmc help clarify your question?

If so, please consider clicking the "Accept Solution" button. Doing so helps others in the community find answers to similar issues.

If your question still needs more attention, feel free to reply here with an update. This way, other members can jump in with further suggestions or guidance to help you move forward.

All the best,

Lauri | Community Manager


Lauri | Community Manager
0 Likes