11.07.2015 Views

First Steps - RealFlow Tutorials.

First Steps - RealFlow Tutorials.

First Steps - RealFlow Tutorials.

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Author: NL TeamPublication: 17/06/2010Category: ExpressionsType: TutorialExpressions / Tutorial<strong>First</strong> <strong>Steps</strong>1. <strong>First</strong> <strong>Steps</strong>You don´t need to do very much for to create expressions. <strong>First</strong>, you need a parameter to be controlled byan expression. You select the desired setting from the Node Params window, right-click on the appropriatevalue, and select "Open curve". Now you can see the node and the associated value, but currently nocurve, because you don´t have any keys.Below the curve window you can see a line with a "+" button, an input field, and an "Insert" button. With "+"you can easily merge the expression with an existing curve. The input field contains the expression youhave to enter and "Insert" provides the lists with all available functions and variables.A very important issue concerning expressions is time. In <strong>RealFlow</strong>, time is either measured in frames or inthe standard time code formathh : mm : ss (hours : minutes : seconds)By default the time line in the GUI and the curve editor use frames. If you want to use time with expressionsthen you have to use them in the form of variables. A variable is a placeholder that will be "filled" withvalues. For frames you have to use the variable "f" and for time code it´s "t". With expressions, "f" or "t" arereplaced with the current frame/time from the timeline. This happens automatically so you don´t have tothink about it. You can also create expressions with both frame and time dependency:sin(t*10)*f/ 0The result of the given expression sin(t*10)*f/20tutorials.realflow.com - <strong>First</strong> <strong>Steps</strong> Page 1/3


With frames the curves show a very important difference: they look jagged and aliased, because framesonly recognise integer values and the space between is interpolated by <strong>RealFlow</strong>. With time dependency,the curves are drawn smoothly. Fortunately it´s not difficult to get rid of these jagged curves. Simply multiplyframes by time:(t*fps)Frame dependencies create stepped curves and time dependencies are used to smooth themExpressions are not limited to frames or the time code. You can also use numbers, or even animatedattributes from other nodes or properties, for example:sin(5)cos(Cube01.rotation_X)Another example:You want to create a regular up-and-down movement of an object, lets say an emitter. The first thing youhave to consider is the appropriate function for this task. By looking at various mathematical functions you´llsee that either the sine or the cosine functions are optimal, because they already show this wave-likebehaviour. The sine curve is even better, as it starts with 0.0. All functions like sine, hyperbolic cosine,square root etc. only need one parameter to work correctly. That´s why they are called unary functions.The next thing you need is a curve from the emitter´s vertical position. Please note that this can either bethe Y or the Z axis, depending on your preferences (see page 51). Here, we´ll assume that Y representsthe vertical axis. Go to the emitter´s Node Params:Node Params > Node > Position > YRight-click on the value and choose "Open curve". Now the curve editor is visible, but there´s no curve orgraph right now, because we´ve only prepared the emitter´s position attribute so far. Place the cursor intothe expression field and entersin(t)Confirm your entry with the Return key and have a look at the Graph window. The expression sin(t) worksthis way: for each frame, <strong>RealFlow</strong> calculates the appropriate sine value and applies it automatically to theY position of the emitter. Nevertheless, the result might not be what you might expected. You surelyawaited more "hills and valleys", didn´t you? What you can see is just the basic sine function in dependencyon the current time. With simple operations you´re able to create a denser or wider curve, higher peaks,and a positive or negative offset.Here are a few example operations to modify the sine curve and the results:tutorials.realflow.com - <strong>First</strong> <strong>Steps</strong> Page 2/3


sin(t*5) Sine curve compressed along the X axissin(t/5) Sine curve stretched along the X axissin(t+5) Shift the curve 5 units to the right along the X axis (horizontally)sin(t-5) Shift the curve 5 units to the left along the X axis (horizontally)sin(t)+5 Shift the curve 5 units up along the Y axis (vertically)sin(t)-5 Shift the curve 5 units down along the Y axis (vertically)sin(t)*5 Stretch the curve 5 times along the Y axis ("higher" curve)sin(t)/5 Flatten the curve to one fifth in Y direction ("flat" curve)It´s also possible to combine functions with each other. There´s no rule that expressions must consist ofjust a single function &ndash; infact anything goes as long as it follows the fundamental mathematical rules:(sin(t) + cos(t)) / (cos(t) &ndash; sin(t))This means that it´s not possible to perform division by 0 or extract roots from negative numbers, forexample. Division and multiplication have a higher priority than addition and subtraction. If you want toreverse this rule, brackets are needed, as you can see from the term above. When you´re working withoperations like addition or multiplication, you always need two arguments. These functions are hence calledbinary functions, as seen here: value1 + value2 or value1Now that you´ve entered the expression you´re already done! Close or collapse the curve editor, press theplayback button from Timeline Control, and watch the emitter´s perfectly regular motion. Of course it´spossible to create this kind of motion curve by traditional means, but it would be disproportionately difficult.So don´t be afraid of expressions: just experiment a little and you´ll soon find out that they´re flexible,versatile and easy to use.Motion path in vertical direction with sin(t)*cos(t*2)tutorials.realflow.com - <strong>First</strong> <strong>Steps</strong> Page 3/3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!