Pages

Saturday, February 18, 2012

Code of the Day: XY Shrink Wrap

xyShrinkWrap 0.1 script by riviera: http://www.creativecrash.com/maya/downloads/scripts-plugins/modeling/misc/c/xyshrinkwrap

xyShrinkWrap 0.1 is a MEL script that modifies an object to fit the first selected object inside the second selected object.

Language: MEL
Type: Maya Editor Script
Script Files: 1
Number of lines: 167

Functionality: 5.5
The script has no interface and relies on selection. The code uses geometry constrains to setup the shrinkwrap functionality. It appears as if the object that gets wrapped does not always keep its shape, but instead is modified to fit inside its wrapper object. It is not quite the same as the XSI shrinkwrap which actually uses the normals of the object to do the wrapping, but instead is more of a place one object inside of another "wrapping".

Design: 6
The code is broken up into logical components, and even has a wrapper around some of the warning print statements which can be helpful for debugging (instead of having to comment out all the existing print/warn statements). The main function for doing the wrapping is a little more complex than it could be (with numerous nested if and for statements. The name wrap is also a builtin Maya MEL function, so it would probably benfit from choosing a different name.

Style: 7
The code formatting is pretty consistent and the overall use of whitespace is appropriate. The variable names and function names are pretty good (although wrap, xyShrinkWrap, wrapc may be a little too similar). The code makes use of some comments and is organized in a logical way.

Documentation: 6
The header is a little sparse and would benefit in explaining how to use the code, or what it is supposed to do (such as which object to select first to get shrink wrapped), or how to invoke the script. There are some code comments which are helpful though.

Reusability: 7
The code base is quite small and the main wrap function is coded in such a way that it is possible to invoke the wrap function through parameters (which is quite helpful). Overall, from the clean organization and comments it would likely be a fairly easy script to maintain or extend.

Overall: 6
It is not quite the XSI shrinkwrap tool, but may have its uses in certain cases. It mentions it is based on the fitMorph.mel script, which is a more descriptive name of what the tool actually does.

Until next time,
Michael Hubbard
http://michaelhubbard.ca

No comments:

Post a Comment