haniblog

Icon

Flame Artist by day. Proud Dad by, uhm, the rest of the time. Lover of everything Apple. Hater of everything Microsoft.

A Beginner’s Guide

I decided to write a quick and easy guide on how to start using Expressions in Flame.

Scope

Expressions are incredibly powerful tools in animation. They can be simple linking functions or complex camera positioning sequences. The aim of this guide is to get started and offer up some basic everyday examples. Click on any of the images for a better view.

Linking

As mentioned above, linking are the simplest use of expressions: axes linking to axes or image to 3d object transparencies. Here’s an example of linking one axis to another. To mirror what axis1 does, tap on axis2 in the animation view, then tap the Expr button (or hit the [ hotkey) and type:

axis1

That should create a live link between the two axes. axis2 should have a little [e] icon next to it to indicate that the expression you entered is valid and live. It’s as simple as that.

Adjusting the link

Sometimes you need to adjust the link to follow the animation, but with an adjustment. If I wanted my link axis to follow the main animation, but half the X, Y or Z values, my expression would be:

axis1.position.x / 2

That is a live link to whatever axis1 does in 3D space, but only half the value. As you can see from the next graphic, axis1.position.x is 100 but axis2.position.x is 50. The cool thing is you can see what axis2 does as you adjust axis1!

If… then… else

Sometimes you want to limit certain linked animations. Let’s say that your expression should look at axis1 and if it goes beyond a certain value, say 50, then the animation should be half that of axis1, but any more than that then it should stick at a value. As the following image shows the expression for that would be:

if ( axis1.position.x > 50, axis.position.x / 2, 50 )

And here’s the breakdown. If statements are structured thus: If a value is true then do this; otherwise do this. So a verbose explanation of the expression above would be: If axis1’s X position is greater than 50, then axis2’s position is half of axis1’s. Otherwise let axis2’s position equal to 50 until it becomes greater.

Frame and Eval

frame is a powerful function as it let’s you select animations in time, much like manually manipulating animation curves in the Tracks view. Let’s say you want axis2 to follow whatever axis1 does, but 50 frames behind. The expression for that would be:

eval( axis1, frame – 50 )

The eval function is short for evaluate and the expression in english would be: look at what axis1 did 50 frames ago.

Noise

Let’s say you’d like to apply some camera shake to an axis. A powerful way of applying this is to use the noise function in expressions. That function adds a random value to any channel you assign it to: position, rotation, scale, etc. To avoid the same values on every position curve it’s better to use a higher function called noise3. This will add 3 random values to the X, Y and Z curves and will give a better result as you can see in the following image. The frame variable basically means: make sure every frame has a random value.

The values produced out of the noise function are usually not of the scale we need as they are between 0 and 1. To use it properly, you would need to multiply the result. In the next example I added a multiple of 50 to the noise value to make a difference in my animation, by entering in the following expression:

noise3 (frame) * 50

You can see that even though the randomness of the animation is the same, the Y value in the animation channel jumps from 1 to 50.

Eval again

But let’s say that the animation is far too jittery and we’d need to slow down the randomness by a third. That’s where the eval operator comes in:

eval ( noise3 (frame) * 50, frame / 3 )

In english that would mean: take the randomness, multiply it by 50 and then slow it down by a third. And it should look like this.

Ramping up and down

Camera shake is all well and good, but what if you have to ramp it up or down? Flame’s expression system let’s you multiply animation curves to produce exactly that. I usually use a dummy axis for all of my basic expression needs (axis2 in this case). I would assign a noise3 function to the position channel and a ramp up or down animation to the rotation curve, as you can see in the next illustration.

So if I wanted axis1’s camera shake to ramp up and down according to my axis2’s rotation curve, the expression would be:

axis2.position * axis2.rotation.x

And this is what would happen to my animation:

Again, this is a live link. If axis2’s rotation x value increases from 0 to 2 halfway and then back to 0, it would multiply the camera shake by those values exactly. If I change the ramping from 1 to 0 and back to 1, then the animation would be: extreme shake to stillness and back again as illustrated here:

More to come

I hope this introductory guide helped and I will add more complex guides in expressions and particle animations along with real world examples in the future so stay tuned!

Hi. I'm Hani and this is my blog. I also have some photos on Flickr, bookmarks on Delicious, tweets on Twitter and generalities on Facebook as well. Most of the time I can be found at Prime Focus in London, crafting commericals using Flame.