Mtor
|
Introduction
Slim Ribbox Scripting I & Scripting II
provided introductory and intermediate examples of using TCL expressions in a slim ribbox.
This page provide several ribbox (TCL) scripts that cause a polygon mesh and a nurbs
curve to be replaced by a series of objects. In the first example, the MEL commands clientcmd
and pointPosition are used to querry the vertex data of a polygonal mesh. The
xyz coordinates of each vertex of the mesh are used to position (arbitary) objects across the
mesh. The second example uses pointOnCurve to replace a curve with a series of objects.
Polymesh ReplacementFigure 1 shows a character model that was kindly made available to me by Kelly Eisert. Figure 2 shows the effect the ribbox, shown in ribbox listing 1, has had on the rendering of the model. [ set tok [split $OBJPATH |] set tnode [lindex $tok end-1] set n [clientcmd "polyEvaluate -v $tnode"] set n [lindex $n 0] set out "" for {set i 0} {$i < $n} {incr i} { set str $tnode append str ".vtx\[$i\]" set pnt [clientcmd "pointPosition -world $str"] set rib "TransformBegin\n" append rib "Transform \[1 0 0 0 0 1 0 0 0 0 \ 1 0 0 0 0 1\]\n" append rib "\tTranslate $pnt\n" append rib "\tReadArchive \"G:/archives/cube.rib\"\n" append rib "TransformEnd\n" append out $rib } append out "Opacity 0 0 0\n" return $out ] |
figure 1 - original model figure 2 - polygon mesh replaced by cubes |
Lines 2 and 3 obtain the name of the
transformation node of the model. For example, slim's pre-defined variable $OBJPATH
may contain the following text,
TransformBegin Translate 0.139515 -2.34644 1.20277 ReadArchive "G:/archives/cube.rib" TransformEnd
In this example, ReadArchive is referencing a pre-baked rib of a cube. However, any
geometry could be used and the placement of the geometry can, of course, be modified
by other transformation and/or attribute commands. For example, figure 3, shows the effect
of assigning opacity to each pre-baked rib according the vertex "number".
|
[ source "PATH_TO_AIMY_SCRIPT" set tok [split $OBJPATH |] set tnode [lindex $tok end-1] set n [clientcmd "polyEvaluate -v $tnode"] set n [lindex $n 0] set out "" for {set i 0} {$i < $n} {incr i} { set str $tnode append str ".vtx\[$i\]" set pnt [clientcmd "pointPosition -world $str"] set norm [clientcmd "polyNormalPerVertex -q -xyz $str"]; set norm [lrange $norm 0 2] set ang [aimY $norm] set rib "TransformBegin\n" append rib "\tTranslate $pnt\n" append rib "\tRotate [lindex $ang 1] 0 0 1\n" append rib "\tRotate [lindex $ang 0] 1 0 0\n" append rib "\tRotate -90 1 0 0\n" append rib "\tCylinder 0.01 0 1 360\n" append rib "TransformEnd\n" append out $rib } append out "Opacity 0 0 0\n" return $out ] |
© 2002-6 Malcolm Kesson. All rights reserved.