Categories
code of the day cotd

Code of the Day: GI_Joe

Continuing on with more creative crash site today, I look at the GI_Joe script by pixho: https://www.creativecrash.com/maya/downloads/scripts-plugins/rendering/misc/c/gi_joe–2

The script is a set of UIs for creating a fake spherical lighting Global Illumination setup. There are a couple of options to setup the initial number of lights, as well as numerous options for setting the shadows, color calibration and sky attributes.

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

Functionality: 8
The initial setup only offers a few options for the light setup, but once it has been created, the code offers quite a number of options to tweak the values. Many of them are useful for quickly adjusting various attributes and setting up the GI in a number of different ways.

Design: 6.5
The first element I noticed (and indeed a requirement to get the code to work) is that it has to be modified so that the path point to the GIJoe.lights file. Rather than having everyone using the script modify the code, the code should instead look up the user’s path and use that.

// Line 57
string $pathL = “e:/vfx/mans/maya/scripts/GIJoe.lights”;

Should be replaced with this:

// Get the user’s script path from the internalVar and setup the GIJoe.lights
string $scriptPath = `internalVarusd`;
string $pathL = $scriptPath + “GI_Joe.lights”;

Other than this immediate change, much of the rest of the design is fairly logical. The code is a little long, and may benefit from being split into separate files, but most functions are small and self contained which helps with the overall structure. The code does not do a lot of error checking in the functions, but since the functions are not used in standalone (and are only available after the initial GI light is setup) this is more of a nice to have. Some of the code suffers from code duplication where the same checks are done in a number of functions (which could be moved to a separate function to reduce code duplication).

Style: 8
The code is organized in a logical manner for the most part and the use of whitespace helps organize the code. The naming conventions appear to be fairly consistent and most variables and functions have appropriate names. There are a few minor inconsistencies, but the grouping of logical functions together in the same area of the code helps show the structure of the design.

Documentation: 7.5
The documentation is a little bit sparse, for those that are unsure of how to run the code the commands are:

source “GI_Joe.mel“;

GI_Joe;

I suspect that better documentation would be available but the link http://www.pixho.com/ does not exist. There are a number of comments in code which are somewhat useful, and the inclusion of a help option in the tool (which displays some information about the tools as they are hovered over) helps improve the use of the tool.

Reusability: 7
A number of functions appear as though they could be reusable, but the size of the single script and coupling with the GI_Joe.lights file make maintainability more difficult. As with a number of MEL files, some pieces of the code are closely coupled with the interface, but there are areas that benefit from the use of standalone encapsulated functions.

Overall: 7.5
A nice tool if you are looking for this kind of Global Illumination fake. The options are really what make this tool useful. It would be nice to see what kind of documentation was available at the website, since it would likely help better understand how the tool is used and the overall functionality, but as it stands, it is a nice little tool for what it does.

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

Leave a Reply

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