RfM
Python rif_mesh2blobby


return to main index


Code

    Python Rif rif_mesh2blobby.py (as html).



Introduction

The functionality of the python rif presented by this tutorial is very similar to the C++ RifPlugin used in the tutorial "RifPlugin: Mesh2Blobby". The advantage of using python to implement a rif is that the same code will run on Windows, Linux and MacOSX. The advantage of using compiled C++ RifPlugins is that they run faster than python. However, C++ RifPlugins are considerably more difficult to code than their python equivalent.

The rif_mesh2blobby module enables one or more polymesh surfaces to be converted to Blobbies at render-time. For example, figure 1 shows a Maya scene consisting of a distorted poly sphere. Figure 2 shows the objects rendered (occlusion) with and blobby conversion.


Figure 1 - basic mesh


Figure 2 - result of using rif_mesh2blobby.



Applying the Rif in Maya

RfM does not provide a GUI that enables python rifs to be used in an artist friendly way. However, there is a work-around, but it assumes the reader has downloaded the scripts given in the tutorial "RfM 23: Customizing" and has reviewed their use for batch rendering outlined in the tutorial "RfM 22: Batch Rendering and Filtering".


Workflow

1   Select a polymesh object that you wish to be rendered as a blobby.
2   Open the script editor (MEL tab) and execute the following commands,
      addFloatPrimVar("blobby", 1);
      addFloatPrimVar("blob_min", 0.1);
      addFloatPrimVar("blob_max", 0.2);

The first addFloatPrimVar tags the polymesh for conversion to a Blobby. The second and third addFloatPrimVar sets minimum and maximum sizes that will be used by the rif when it randomly scales each blob.
3   To confirm the additional channels have been added go to the Channels tab.



Figure 3


Note the names have each has automatically been given the prefix rmamcF. Their prefixes will ensure the value of each channel will become primvars that can be read by the rif.

4   Execute the following python commands in the script editor (Python tab),

import batch

rifs = ['rif_it','rif_mesh2blobby.Rif(0.3)']
batch.render(1,1, rifs)

The value of 0.3 will be used by the rif if it cannot find the primvar values of blob_min and blob_max, in which case the blobs will be of a uniform size.









© 2002- Malcolm Kesson. All rights reserved.