Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As you can see the current position is added to the list with each frame, as well as the current time. That is necessary because after the simulation you do not have any time information and so everything has to be stored temporarily. Time is needed to properly set a key. The rest is pretty straightforward.

 

Image Added

The motion path of a sphere will be translated into animation keys.

 

All keys will be written after the simulation, because this has some advantages: imagine you have to write out the position data to a file. This could slow down RealFlow, since the script has to open the output file, write the data and close the file for every single frame! With the method outlined here, everything is written in one pass after the last simulated frame. In the last part you can find the functions for setting the keys and assigning the information from the different lists. Everything has to be done for each component of the position vectors: X, Y and Z. The code snippet here shows the process for a single axis. A counter is needed to read out the stored time information by the list’s index:

...

The final statement prints a key which will be visible in the "Curve Editor". Each statement with an axis-dependent variable has to be repeated for each of the position vector’s component to record the entire movement. Instead of KEY_TYPE_BEZIER you can, of course, use other types: KEY_TYPE_TCB, KEY_TYPE_LINEAR or KEY_TYPE_STEPPED.  Another thing you should be careful with is this notation:

...

Please mind the dot between “Position” and “X”!

 

Image Added

An enlarged section of the recorded curves shows individual keys.