code of the day cotd

Code of the Day: Tree Generator

Tree Generator 1.4 script by nitisara:

Tree Generator is a nice option for random generation of NURBS trees. There are quite a number of options to create the trunk, roots, branch and adding leaves from a Maya.

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

Functionality: 9.5
The tool creates a number of options to create a nice tree, with quite a number of options to generate the random tree. The code does generate a lot of NURBs objects, which would be nice to either combine or have options to generate polygons instead. The tool allows quite a bit of functionality in terms of customization and extension, and it allows custom leaves to be created and used. The option of loading and saving presets is especially powerful, and the tool comes with a number of useful options for creating trees.

Design: 7
The code base is fairly small but powerful. The code does however make use a significant amount of global variables (counted at least 66), and would benefit somewhat from additional encapsulation. The tool creates a new scene each time which is a little unusual, and while the animation in producing the tree is neat to see, I would prefer that the tool have options to disable this as well. Some of the code seems to do quite a lot, and some smaller more encapsulated functions would help benefit the structure.

Style: 8.5
The code makes quite good use of whitespace and the variable names were quite appropriate and easy to follow. In a few cases the same variable name was used for different values (mostly in loop iterators) but otherwise is pretty good.

Documentation: 9
The documentation is quite helpful and explains all of the options in the UI. There Readme.txt was helpful and gave a good overview of the overall functionality of the code.

Reusability: 6
The code is tightly coupled to the UI and has a significant number of global variables (although most are treated as constants). The code makes use of a number of switch statements which is what makes the code more difficult to extend or change.

Overall: 9
The functionality produces a nice result, although with a few tweaks additional options on the type produced (combined polygon mesh would be nice), and the ability to turn off the animations (to speed up the end result), it would be even more impressive. It would also be helpful if the tool allowed branches and leaves to be created without roots, as they are not always necessary.

Until next time,
Michael Hubbard

Leave a Reply

Your email address will not be published. Required fields are marked *