RfM
|
Topics
|
Introduction
This tutorial presents examples of scripts intended for use at
Mel insertion points with Pixar's RenderMan for Maya plugin. For example, the
Mel proc,
As touched upon in the tutorial
RfM: Introduction to Ri Scripting, Pixar's RenderMan for Maya adds many custom Mel
procs to Maya's scripting environment. Most of the sample scripts in this tutorial
call the very useful
string $shape = `rman ctxGetObject`; Most of the sample Pre-Shape MEL scripts set a number of RenderMan visibility attributes to ensure the object to which a script is "attached" is not seen in the final render ie. RiAttribute "visibility" "int camera" 0; RiAttribute "visibility" "int transmission" 0; RiAttribute "visibility" "int diffuse" 0; RiAttribute "visibility" "int specular" 0; RiAttribute "visibility" "int photon" 0; The reader should also refer to the tutorial "Mel: Secondary Geometry". It provides samples of code that are similar to those presented in this tutorial. Sourcing a Sample ScriptThe sample scripts presented in this tutorial can be sourced in two ways. If the reader has followed the suggestions in the tutorial, RfM:Setup for Mel, Rman and Slim. then a Mel script, or scripts, can be saved to, maya/projects/RfM_mel However, when testing a sample script on an ad-hoc basis it is probably best to copy and paste its text into Maya's script editor window and manually source it (by clicking on the enter key on the numeric keypad). |
Using a Polymesh as a Proxy Surface for Archives |
|
|
Using Particles as Proxy Objects |
Listing 3 (particleArchiveRI.mel)
|
Using Particles to Generate CurvesSee also, "user interface for particles generating curve archives" |
|
|
This examaple uses a Mel and a python script (listings 5 and 6) to bake an
archive rib file containing the xyz coordinates of an animated particle system.
The baked archive file contains a number of RenderMan Curves statements - one
for each particle created by an emitter. The curves, in effect, correspond to
the trajectories traced by the particles during an animation. Unlike the previous
examples, the scripts in this section can not be used directly to render a sequence
of images. However, the pre-baked rib file generated by the scripts shown in
this section can, of course, be used as a digital asset in an animation.
vector $data[][];
Consequently, listing 4 is forced to use the very inefficient technique of
appending particle positions to an array of strings - refer to the proc
named |
Listing 4 (particlesToCurvesRI.mel [test version])
|
The Mel script shown in listing 5 is a simplified version of listing 4 because
it delegates most of the heavy lifting to a "sister" python script - listing 6.
Other than ensuring the python script is used to accumulate the particle positional
data into a cache, it is a matter of personal preference how the workload is
"shared" between the Mel script and its associated python script.
The Mel script handles step 1 while steps 2, 3 and 4 are handled by the python script. |
Listing 5 (particlesToCurvesRI.mel)
|
Listing 6 (particlesToCurvesRI.py)
|
Running the Scripts
Following the suggestions at the beginning of this tutorial the
Mel code in listing 5 should be saved as maya/projects/RfM_mel
The python code in listing 6 should be saved as maya/projects/RfM_python Notes on how to ensure that Maya can source the users custom python scripts can be found in the tutorial "Maya: Setup for Python". In the Pre-Shape Mel text field the reader should enter, particlesToCurvesRI(1, 0.02); The start and stop frames of a animation must be set in the Render Setting dialog box. Since the scripts will be used to write a pre-baked rib file there is no need to do batch rendering. Instead, enter this command in the Mel script editor. rman genrib
This will cause the particle simulation to run without any images being rendered.
The pre-baked rib file will be written to the current projects Hider "stochastic" "int sigma" [1] "float sigmablur" [1.0] Attribute "dice" "hair" [1] Attribute "stochastic" "int sigma" [1] |
Listing 7 (curves_test.rib)
|
© 2002- Malcolm Kesson. All rights reserved.