Mtor
Maya Curves to RenderMan Curves


return to main index

Related Links


 

Introduction

The mtor plugin enables Maya curves to be rendered with prman. mtor identifies a Maya curve as one that should be rendered if it has been assigned an attribute called mtorCurveWidth. The mtorCurveWidth attribute can be assigned via the MTOR->Attribute->Curve Rendering menu (figure 1).

It is often convenient, especially if a number of curves have been created with a MEL script, to assign the mtorCurveWidth attribute from the same script that produced the curves. This tutorial demonstrates how to output Maya curves to prman using MEL scripting.


Adding an Attribute

Lets add the mtorCurveWidth attribute to a very simple (degree 1) Maya curve consisting of a straight line segment.

curve -d 1  -p 0 0 0 -p 0 1 0;

mtorCurveWidth must be added to the shape node of a curve. The curve command returns the name of its parent transformation node. To assign the mtorCurveWidth attribute we must querry the transformation node for the name of its child (curve) shape node ie.

string $shape[] = `listRelatives -s`;

The -s flag means "list the shape nodes". Once the name of the shape node has been obtained, the curve width can be assigned using the MEL addAttr command eg.

addAttr -ln mtorCurveWidth -dv 0.2  -k true $shape[0];

The meaning of the flags are:
-ln "long name"
-dv "default value"
-k "keyable"

Putting these statements together into a simple MEL script we have,

curve -d 1  -p 0 0 0 -p 0 1 0;
string $shape[] = `listRelatives -s`;
addAttr -ln mtorCurveWidth -dv 0.2  -k true $shape[0];
mtor RenderSpool;   // get MTOR to render the scene using prman


Figure 1



Maya CVs - RenderMan CVs

The number of cv's specified by a Mel script may not result in the same number of cv's defined in the corresponding RIB statement. For example, a Maya curve created using this Mel command,

curve -d 1  -p 0 0 0 -p 1 0 0;

would be expressed in a RIB file as,


Curves "linear" [4] "nonperiodic" "P" [0 0 0   0 0 0   1 0 0   1 0 0] "constantwidth" [0.1]

By default, Maya curves are defined in a RIB file as b-spline's,

AttributeBegin 
    Attribute "identifier" "name" ["|curve1|curveShape1"]
    ConcatTransform [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]
    ShadingInterpolation "smooth"
    Basis "b-spline" 1 "b-spline" 1
    Curves "cubic" [9] "nonperiodic" "P" [0 0 0
                     0 0 0 0 0 0 1 1 0 2 -1 0
                     3 1 0 4 -1 0 4 -1 0 4 -1 0] 
           "constantwidth" [0.1]
AttributeEnd

Because b-spline curves must be defined by no less than 4 cv's, mtor will repeat the first and last points when it produces a RIB file. Lets take a look at another example. In Mel we might have a cubic curve defined by 5 cv's,

curve -d 3  -p 0 0 0 -p 1 1 0 -p 2 -1 0 -p 3 1 0 -p 4 -1 0;

The same curve written into a RIB file would look like this,

Curves "cubic" [9] "nonperiodic" "P" [0 0 0
0 0 0   0 0 0   1 1 0   2 -1 0
3 1 0   4 -1 0  4 -1 0  4 -1 0] "constantwidth" [0.1]

In the case of a cubic curve, mtor has repeated the first and last cv's twice. The cv count has gone from 5 to 9. Without this repetition of cv's the curve would not appear to begin and end at the first and last cv. Figure 3 shows a 5 cv curve rendered in red and 9 cv curve rendered in blue. The red "blobs" indicate the locations of the cv's shared by both curves.


Curve Segmentation

The RenderMan Interface Specification allows "attributes" to be bound to each segment or span of a curve. Looking at a curve, so to speak, from the "outside" we define the shape of a curve by,

  • the XYZ values of its control vertices (cv's), and its
  • type




Figure 2



Figure 3

Another tutorial, RiCurves Basics, illustrates how different curve types produce curves that have very different shapes even when using identical cv's.

From the point of view of the renderer, from the "inside" so to speak, a curve consists of a number of segments (spans). For example, figure 4 shows a b-spline curve that consists of 9 cv's (the first and last cv's have been repeated twice). The curve has (cv's - 2) segments and each of them has been assigned a width ie.

Curves "cubic" [9] "nonperiodic" 
       "P" [0 0 0    0 0 0    0 0 0    1 0 0     2 0 0
            3 0 0    4 0 0    4 0 0    4 0 0] 
       # one width for each of the 7 segments
       "width" [0.01  0.1  0.01  0.1  0.01  0.1  0.01]

To make it easier to see the overlaps between the cv's and the segments, the curve is shown as a straight line even though it is, infact, a cubic curve. The RIB file that produced this image can be viewed at curve_segments.rib.

The RenderMan Interface Specification allows any attribute to be assigned to the segments of a curve. Surface color "Cs", for example, can be used to blend colors along the length of a curve, figure 5.

Curves "cubic" [9] "nonperiodic"
       "P" [0 0 0
            0 0 0 0 0 0 1 1 0 2 -1 0
            3 1 0 4 -1 0 4 -1 0 4 -1 0] 
       "constantwidth" [0.03]
       "Cs" [1 1 1
              1 1 1
              1 0 0
              0 1 0
              0 0 1
              1 1 1
              1 1 1]
			

Figure 4








Figure 5




© 2002-5 Malcolm Kesson. All rights reserved.