Pages

Saturday, January 7, 2012

Code of the Day: Connect Poly Shape

Continuing on with more creative crash site today, I look at the Connect Poly Shape script by dirk: https://www.creativecrash.com/maya/downloads/scripts-plugins/c/connect-poly-shape

This tool set simulates subdivision modeling with polygons by connecting a low res polygon shape with a higher res version. The higher res proxy version updates in realtime to allow an artist to model in low-res polygons and see immediate updates to the high res version.

Language: MEL
Type: Maya Editor Script
Script Files: 7
Number of lines: 6437

Functionality: 9.5
There is a lot of functionality to this script set, and a lot of workflow considerations are considered, including setting the proxy object and initial objects on different display layers, heads up display information to help better navigate the tools (and current settings) and helpful options for creating quick selections, and navigating the interface.

Design: 7
The setup scripts do a good job with sanity checks to verify that all the other scripts and icons are there which more scripts should really do. The interface code would also benefit from a separation from the connection logic. Some of the functions are very long and would benefit the design and reusability to split these into smaller reusable functions. The code does a good job in checking most potential error conditions, and does a good job of outputting errors that it comes across. The most unusual part is creating a string array which is a mix of parameters and code to pass to another function (like a parser). I realize the MEL does not have good support for objects (which is what this approach is trying to mimic), but feel that a more concrete structure would be far less error prone and easier to debug.

Style: 8
The code is organized into logical files, each encapsulated to do its job. The naming conventions are consistent and the use of whitespace is appropriate in showing the hierarchy of the UI. The use of comments is appropriate and offers some good insight into a few of the longer functions.

Documentation: 10
The documentation is great and very thorough, it even has tutorials and examples of what is going on underneath the code with a basic example of how to setup the poly shape connection without the tools. The code has help and tooltips and the inclusion of hud options makes it very easy to navigate.

Reusability: 7
A number of functions are isolated, but some functions are just too large to be reusable. A lot of the code is tied to the interface and some of the unusual preset approach with string arrays makes it tricky to pass other parameters.

Overall: 9
This tool set offers a lot of functionality for modelling polygons in a way that is easy to understand and seems to be well aware of the artist workflow. Overall this feels like a very complete package and the documentation and tutorials are some of the nicest I have seen on creative crash.

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

Friday, January 6, 2012

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 = `internalVar -usd`;
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
http://michaelhubbard.ca

Thursday, January 5, 2012

Code of the Day: FBIK CharacterControl

Continuing on with the creative crash site today, I wanted to continue a bit more with some asset creation tools, so downloaded the popular FBIK CharacterControl by shinsenTarou: https://www.creativecrash.com/maya/downloads/scripts-plugins/c/fbik-charactercontrol

The script is a UI for character building similar to a feature like Motion Builder. This offers a UI for selecting specific rig controls (rig file included) and options for creating and loading poses, setting keys, selecting IK or FK nodes and overall control over the human.mb character. Other rigs are included (such as a quadruped), but the interface is based of a human biped character.

Language: MEL
Type: Maya Editor Script
Script Files: 2
Number of lines: 2577

Functionality: 8
The code creates an interface to quickly select and create poses for the rig file included. The overall interface is nicely laid out with features for creating and setting poses, quickly grabbing multiple parts of the rig through the interface. The UI has tabs for Body, Hands and Feet, selection for FK or IK, and keying whole body or selection.

Design: 8.5
The code is organized into logical functions with appropriate parameters and return values. Many of the functions have encapsulated functionality which offers a great deal of code reuse. Some elements of the design are still closely coupled with the interface, but are handled in such a way to keep these isolated from the rest of the code. Some functions use a few magic strings which would be better set as constants, but otherwise is well organized in design.

Style: 9
The code is very organized and easy to read. The use of whitespace is consistent as is the decorators above each function. Some of the code could benefit from some additional comments, but since most of the functions are small and concise this is more of a nice to have. The naming conventions between public and private procs borrows a little bit from python in its use of underscores, but is nevertheless consistent.

