Tcl
|
IntroductionOccasionally it is necessary to apply a series of rotations to a coordinate system so that one of its axes points in a specific direction. Another tutorial "Mel: Align Y-Axis to Vector" explains the principle on which the Tcl script given in this tutorial is based. |
Listing 1
|
UseagePixar's RenderMan Artist Tools (RAT) supported the use of a so-called Ribbox. They enabled Tcl scripts to be executed when RAT's mtor plugin for Maya wrote the geometry for an object into a rib file. Although RAT has been replaced by Pixar's newer product, RenderMan Studio, the following notes, intended for use with RAT, may still be of use in other contexts. To align an object, such as a quadric cylinder, to a vector (x = -2, y = 2, z =1), the aimY proc would be used as follows. [ source "PATH_TO_THE_AIMY_SCRIPT" set xz_angles [aimY -2 2 1] set rib "Rotate [lindex $xz_angles 0] 1 0 0\n" append rib "Rotate [lindex $xz_angles 1] 0 0 1\n" append rib "Rotate -90 1 0 0\n" append rib "Cylinder 0.5 0 2 360\n" return $rib ] The rotation of -90 degrees around the z-axis is required because RenderMan quadric surfaces, such as a cylinder, are aligned to the z-axis not, as would be the case with a Maya cylinder, the y-axis. The rotation, in effect, turns the cylinder upright after which the x angle and the z angle rotations align the cylinder to the specified vector. |
© 2002- Malcolm Kesson. All rights reserved.