Entries in flying (1)

Wednesday
Jul062016

MIR Procedural Flight

This AE project file contains a procedural flight camera for Trapcode Mir. Note that these expressions are not mathematically correct, they just give an appearance of a flying camera.

In order to achieve flight motion, firstly the Scroll Y parameter has an expression (time*1000) so it appears the landscape is moving towards the camera. To get motion sideways there is an expression on Scroll X as well. This is more complex:

seedRandom(2002); // change this to change the flight path
// smooth the scroll willge to avoid jumps
sum = 0;
for(i=-4; i<5; i++) {
sum += effect("Mir")("Scroll X").wiggle(0.2, 700, 1, 0.5, time +i*0.1);
}
sum/10

 

Simply changing the seedRandom value here will change the entire flight path. The rest of the expression is a smoothing window to smooth out the result of a wiggle expression. The wiggle expression creates the randomness and uses the aforementioned random seed to do so.

To get the banking effect (roll of camera) an expression is used on the Camera Z Rotation:

// smooth the velicity values to avoid jumps
sum = 0;
for(i=-4; i<5; i++) {
sum += thisComp.layer("MIR").effect("Mir")("Scroll X").velocityAtTime(time +1 +i*0.1);
}
-0.1*sum/10   // change the value (0.1) to change the amount of banking

Here we are again smoothing the alredy smoothed values of Scroll X. Lots of smoothing is needed! By sampling the velocity of the Scroll X motion we get an approximation of the banking needed for such a turn. One second is added to the sampling time so that the banking happens first, before the actual turn.

Lastly there is an expression on for the sideways direction of the camera (yaw). This is so that the camera aims in the direction of flight. The expression is:

// smooth the velicity values to avoid jumps
sum = 0;
for(i=-4; i<5; i++) {
sum += thisComp.layer("MIR").effect("Mir")("Scroll X").velocityAtTime(time +i*0.1);
}
-0.03*sum/10

This expression is similar to the one above but doesn't add any delay to the sampling. As soon as the turn starts, the direction is corrected.

Download Adobe After Effects CS6 project file: MIR_Procedural_Flight_CS6.aep