Documentation: 8
The Install.txt file gives information about how to install the shelf and icons, but the code could do with a little bit more documentation. The code is well organized and somewhat self-documenting, but some additional information would be useful.

Reusability: 7
Due to the small and reusable design of the functions, a lot of this code base would be easy to maintain. The interface specific stuff is tied specifically to the hierarchy of the UI, but otherwise is encapsulated away from the rest of the code. Creating different skeletons would likely involve some heavy modification to the UI. The interface also seems closely tied with the rig, which would require updating the UI, code and rig for any modifications.

Overall: 8
The functionality is useful, and the example maya files are helpful in displaying the functionality of this tool. The code base is very easy to read and benefits from a logical design. Some of the functionality is similar to other tools, but overall gives a nice example of a Motion Builder like interface in MEL.

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

Wednesday, January 4, 2012

Code of the Day: MJ PolyTools

Continuing on with the creative crash site today, I wanted to continue a bit more with some asset creation tools, so downloaded the popular MJ Poly Tools by Mikkel Jans: http://www.creativecrash.com/maya/downloads/scripts-plugins/polygon/c/mj-poly-tools

This is a script creates a menu with of mesh manipulation tools including:
Connect Vertices/Edges/Faces
Split Around Vertices/Edges/Faces
Edge Loop Split
Select Ring
Select Loop
Select Outline
Extrude Vertices ( Seperated / Together )
Chamfer Vertices ( Seperated / Together )

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

Functionality: 8.5
The code creates a number of quick and easy to use tools in a straight forward menu. The functionality of the tools when the selection is done right, but does not offer the user much feedback when they do something wrong. Helping the user with some more messages will increase the usability of the tool. More of a nice to have would be if the script checked if the menu was already created before attempting to create it again.

Design: 8
Each element of the menu is broken up into single functions and supported by smaller helper functions in a logical manner. The design is not tightly coupled to the interface and does well to avoid the use of globals or state information and almost runs entirely as stateless functions. Some of the code looks like it could be broken down into a few more logical pieces (such as those that get the selection and filterExpand), but otherwise shows minimal code duplication.

Style: 6
The code unfortunately is quite difficult to read in some places due to spacing and some of the inconsistencies with indentation (or in some cases, no indentation). This makes the code especially hard to read when it is a few nested levels deep and all the brackets for the nesting are in the same leftmost column. The code initially makes use of larger header and footer comments to distinguish between functions, but does not follow this consistently throughout the code. The comments are not entirely consistent with the code, and a number of forward slashes are used to separate parts of functions. The function names vary between camelCase and PascalCase, but are still somewhat logical. The use of whitespace is inconsistent in terms of indenting and spacing.

Documentation: 6.5
The user documentation points to a link that no longer exists http://www.maya3d.dk/MEL/MJPolyTools/MJPolyTools.htmwhich is unfortunate, since I feel that it would help share some insight into what is happening in the code. The code does not include any information about how it is to be used, but does follow the standard "source scriptFileName" MEL paradigm. The code does have some comments, but it would help to have more.

Reusability: 7
Due to the good design of the code into small separate functions, the code could well be reused in other ways as the functions are available to be called directly without going through the user interface. The code may benefit from some cleanup to make it consistent and easier to follow in a few places should any bug fixes be required.

Overall: 7
The functionality is really what shines through on this script, and while some of the tools may now have similar counterparts in later versions of Maya, the tools being in one easy to use menu are quite nice. Overall it seems a useful set of tools, and worth playing around with a bit more.

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

Tuesday, January 3, 2012

Code of the Day: TreadsCreation

Continuing on with the creative crash site today, I downloaded the third most popular download AS_TreadsCreation by asanint: https://www.creativecrash.com/maya/downloads/scripts-plugins/c/advancedskeleton

This is a script to copy (or instance) objects around a curve to create an animated tread (like a tank tread). The treads created have a speed attribute for setting the direction and speed of the tread movement around the curve (negative speed value for reverse).

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

