MTOR/MEL/TCL
|
![]() before post processing - figure 1 |
![]() after post processing - figure 2 |
|
i n t r o d u c t i o n
As of RenderMan Artist Tools version 11.5.3 the only attribute that can be assigned
to a Maya curve using mtor is "constantwidth". Pixar's mtor plugin allows a curve
to have a uniform width but not a sequence of width's or colors etc.
The normals are encoded to 3 decimal places. This seems to provide sufficient accuracy for most purposes while preventing the curve names from becoming too long.
|
|
|
|
i n t r o d u c t i o n
Post processing a Maya/mtor RIB file consists of,
Any general purpose scripting/programming language can be used to post-process
RIB files. This tutorial provides an example TCL script (listing 2) that
post process a single RIB file. Before continuing you may wish to
review another tutorial dealing with
file filtering.
|
|
listing 2 - Tcl script |
proc decode { input } {
if { [string equal [string index $input 0] p] } {
set out 0.[string trimleft $input p]
append out " "
} else {
set out -0.[string trimleft $input n]
append out " "
}
return $out
}
proc processRib { inpath outpath } {
set in [open $inpath r]
set out [open $outpath w]
while { [eof $in] != 1 } {
gets $in line
if { [llength $line] == 4 &&
[string equal [lindex $line 0] "Attribute"] &&
[string equal [lindex $line 1] "identifier"] &&
[string equal [lindex $line 2] "name"]} {
set tokens [split [lindex $line 3] _|]
set N "\t\t\"N\" \["
# The coordinates are in 3rd to second to last token.
for {set i 2} {$i <= 11} {incr i 3} {
set x [lindex $tokens $i]
set y [lindex $tokens [expr $i + 1]]
set z [lindex $tokens [expr $i + 2]]
set xyz "[decode $x][decode $y][decode $z]"
# Because mtor repeats the first and last cv's
# we must also repeat the first and last normals
if {$i == 2 || $i == 11} {
append N $xyz$xyz
} else {
append N $xyz
}
}
set N [string trimright $N]
append N "\]"
# Now we have decoded the name we must look for AttributeEnd
# so that we can copy the data to the output RIB file
while { [eof $in] != 1 } {
gets $in line
if { [string equal [lindex $line 0] "AttributeEnd"] } {
puts $out $N
puts $out $line
break
} else {
puts $out $line
}
}
} else {
puts $out $line
}
}
close $in
close $out
}
set src PATH_TO_DIRECTORY/single_curve.rib
set dst PATH_TO_DIRECTORY/single_curve_copy.rib
processRib $src $dst |
© 2002-5 Malcolm Kesson. All rights reserved.