Mtor
|
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.
|
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 1
2
3
4), 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.
|
figure 3 |
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. set numExt [format %0.4d [expr (($n + $F) % 24)]] append ribout " ReadArchive \"PATH_TO_PREBAKES.$numExt.rib\"\n" 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. |
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.
|
|
A ribbox containing the (edited) text of listing 2 should be attached
to a particle system. The renderer can be turned off using RenderMan Globals->Spool->Job Setup
Running the particle animation will generate a number of
text files named particle.0000.rib, particle.0001.rib etc. A typical
data file will contain listings of xyz positions, for example,
0.0312244 0.00145994 -0.00867358 0.143521 0.00671052 -0.0398675 0.255817 0.0119611 -0.0710615 0.368114 0.0172117 -0.102255 0.48041 0.0224623 -0.133449 |
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,
Basis "b-spline" 1 "b-spline" 1 Curves "cubic" [5] "nonperiodic" "P" [ 0.0312244 0.00145994 -0.00867358 0.143521 0.00671052 -0.0398675 0.255817 0.0119611 -0.0710615 0.368114 0.0172117 -0.102255 0.48041 0.0224623 -0.133449 ] "constantwidth" [0.05]
The next listing is a tcl script that converts the xyz's in
the data files into a rib file that defines curves whose CV's pass through
each particle xyz positions.
|
|
figure 5 |
Ensure the items shown in blue conform to your directories.
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 - animated shader (see figure 1) |
Example 4 - converting the data to blobbies
Figures 7, 8 and 9 are based on the data that produced figure 5.
if {[expr rand()] > 0.5} { lappend data $xyz } |
figure 7 - see ribbox listing 6 |
figure 8 - see ribbox listing 7 |
figure 9 - see ribbox listing 7 |
Ensure the items shown in blue conform to your directories. |
|
© 2002- Malcolm Kesson. All rights reserved.