There are some old animations that I want to reuse, but the old animation use different axis (For example: old: Face negative Z, Y as up; new: Face Y, Negative Z as up). So I fix this by grouping the animation and rotate the group so that it faces the right axis. But when I ungroup, it's only work for current frame (I turn Auto key on).
I have search several forums:
Grouping animated objects, Scaling, Ungrouping
Need help maintaining offset during ungroup
ungrouping but keeping animation
Grouping animated objects, Scaling, Ungrouping
But nothing works.
Ok, it works for the current frame when you ungroup. So to make it work for the entire animation, you can group & un-group for all the frames. Of course I won't do it by hand but I'll do it with script.
proc GetPlaybackRange(string $bone, int $outStartEndTime[])
{
float $arrKey[] = `keyframe -q $bone`;
$arrKeyLength=size($arrKey);
$outStartEndTime[0] = floor($arrKey[0]);
$outStartEndTime[1] = ceil($arrKey[$arrKeyLength-1]);
}
proc UngroupAndGroupNextFrame(int $frame, string $groupName, float $transform[])
{
currentTime $frame ;
ungroup;
currentTime ($frame + 1) ;
group -n $groupName;
xform -worldSpace -matrix
$transform[0]
$transform[1]
$transform[2]
$transform[3]
$transform[4]
$transform[5]
$transform[6]
$transform[7]
$transform[8]
$transform[9]
$transform[10]
$transform[11]
$transform[12]
$transform[13]
$transform[14]
$transform[15]
$groupName;
}
proc UnGroupForAnimation()
{
string $sel[]= `ls -sl`;
string $groupName = $sel[0];
float $transform[];
$transform = `xform -q -worldSpace -matrix $groupName`;
string $bone[] = `listRelatives -children $groupName`;
int $startEndTime[];
GetPlaybackRange($bone[0], $startEndTime);
for($i = $startEndTime[0]; $i <= $startEndTime[1]; $i++)
{
UngroupAndGroupNextFrame($i, $groupName, $transform);
}
currentTime ($startEndTime[1] + 1) ;
ungroup;
timeSliderClearKey;
print ($bone[0] + " range "+$startEndTime[0]+" : "+$startEndTime[1]);
}
UnGroupForAnimation();
Usage of the script:
Step 1. Select the group (the children of the group should be the bone)
Step 2. Run the script.
And that's it.