Tuesday, February 14, 2012

Camera Animation Broken on Batch Render

A few people at school have had issues with their cameras not animating when rendering on our farm. I think this happens when complex camera rigs are used, sometimes even one group above a camera with keys will not work. These rigs are a little bit more difficult to deal with but here is a quick script that bakes the overall camera animation to a new camera.

global proc dbr_bakeCamera(string $cam)
{
string $bakeCam[] = `camera -name ($cam + "_BAKE")`;
string $oCST[] = `orientConstraint $cam $bakeCam[0]`;
string $pCST[] = `pointConstraint $cam $bakeCam[0]`;
bakeResults -t "1:68" -at "tx" -at "ty" -at "tz" -at "rx" -at "ry" -at "rz" $bakeCam[0];
delete $oCST[0];
delete $pCST[0];
}

//usage: dbr_bakeCamera("camName") where camName is the name of the camera you'd like to bake.


** Python

import maya.cmds as cmds
def dbr_bakeCamera(cameraName, frameRange):
     bakeCamera = cmds.camera(name = '%s_BAKE' % cameraName)
     orientCNSTR = cmds.orientConstraint(cameraName, bakeCamera[0])
     pointCNSTR = cmds.pointConstraint(cameraName, bakeCamera[0])
     cmds.bakeResults(bakeCamera[0], t = frameRange, at = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'focalLength'])
     cmds.delete(orientCNSTR)
     cmds.delete(pointCNSTR)

#Bake selected camera from frame 1 to 62
dbr_bakeCamera(cmds.ls(sl = True)[0], (1,62))

No comments:

Post a Comment