Expressions

Expressions are the most convenient way to automate courses of motions, and regular or repetitive animations without scripting knowledge. With expressions you do not have to worry about keys, because you simply enter a formula and can immediately see the results. Expressions can also be made event-based: you define a certain condition to switch on a certain feature, e.g. rigid body dynamics. Such a condition could either be a particular frame or the position of a null object, to name but a few.

 

 

RealFlow offers another feature: the combination of expressions and key-based curves. Combining key-based curves and expressions can help you in many situations: for example, when you want to add some noise to an animation or create secondary motions within a higher-ranking movement. A click on the “+” button, next to an expression, will do the job for you. The result is a completely new curve, showing characteristics of the animation and the expression – a hybrid type.

 

In order to apply an expression, right-click on a parameter's name in the "Node Params" panel and choose "Edit Curve...". Now enter an expression to the empty field at the "Curve Editor" panel's bottom, but add a leading "=" character, e.g. =sin(t*5)

Available Functions and Operators

The "Insert" button provides several submenus:

 

 

Unary functionsThe available mathematic functions, e.g. sine, cosine, square root, etc.
Binary functionsThe available mathematic operators: +, -, >, <, etc.
Tertiary functionsThe "if" condition.
I varsThe time-based variables t (seconds), frames, and fps.
D varsHere you can find lists with all parameters of the scene's nodes. You can couple them with an expression to trigger a certain event.
ConstantsHere you can find a few important constants, e.g. Pi or e.

Examples and Useful Expressions

Here are several useful expressions for your daily work - you can substitute the factors with your own values.

 

Basic sine curvesin(t)
Basic cosine curvecos(t)
Create five times more ups and downssin(t*5) | cos(t*5)
Create ups and downs between -3.0 and 3.03*sin(t) | 3*cos(t)
Shift the entire sine curve by 1.5 secondssin(1.5+t)
Switch a node's simulation state from "Inactive" to "Active" at frame 50if(f>49,1,0)
Set an emitter's "Speed" value from 2.0 to 0.0 when a sphere's X position is greater than 1.0if(sphere01.position.x>1.0,0.0,2.0)
Create a random value between 0.0 and 2.0rnd(2.0)
Add noise between 0.0 and 1.0 to a sine curvesin(t)+rnd(1.0)
Create circular motions around the vertical axis (two expressions!)X position: sin(t*3) and Z|Y position: cos(t*3)
Activate an object's "Active rigid body" state at t = 2.5 secondsif(t=2.5,1,0)
Switch from "Active rigid body" to "Passive rigid body" at frame 10if(f>9,2,1)
Add a vertical offset of 2.0 to a sine curve2+sin(t)
Create a falling exponential curve starting at 5.0 (frame 0)5*exp(-t)
Make the exponential curve decrease faster5*exp(-t*3)
Animate an emitter's rotation around an axis between -30° and 30°sin(t)*15
Animate an emitter's rotation around an axis between 60° and 80°70+sin(t)*10
Randomize the rotation from above between 60°- 65° and 75°- 80°70+sin(t)*(5+rnd(5))
Create a zig-zag curve with many repetitionstan(sin(t*10))
Create a smooth acceleration effect with a position parameter expressionsinh(t)