Mtor
Slim Ribbox Scripting 5


return to main index

Related Links
   Slim Ribbox Scripting 1
   Slim Ribbox Scripting 2
   Slim Ribbox Scripting 3
   Slim Ribbox Scripting 4
   Slim Ribbox Scripting 6


Introduction

This example of geometry substitution involves the use of a Maya particle emitter. The ribbox shown below querries the number of particles using the MEL command,

    particle -q -ct ...

and then steps over each using the command,

    getParticleAttr -at position ...

in order to querry the each particles xyz location. The positional data can be used for any purpose, for example, a blobby object. In the example shown below a long string is created that inserts a colored spheres into the scene. The final rib statement in the script, "Opacity 0 0 0", makes the actual particles invisible.


[
set pName   [clientcmd "listRelatives -parent $OBJNAME"]
set pName   [lindex $pName 0]
set pNum    [clientcmd "particle -q -ct $pName"]
expr srand(1)

set ribout  "Surface \"plastic\" \"Kd\" 1\n"

for {set n 0} {$n < $pNum} {incr n} {
    set pnt [clientcmd "getParticleAttr -at position $OBJNAME.pt\[$n\]"]
    set x   [lindex $pnt 0]
    set y   [lindex $pnt 1]
    set z   [lindex $pnt 2]
    append ribout "TransformBegin\n"
    append ribout "    Translate $x $y $z\n"
    append ribout "    Color [expr rand()] [expr rand()] [expr rand()]\n"
    append ribout "    Sphere 0.1 -0.1 0.1 360\n"
    append ribout "TransformEnd\n"
    }
append ribout "Opacity 0 0 0\n"
return "$ribout"
]

Of course, inserting colored spheres as substitutes for the actual Maya particles is of no importance. However, the script could be quite easily adapted to render a blobby object (also) or to generate a procedural primitive via a helper application.


figure 1






© 2002-6 Malcolm Kesson. All rights reserved.