Scripted Nodes

Scripts can handle different tasks and therefore it is necessary to distinguish a few types. Within RealFlow there are three fundamental types:

  1. Batch scripts
  2. Simulation Flow scripts (aka "events scripts")
  3. Custom node scripts

Each of these types has its own editor window. Even if the windows appear different, they have some important similarities. The visual appearance of the scripting windows is controlled by RealFlow’s preferences, where you can adjust things like font type, syntax colours and folders for storing your programs:

Menu bar > File > Preferences > Script (Windows/Linux)

Menu bar > RealFlow > Preferences > Script (OS X)

Syntax highlighting is another important similarity. Whenever RealFlow detects an instruction or known function in your code, it will be coloured. For all scripting windows, RealFlow provides auto completion. This function helps you to complete a statement with the help of a drop-down menu. It appears when parts of a command are recognized and allows you to choose the desired function.

How to Apply Scripted Nodes?

When you have a close look at the available emitters, daemons, and RealWave modifiers, you will notice options like “Custom” or “Scripted”. This means that you have the option to write your own fluid emitters, apply your own forces, and calculate your own RealWave surface displacements. To open the appropriate editor, look for:

Emitter > Node Params > Particles > Type > Custom

Available daemons > Scripted

RealWave node > Right mouse button menu > Add Wave > Scripted 

 

These different nodes have one thing in common: the “Edit” button. By clicking on this button, a new script editor will be opened which contains specific functions for each node type – it is not possible to mix or change these functions. For example, the updateWave( vertices, initPositions ) function should not be used inside a scripted daemon’s editor and vice versa. The scripted emitter is not a type of its own, like scripted daemons. It is a property, or better, a particle type that is available with any emitter. You can choose from “Gas”, “Dumb”, “Elastic”, “Liquid” – and “Custom”: 

Node Params > Particles > Type > Custom

Here you can calculate the forces between particles and apply them to the fluid. For this purpose there is the computeInternalForces( emitter ) function. Since forces between particles only affect the fluid and nothing else, this option is strictly limited to emitters. Scripted daemons, on the other hand, can either affect particles and rigid bodies. The difference is that you are going to introduce external forces which can act like RealFlow’s standard forces, for example gravity. With a scripted daemon you can model your own force fields, such as vortices or falloffs. The great advantage with this type is that they can be treated like any other daemon. In other words: you can make them exclusive to certain nodes or (de-)activate them at a certain point in time, for example. Scripted RealWave modifiers are also possible, and you are free to perform calculations for all three axes. This extension helps you to create completely customised wave types. One of the best applications of scripted waves is the translation of an image’s grey scale values into height information. With this method you are able to create wave simulations out of a sequence of images.

The number of scripted nodes is not restricted and the only limitation affects RealWave, because you can only have one object per scene, but you can (at least theoretically) apply as many scripted modifiers as you want to the surface. Scripted emitters will work and interact with all the other solvers and particles. They can also be affected by both scripted and built-in daemons.