MtorSlim Ribbox Scripting 6

Introduction

The scripts on this page present a rough and ready way of saving
xyz data for an animated particle system. As individual particles move within
a scene their positions are saved into separate text (data) files. Particles
emitted early in an animation have data files that record more xyz positions
than particles generated later in the animation. The script assumes that particles
are not deleted from the system.

At the end of the animation the
data from the individual data files are consolidated into a single rib file. In
effect the scripts shown on this page bake-out particle trajectories.
In this example, the xys data is used to describe RenderMan curves. Figure 1 shows
a bundle of flow lines (curves) formed by particles striking a sphere.

Breakdown

On the first frame of a particle animation the ribbox script, listing 1, deletes
the data files from a previous baking run. This is necessary because
the data in the (particle) text files is appended and as such we do not want "new"
data combined with "old" data.

On the last frame of an animation the data previously saved into individual particle
files is consolidated by an external TCL script, listing 2, into a single
rib archive that describes a series of curves. The data could be re-purposed to
describe almost anything - blobby flow lines for example.

Figure 2 shows a 30 frame animation of the curves rendered with the sparky
shader - listing 3. The shader progressively "moves" a patch of opacity along
otherwise transparent curves. Sparky assumes the start and end of each flow line
spans an "age" of 0.0 to 1.0. Of course this is wrong because the shorter lines
represent the trajectories of young particles. Thus, the very
short curves may only span an age of 0.9 to 1.0.

It is left to the reader to figure out a technique whereby sparky can apply a
"age" compensation to a curve it is shading. Hint: name each curve ie.

Attribute "identifier" "name" ["a_number"]

with an integer that matches its number of data points. A shader can querry the
name of the object to which it is "attached" ie.

attribute("identifier:name", name)

Sparky should be able to use the number to apply a compensation factor to the age.
Refer to
Surface Names & Ray Names for more information.