Removing parenting & targetting -- baking the AE camera

All things .jsx

Moderator: Paul Tuersley

Post Reply
urbanspaceman
Posts: 54
Joined: December 12th, 2007, 9:56 am
Location: London
Contact:

Thanks to some direct help from Mr. Ebberts with the 3D rotations, I now have a script to share that will bake the AE camera. It shouldn't matter what rotation methods and parenting the original camera has, as it translates all of that into a free camera with only position, rotation, and zoom parameters.

All you have to do is set your work area, highlight your camera, and it will make a copy of it with all the keyframes baked.

There are a number of advantages. Sometimes there is a need to export an AE camera to a 3D app, and baking the camera usually helps you avoid certain problems before you export. Also, there is an advantage to seeing the camera motion path on a free camera that's invisible on a parented one. And, this script could easily be adapted to remove parenting or auto-orientation on any layer.

http://www.urbanspaceman.net/shared/AEs ... raBake.jsx

(ps. there is no error checking in the script, so if you don't highlight the camera it just quits at the moment)
redforty
Posts: 5
Joined: March 1st, 2007, 4:32 pm

THIS IS AWESOME!!!

Thank you!!! <333
sneather
Posts: 3
Joined: April 11th, 2008, 7:24 pm

I couldn't have found this script at a more important time! However, I'm having difficulties making it work correctly. I'm using AE 6.5, and trying to get my camera data ported into Electric Image 5.5. I need this bake script because my AE camera is the child of an animated null, and the 3DMation MoCon script doesn't handle that properly into EIAS. But if I use the bake script first, and follow the prompt to remove the camera auto orientation, EIAS says there's no data to import, at all. When I leave the orientation on, I get better results, but still not accurate to the original AE move. Something is getting lost in the translation.

Can anyone please lend some advice???

Cheers!
urbanspaceman
Posts: 54
Joined: December 12th, 2007, 9:56 am
Location: London
Contact:

Because I'm not familiar with EI, I'm not completely clear. Are you saying you are using my script, and then MoCon to go to EI? Does switching from Orientation to Reference camera in MoCon make a difference?

All I did in this script was to put the point of interest in the same spot as the camera position, and this nullifies auto-orientation, basically. In AE 6.5 there is no command for switching the POI off, so that's the next best thing. I only put a prompt in there to instruct you to turn it off because it will probably be best to get rid of it, as it's not needed. But it's probably okay to leave it on, as long as you don't make further changes to the camera.
sneather
Posts: 3
Joined: April 11th, 2008, 7:24 pm

Yes. MoCon isn't able to handle child cameras (or objects) when exporting data (.obm) to EIAS. So, your script seemed to be the perfect solution, and from inside AE, it looks like it is. My baked camera moves juts like it did when it was attached to a null. But, there is something with the orientation which I can't figure out. I've tried exporting with MoCon in both orientation, and reference, and I've also tried it with the auto orientation on and off. Still, once in EIAS, the camera seems to move fine, but the reference is not aligned. Strange.

Thanks so much for the reply, though, and I hope this thread might lead to someone else who is more familiar with AE to EIAS possibly helping out.

Cheers.
urbanspaceman
Posts: 54
Joined: December 12th, 2007, 9:56 am
Location: London
Contact:

Part of the reason to bake the camera is to dispense with a reference (target, Point of Interest, etc) all together. So if you ran my script, the idea would be to not use a reference in EI. If you had reference camera selected in MoCon, my guess (not knowing EI specifically) is that it would introduce a target, which might screw up the baked camera which is supposed to be a "free" camera not pointing at any reference. You certainly wouldn't want MoCon to read the POI from After Effects and bring it into EI after running my script...it could cause havoc because I placed the POI in the same spot as the focal point of the camera...if moved slightly the camera could rotate wildly in unpredictable directions. That's the reason for the prompt to turn it off and get rid of it.

In most cases, you want to stick with one method for rotating the camera. My bake script is for the orientation method, not to be mixed with the reference method.
sneather
Posts: 3
Joined: April 11th, 2008, 7:24 pm

Thanks. I'll try it again, with the orientation method. I also just installed AE CS3, and the newest 3DMation script. Perhaps, that will take care of the issue (fingers crossed).
dflamholc
Posts: 1
Joined: August 11th, 2009, 8:34 am

Hi all,

I'm really pleased to find this thread and the script, but I'm having some trouble with it at the same time.

When using it with Andrew Kramer's SureTarget 1.5.1, the parented camera seems to have a problem with 180 degrees rotation and sometimes caps the rotation at 43.3 degrees. Has anyone had similar issues?

Just keen to see if there are any updated tips on this...

Thanks to all above!

cheers/ david
macattack
Posts: 5
Joined: August 5th, 2009, 3:57 pm

Is this script complete?

from above: http://www.urbanspaceman.net/shared/AEs ... raBake.jsx

I can't seem to find values for some things (v, u, w) and the for loop seems incomplete. Maybe just because I'm new to JavaScript. But I could really use a script to bake animation.

I reformatted it and removed a rogue double-quotation mark:

Code: Select all

//****************************** SUBROUTINES 
function Bake(theComp, propBeingCopied, propBeingWritten) 
{
	StartBake=theComp.workAreaStart; 
	EndBake=StartBake+theComp.workAreaDuration; 
	NextFrame=1/theComp.frameRate; 
	for (var i=StartBake; i .0005)
	{c = -Math.atan2(v[0],u[0]);
		a = -Math.atan2(w[1],w[2]);
		}
	else{a = Math.atan2(u[1],v[1]);c = 0;
		}
	[radians_to_degrees(a),radians_to_degrees(b),radians_to_degrees(c)]; 
	theComp.layers.addCamera("CameraCopy 2",[0,0]).startTime=0; 
	CamCopy02=theComp.layer(1); 
	CamCopy02.position.expression="thisComp.layer('CameraCopy 1').position"; 
	CamCopy02.pointOfInterest.expression="position"; 
	CamCopy02.rotationX.expression="thisComp.layer('CameraCopy 1').orientation[0]"; 
	CamCopy02.rotationY.expression="thisComp.layer('CameraCopy 1').orientation[1]"; 
	CamCopy02.rotation.expression="thisComp.layer('CameraCopy 1').orientation[2]"; 
	CamCopy02.zoom.expression="this_comp.layer("+"\'"+CameraName+"\'"+").zoom"; 
	theComp.layers.addCamera("Baked Camera",[0,0]).startTime=0; 
	CamCopy03=theComp.layer(1); Bake(theComp, theComp.layer(2).position, CamCopy03.position); 
	CamCopy03.pointOfInterest.expression="position"; 
	Bake(theComp, theComp.layer(2).rotationX, CamCopy03.rotationX); 
	Bake(theComp, theComp.layer(2).rotationY, CamCopy03.rotationY); 
	Bake(theComp, theComp.layer(2).rotation, CamCopy03.rotation); 
	Bake(theComp, theComp.layer(2).zoom, CamCopy03.zoom); 
	theComp.layer(3).remove(); theComp.layer(2).remove(); 
	alert("Turn off the auto-orientation on the baked camera"); 
	//****************************** END 
vit.fit
Posts: 3
Joined: September 30th, 2008, 10:33 pm

Hi
Script perfect!!
but sometimes i have a trouble with YRotation when i use Null as parent for camera.
script worked only when YRotation <= 66,1 degree
ZRotation worked any degree
maybe someone knows answer
thanks
caltd
Posts: 1
Joined: December 16th, 2009, 4:10 pm

Just wanted to say thanks for the script - much appreciated & very useful!

:mrgreen:
Post Reply