So, FBX in Cinema 4D is screwed – and has been screwed for a long time. It gets in position and rotation data correctly, but it never gets in camera data correctly (nor exports it correctly, either, for that matter).
What I have done in the past to get cameras from maya into cinema has been to link the transforms of the camera to a null and then link the focal length of the camera to the Y position of another null. I bake them both out, transfer to Cinema via FBX and then use Xpresso to link up the correct values to a new cam. All well and good, but I thought since I had a little down time on my current job – and we’ve been dealing with this problem for months now – it might make a nice little script to ease the workflow a bit. So this script does the linking and baking part in Maya. You just select the camera, run the script, and it creates two locators – one with all the camera transform information baked in, and the other with the y position equaling the focal length of the camera.
Keep in mind this is my first mel script – and I only had a few hours to work on it. So, it is not perfect. There’s no error checking, no gui – just a barebones script that assumes the user knows exactly what he is doing and why he needs the script.
//MayaCameraXForm to C4d by Adam Swaab ©2010 //Warning! There's no error detection in this script! Select one camera (one only!) and run the script. It works based on the project timeline. int $i = `playbackOptions -q -animationStartTime`; int $end = `playbackOptions -q -animationEndTime`; string $select[] = `ls -sl`; $ActiveCam = $select[0]; //Create locators for data spaceLocator -p 0 0 0 -name "CameraTransforms"; spaceLocator -p 0 0 0 -name "YisFocalLength"; while($i <= $end) { currentTime $i; //Restore selection to camera and get Camera Info select -cl; select -r $ActiveCam; float $position[3] = `xform -worldSpace -query -translation $ActiveCam`; float $rotation[3] = `xform -worldSpace -query -rotation $ActiveCam`; $xpos = $position[0]; $ypos = $position[1]; $zpos = $position[2]; $xrot = $rotation[0]; $yrot = $rotation[1]; $zrot = $rotation[2]; $camshape = `listRelatives -s $ActiveCam`; $flength = `getAttr $camshape.focalLength`; //Set Data for locators setAttr("CameraTransforms.translateX", $xpos); setKeyframe("CameraTransforms.translateX"); setAttr("CameraTransforms.translateY", $ypos); setKeyframe("CameraTransforms.translateY"); setAttr("CameraTransforms.translateZ", $zpos); setKeyframe("CameraTransforms.translateZ"); setAttr("CameraTransforms.rotateX", $xrot); setKeyframe("CameraTransforms.rotateX"); setAttr("CameraTransforms.rotateY", $yrot); setKeyframe("CameraTransforms.rotateY"); setAttr("CameraTransforms.rotateZ", $zrot); setKeyframe("CameraTransforms.rotateZ"); setAttr("YisFocalLength.translateY", $flength); setKeyframe("YisFocalLength.translateY"); $i++; }