Functionality: 8
The code creates instances (or copies) an object around a curve, but it would be nice to have options to include spaces between the treads without modifying the tread geometry. Overall for very small treads it works quite well and does as expected. The inclusion of the animation curves for the treads is very nice. All the treads created fall under the same AS_treadsGrp, but it might be a nice option to create a separate group for each set of treads to make it easier to manage multiple groups.

Design: 7
The code is broken up into logical functions with clear functionality. Error handling is logical and handles the majority of cases that the code can get into. Some of the functions (like the treads function) are quite long and use a lot of internal variables which may benefit from refactoring into a few smaller functions. The tread code is unfortunately strictly tied to the interface code, as the functions do not use any parameters, but grab the value directly from specific widget control settings.

Style: 7.5
The code is laid out in a consistent and logical manner. The use of comments is helpful, although I find the indenting the code underneath a comment a little unusual. The use of the asterix is a little overused as it is in both as header decorators and within the code. Usually if such visual breaks within a function are desired, it is better to separate those pieces into a separate function. Some of the spacing around the interface is a little confusing and does not seem to follow the hierarchy of the interface.

Documentation: 7.5
The user documentation points to a link that no longer exists http://www.radiantsquare.com/modules/tutorials/listtutorials.php?cid=5 which is not that helpful. The code comments are useful, and the debug messages are helpful in guiding the user in their mistakes. Some of the comments are a little redundant, especially the closing bracket comment that mentions the end of a function, but I suppose this could be the style carried over from a different programming language background (like Visual Basic) which uses "End Sub".

Reusability: 6
The code for the most part is logically broken up, but since none of the functions take parameters (and instead rely on specific UI elements for their values), the code is tightly coupled with the interface. The treads function is the major functionality outside of the interface, but would require modification to pass in a different set of parameters.

Overall: 7.5
This is a nice little script for quickly creating animated treads. Some additional parameters to allow for a little more customization in the interface would be a nice to have, but for many cases it works well the first time.

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

Monday, January 2, 2012

Code of The Day: Advanced Skeleton

I decided to tackle a larger (and second most popular download) on creative crash today, the advancedskeleton by oyvind: https://www.creativecrash.com/maya/downloads/scripts-plugins/c/advancedskeleton

This is quite a large bundle, although the majority of the size 4.34 MB download is from the numerous icons (both .png and .xpm icons). The package is an entire rigging system, allowing flexible creation of multiple types of rigs (biped, quadruped, bug and custom), the creation of low res geometry and tools for rigging characters. The system also includes an install for copying the scripts to the correct directories, a Maya shelf for the tools available, maya files for the built in skeleton types, and selection and pose creation interfaces. Another interesting option is the Fit Mode option which preserves X-down join orientations while they are being manipulated.

Language: MEL
Type: Maya Editor Script
Script Files: 13
Number of lines: 18535

Functionality: 9
First off I have to say I did not get a chance to try every feature, but from what I tested I was quite impressed with the functionality I did explore. The code performs quite well for such a large system, and was easy to setup and use once installed/setup (although I used the manual install since I was more interested in seeing the internal files). The FitTools and AdvancedSkeleton Tool (for mirroring the FitTools) is easy to use and works well.

Design: 7
The code has some code duplication mostly involved in getting the absolute path of the file and sourcing other mel files. I understand that this could be done to allow each script to work in isolation, but since it is part of a package, it might be worth considering a single place to setup and source the file paths and not have each script worry about where it actually lives. The use of global variables and evals is understandable due to examples from MEL and Maya, but it is still nicer to see other design patterns in place. Most of the code functions are small and compact, but there are a few functions that do quite a lot.

