After Effects

Javascript number to number with commas trick

Came across this simple function that works nice in After Effects:

function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }

Now you can have rolling counters by just adding a custom slider control and keyframing the start and end values.

After Effects Expression Tips

Here are some of the latest tricks I have been playing around with, especially useful with Particular.

Tip: Add a ‘layer for motion’ selector for your particular emitter and make your keyframing easier.

Add an Effects>Expression Controls>Layer Control to the layer and name it ‘layerForMotion’

Add these expressions to the particular emmitter properties:

In Position XY:

try {
 m= effect("layerForMotion")("Layer").transform.position;
 [m[0],m[1]];
 }catch(err){
 effect("Particular")("Position XY");
 }

In Position Z:

try {
 m= effect("layerForMotion")("Layer").transform.position;
 m[2];
 }catch(err){
 effect("Particular")("Position Z");
 }

Now just select the layer that you want to control the emmitter. Be sure to convert that layer to 3D before selecting.

Tip:Adjust the amount of particles emitted based on the velocity (speed) of the emitter.

[UPDATE – also, have it stop emitting when it stops.  No need to keyframe ‘0’ ]
This is helpful when you get thin or clumpy areas of particles when you are moving your emitter at various speeds.
Add the following expression to the Particular ‘particles/sec’ property:

//specify the where the motion for the emitter is coming from
 m=effect("layerForMotion")("Layer").transform.position
 //get the magnitude of the position change (ie speed) and combine with attribute value you set or keyframed
 length(m.velocityAtTime(time))*effect("Particular")("Particles/sec")/2000;
 //omit this if you don't what it to stop emitting when it stops moving
 if (m==0){
 0; //stop emitting if no change in position
 }

Now you will get a nice even stream no matter how you zip the emitter around, and it will stop emitting when standing still so no more clusters!

Maya to AfterEffects… tips, tricks.

Can’t remember the process for succesfully getting Maya camera and locators into AfterEffects?  Here’s what I’ve written down so I won’t forget…
Maya scenes need to be transformed in order to appear in AE default space (where center is 960,540):
Scale = 100
TX  =  960
TY = -540

How Cameras relate…
Default AE 50mm camera = Maya 50mm with Z = 26.6666
Default AE 35mm camera = Maya 35mm with Z = 18.6666

So, for basic setup create a Maya 35mm camera at z = 18.666.  Layout for this view (it will match the default AE 3D setup).  When ready to export… bake animations.  Then group elements and transform group with above scale and translate settings.
Import into AE and delete the ‘group’ node which will be the parent to all the elements.  Their transforms will now be set up to match AE world with center @ 960×540 (***This assumes you want to create a 1920 x 1080 comp.  Don’t for get to set your resolution in  Maya to match this resolution!)

If it is more convenient to do the transform in AE only…

  1. Import elements.
  2. Create a null.  Set Position to 0,0,0
  3. Parent elements to null.
  4. Set null position to 960,540,0
  5. Then scale null to 10,000.
  6. Delete null.

Camera and elements will now be in AE default 3D space.

[UPDATE]

[UPDATE AGAIN — possibly ignore all this… i think I found my mistake!]

Maya 35mm camera seems to be off when brought into AE… changing angle of view of AE Camera to 66degrees (or change to film size to 36mm) and that should help slippage off-center.

Another way to calculate what the AE Camera needs to match the Maya camera is to take the Maya Camera’s ‘Camera Aperture’ X value and convert that to mm (mult by 25.4 to get millimeters).  Then use that value for AE Camera’s film size.  I think the problem is that maya has a default ‘user’ film gate that is a 1.5:1 ratio, which is going to be different then your AE 1.78 comp ratio.