MtorSlim Ribbox Scripting: Maya Particles, Curves & Blobbies

Introduction

This page presents a few ideas relating to the use of Maya particles. The main
purpose of these notes is to show how a particle animation can be "baked". Baking
in this instance means writing the xyz positions of each particle into one
or more (text) data files. Such data can be put to uses other than producing a
"literal" rendering of a particle system.

For example, figure 1 illustrates how particle positional data, when rendered
as RenderMan curves, display the trajectories that were traced by the particles in the
original particle system (figure 2).

The techniques shown on this page rely on the use of slim ribbox's and Tcl scripts.
Example 1 serves as an introduction to the use of a ribbox that querries a particle
system. The actual process of baking particle data is shown in example 2. The
remaining examples demonstrate how the baked data can be used for different
effects.

figure 1 - particle trajectories

figure 2- original particle system

Example 1 - particle queries

Ribbox 1 lists a script that demonstrates the basics of querrying a particle system.
The script would be attached the particles themselves, not to the emittor. As shown
in a variety of ribbox examples (refer to 1234), most MEL commands can be called via the built-in
slim tcl procedure "clientcmd". For example, lines 2, 4 and 10 use MEL commands to
querry the name of the shape node, the number of particles and their individual positions.

getParticleAttr
returns an array of two strings. The built-in procedure "clientcmd" converts the
array to a tcl list. The first item in the list is the name of the shape node.
The xyz position of each particle is used to locate a randomly colored sphere.

The loop, lines 9
to 19, builds an output string that eventually contains a sequence of Rib statements
that will cause prman to render the spheres that will "replace" the actual particles.
The final rib statement, "Opacity 0 0 0", ensures the actual particles are invisible.
Ideally, attribute "mtor invisibility" should be attached to the particles but it
seems "mtor invis" does not work with particles - hence the hack of zero opacity!

Of course, inserting colored spheres as substitutes for the actual
Maya particles is of no importance. However, the script could be
adapted to render rib archives.
For example. the particle number (within the loop) could be used to cycle through a
sequence of, say 25, numbered pre-baked ribs. Incidently, the following script assumes
the pre-baked ribs have numeric extensions from "0000" to "0024". The slim variable $F
is substituted by the frame number.

Figure 4 was produced by replacing lines 16 and 17 of the ribbox
with the code shown above. Many thanks to Bryan Bentley of the Savannah College of
Art and Design for the animation of the teapot that was used to generate 25 pre-baked ribs.

figure 4

Example 2 - baking particle positions

Ribbox listing 2 demonstrates how each particles positional data
can be written (baked) to a series of text files. Each particle has its data saved
to an individual file. Therefore, particles emitted early in an animation have more
xyz positions than particles generated later in the animation.
This is a rough and ready way of recording particle positions but it works quite well
for moderately "light weight" particle systems.

The text shown in red must be edited to correspond to the directory
in which the data files are to be saved.

Example 3 - converting the data to curves

Once the particle data has been written it can be post-processed by
a tcl script, or any other scripting language. Tcl listing 3, for example,
converts the particle data into series of RenderMan curves - contained in
a pre-baked rib file. For example, the 5 sets of xyz's shown above would
define a curve in the following manner,

Before referencing the baked rib file in maya it is best to check it
with a simple rib file - rib listing . For example, in Cutter choose,

Rman Tools->Docs->Single Frame Rib

Figure 5 shows part of a large "woven" set of curves. I grateful to Roberto Huacuja
of the Savannah College of Art and Design for providing me with the particle system
animation that generated the data.

Figure 6 is an animation of a prebaked set of curves rendered with the shader shown
in RSL listing 5. 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