Style: 7
The most unusual part of the code is the use of whitespace for indentation. Logic within a function is not indented and sits on the same column as the function declaration and brackets line up exactly with the code rather than being at different spacing. I have not seen this formatting before and while it is consistent within the code it is a little harder to read (as it is not as obvious where a new function starts). Some of the source files are quite long (the longest being 4153 lines long), which isn't huge, but I find if a file gets that big it might be doing too much. In this case it is the asProcedures file which likely contains a lot of functions used by other files. I would favor this approach over code duplication, but think that in a few cases the functionality could be encapsulated in some of the other files. Some of the commented out code in a public build would be nicer to not have been included.

Documentation: 7.5
This is a tough call. The help user documentation is awesome and the examples on the facebook site: http://www.facebook.com/pages/AdvancedSkeleton/114793298585853 are very helpful and well done. The code comments however (outside of the same install information in the header) are few and far between, and coupled with the code that has been commented out do not lead to a lot of useful documentation on what is happening in the code.

Reusability: 6
The code use of global variables and evals makes it trickier to expand on. The user interfaces are mixed in the same files as the functionality so each would have to be worked on together. There is quite a bit of code here which relies on naming conventions, icon names, specific paths and specific maya files. Some of the procedure code could be reused, but likely would have to be extracted if used separately.

Overall: 8
This is a nice little package and creates a nice rig with some great flexibilty for non-standard rigs. The functionality is very nice and the user documentation is great, the code does the job and looks like it has been through some changes and updates. The functionality is the most impressive part of this package.

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

Sunday, January 1, 2012

Code Of The Day: detachseparate-mel

A good place to start this first code of the day is something small but useful. The most downloaded script on creative crash is the Maya script detachseparate-mel by JeffD:
https://www.creativecrash.com/maya/downloads/scripts-plugins/polygon/c/detachseparate-mel

The functionality of the script is similar to the Mesh->Extract on a Polygon Face with the difference that the script creates a separate hierarchy for the new face. My guess at the popularity of this particular script stems from this functionality being available in 3DS Max and thus those artists working in Maya wanted the same feature.

Jeff D writes in the comments: "This script will effectively detach and separate selected faces from a poly mesh. Advantages of this script over Maya's built in detach/separate is that this script doesn't create a third parent node. It also allows you to break off only the selected faces as opposed to exploding every sub-mesh of an object."

Language: MEL
Type: Maya Editor Script
Number of lines: 61

Functionality: 8.5
The code does what is expected when a polygon face (that is attached to other faces) is selected. The code does not handle the case where nothing is selected, when the object selected only has a single face (like a plane) or if the object is not a polygon (like a subdivision surface). Each of these cases generates the same error when the code gets to the duplication line, but it would be nice if the code checked for a few of these and gave a different warning depending on the error.

Design: 7
The organization of multiple iterators in the same loop (with different values), is a little more complex than it needs to be and could be refactored to be simpler. Additional error checking would be ideal to prevent unneccessary computation if the object can not be duplicated (or the selection is invalid). Array indexes are not checked before they are used, values returned from the Maya API are not checked before they are used.

Style: 9
The code layout is consistent and logical. Most variables are declared and initialized at the top of the function to make the code easier to read and follow. The formatting is consistent and the use of whitespace and comments is pretty clear. Some of the variable names such as using step, step2, step3, skip and skip2 for loop iterators are a little unusual.

Documentation: 9
The comments and documentation are quite straight forward, a couple extra comments on some of the magic numbers (like 34) would help clarify a few things without having to look at the filterExpand documentation, some additional comments on why the loops were setup with multiple iterators in the same expression would also be useful.

Reusability: 7
The code could also pass in the filterExpand type variable into the function instead of hardcoding the 34 (for Polygon Faces) which could allow the code could potentially be made more flexible for other types of splits (and not just polygon faces). As a single function, the code would have to be broken up if pieces if any of it were to be used separately.

Overall: 8.5
The code quality is pretty good and the functionality does what it intends. Additional error checking and future reusability design decisions would be a nice to have, but for the most part the script does exactly what is required. For those looking for the same detach 3DS Max workflow, or one that requires that extracted faces be separate from a parent node, this is a nice little script to use.

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