Building Vectors

In RealFlow vectors are an important data type. All parameters with three values can be considered and described as vectors – even RGB colours. They also consist of a trio of values and therefore each RGB colour can be treated as vector. The most important vectors in RealFlow are:

  • Velocity
  • Position
  • Rotation
  • Forces

If you want to manipulate the individual X, Y and Z values you first have to deconstruct the original vector. The instruction for this operation is get[axis]() and is appended to the appropriate vector as seen in the examples before. With this operation a vector is split into its scalar components and can now be used for further vector calculations, e.g. multiplication with a scalar:

new_velocity_x = velocity_x * 0.5
new_velocity_y = velocity_y * 1.3
new_velocity_z = velocity_z * 0.7

 

To use these values again, e.g. for setting the new velocity, they have to be assembled to a completely new vector. This vector should also be stored into a variable:

new_velocity_vector = Vector.new(new_velocity_x, new_velocity_y, new_velocity_z)

 

The key instruction is:

Vector.new(float, float, float)

 

It expects three floating numbers (called an argument) and these values are represented by the new_velocity_[axis] variables. RealFlow puts everything together to create a new vector that can be applied to the particle in the next step. You will soon learn how to set and apply such a vector or other new parameters to a particle or node. A vector does not necessarily need three completely new values and you can also mix different types. The following example contains a fixed float, a new result, and an existing vector from the particle’s original velocity. 

new_velocity = Vector.new(1.0, new_velocity_y, velocity_z)

 

You are also able to perform calculations directly within the new vector’s argument. That is a very good method to shorten your scripts, unless you have to use the new_velocity_[axis] values somewhere else in your program. With this notation you can skip the assignment of three variables.

new_velocity = Vector.new(velocity_x * 0.5, velocity_y / 2, velocity_z + 1.4)

 

A RealFlow vector always consists of three values, regardless whether you need them for your calculations or not. If there are components you do not need, you can set the appropriate value(s) to 0.0:

new_height = Vector.new(0.0, height * 2.5, 0.0)

 

Â