Pages

Sunday, February 19, 2012

Code of the Day: DK Anim

dkAnim 0.7.0 script by danielk: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/dkanim/

dkAnim 0.7.0 is a MEL script for importing or exporting animation channels, and relies on node names instead of node hierarchies (like the built-in Maya animation transfer).

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

Functionality: 7.5
The script does a good job saving and loading, although it is not very fast (compared with the builtin option). Perhaps the most useful option is the ability to replace certain nodes and add prefixes which would be very beneficial if the model has changed at all (although the .dkanim file that is created is a text file, so likely that could also be modified). The format of the text file is again non-standard, but has some hierarchical structure to it that makes it more flexible to use than straight line by line processing.

Design: 6.5
Most of the code except for the read and write functions are small and self contained. The read and write however because it is a custom format are quite complex and the level of nesting is quite deep for some of the branching statements. There are a few global variables used to pass information around, mostly to keep the refresh state organized. The code also uses quite a number of variables in the read and write code which makes the design more complex.

Style: 6.5
The code formatting is not completely consistent, especially related to the indentations. The code nesting I mentioned does go up to 14 levels deep of a combination of if/else branching and while loops, which can be pretty hard to follow the overall path of the code.

Documentation: 6.5
The header comment really doubles as the documentation as it is quite verbose and gives a lot of information about how the tool was used and why it was created. The in code documentation are pretty much non-existent, except for the occasional line of commented out code and the one comment "//Does File Exist?".

Reusability: 5.5
The code in a few places is tightly coupled to the UI (and the refresh globals). There are a number of places that look like they could be reusable, but otherwise not too bad. The maintenance or bug fixes on having to work with the read and write logic would be tricky based on their complexity and the use of a custom format.

Overall: 7
The script does a nice job of providing an alternative to Maya's builtin .anim channel transferring. If you need an option that works purely on the names of the nodes, and has a few additional options for saving information that is not keyed, this could be a useful script to look at.

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

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

Friday, February 17, 2012

Code of the Day: Flock

Flock 1.0 script by JohnKG: http://www.creativecrash.com/maya/downloads/scripts-plugins/c/flock

Flock 1.0 is a MEL script for creating a swarming group of particles around a locator.

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

Functionality: 6.5
The script offers a few controls (initial size, spacing, speed, range, min/max distance and influence), which gives a few nice options for initial setup. The script particles themselves move similar to flying bugs (apparently it is a derivative of the gnat script), so any more complex flocking (such as that of birds or other animals) is not really what the script is about. The code does give a warning in Maya 2012, which is not that unexpected since it is an older script:

// Warning: -r/runtime should be replaced with -rbd/runtimeBeforeDynamics or -rad/runtimeAfterDynamics. //

Design: 6
The code uses a number of global variables to pass information around, and creates a very long expression for the dynamics. The script also automatically begins playing back the newly created particles, which should really be an option in the UI, as in many cases there will need to be additional tweaks before wanting to play back the animation.

Style: 5
While creating dynamics expression can be complicated, it is probably best if it is does not use 20 variables and is over 2400 characters long in a single one liner. If the dynamics expression is that complicated, it would be worthwhile to build up the expression through intermediate strings to at least add in the debugging. The rest of the code has inconsistent spacing and indentation, and there are a number of places where code is commented out (especially non-working versions of the dynamic expression string).

Documentation: 6.5
The code gives a lot of information in the header about what the script is supposed to do, but the only comments in the code are for commented out functionality.

Reusability: 6
The code base is pretty small, basically an interface to setup a dynamic expression for particles. The UI uses empty text files instead of one of the layouts to setup the position and spacing of the UI, but otherwise would be easy to maintain. There is not a lot of code that could be reused however as it is heavily reliant on the global variables.

Overall: 6.5
If you need a lot of bugs as dynamic particles that move in a flocking movement this is a quick and easy way to set them up. It is apparently similar to the "gnats.mel" script, but with more options.

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

Thursday, February 16, 2012

Code of the Day: Spiralizer

Spiralizer 1.2.0 script by marble: http://www.creativecrash.com/maya/downloads/scripts-plugins/modeling/misc/c/spiralizer

Spiralizer 1.2.0 is a MEL script for creating a spiral of any NURBs surface.

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

Functionality: 6
The script takes a NURBS surface and creates a spiral curve based on the surface and the only option in the window "Number of turns". The result is quite nice when used on simple NURBS surfaces, but a few more options would improve the usability of the tool. More complex NURBS appear to produce more unexpected results. The fact that it replaces the NURBS surface that was selected can in some cases be a little less user friendly than giving the user the option to keep the original.

Design: 6.5
The code is split into two files of about ~50 lines each. Each file only contains one function, but it is still a decent separation of UI and the rest of the code. One thing that was a bit unusual was creating a number of empty labels for spacing rather than using any of the layout options (such as formLayout) to get the spacing in the UI.

Style: 6
The code is tiny, but what is there does not appear to have any code indentation. The UI however is indented, but the if statements and rest of the code body is all on the first column. I am not sure if this was intentional or not, but I found the button name "cButt" to be an unusual choice.

Documentation: 7.5
The code only comments one function but that it really all that is necessary. The code comes with a readme for installation as well that is pretty straightforward.

Reusability: 7.5
The code is tiny and would be fairly easy to maintain and debug as this is one of the smallest scripts I have reviewed. Overall, it would be trivial to debug or maintain this code.

Overall: 6
The result is decent for simple surfaces, although it would be great to have some more options (especially not deleting/modifying the original NURBs surface. This is a very specific tool, but gives a quick and nice result for what it does.

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

Wednesday, February 15, 2012

Code of the Day: PoseMan

PoseMan 1.3.5 script by Francis Vega: http://www.creativecrash.com/maya/downloads/scripts-plugins/c/poseman-pose-manager--2

PoseMan (PoseManager) 1.3.5 is a MEL script for creating various 3D rig control icons.

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

Functionality: 8.5
The script has some very nice functionality in creating and organizing poses. One of the things I particularly liked was the inclusion of default camera settings for creating a screenshot of the pose. The format of the poses appears to be a simple text file which is ok, but a standard data format would likely be more reusable. The ability to create "section" tabs to help organize the poses is also a nice approach, as are all the options available for organizing and applying the poses.

Design: 6.5
I never really like instructions that require modification of the code to set path variables. While the $POSEMAN_LOGO is not required, it would still be better if the code used relative paths or some of the Maya environment variables to find the correct image path. The rest of the code is actually quite well organized into logical functions and while there are a number of globals and evals, the code flow is organized and structured.

Style: 8
The code formatting is nicely organized with consistent spacing and clear and descriptive function and variable names. The commenting and use of whitespace make the code quite easy to read, although with the size of the file, it would benefit from splitting up some of the functionality into new files.

Documentation: 7.5
The code commenting is quite well done and the readme gives some install information. The code is quite readable, but some extra documentation would be nice as there are quite a few features that are not immediately obvious and require some experimentation. It is a little unusual that some of the comments are in another language (Spanish I think) but not all of them, especially since the code function and variable names are English.

Reusability: 7
The code has a few functions that could be reusable, but the code in a lot of places is not obvious what it is supposed to do based on the function names. The code style would also help improve how much debugging would be required in maintaining this script. The non-English comments help confuse a few areas when trying to debug (unless you have a programmer on the team that is bilingual).

Overall: 8.5
The functionality is great, and the code quality is very high. The comments in another language is a little unusual, but otherwise is quite easy to follow. A good approach to creating a pose library, with a few nice features not seen in some of the more standard libraries.

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

Tuesday, February 14, 2012

Book Review: More Hyper-Realistic Creature Creation

Autodesk Maya Techniques Official Training Guide More Hyper Realistic Creature Creation by Erick Miller and Jeff Unay and Paul Thuriot and Rudy Grossman is both a long title and an interesting read. The book focuses mainly on facial modeling (mostly using blend shapes), facial rigging (joint driven components) and full body setup (full body IK, influencing the skin, caching out deformations).

The book has some interesting information such as how to adjust to production changes. Accomodating art/design changes can be accomplished by creating a blend shape from the old base head to all blend shapes, which not only saves work, but also perserves all the original information. For accomodating topology changes the first option is to setup a driver to the new topology, or the second option is to bake toplogy to targets.

The list of standard (required) blend shape targets was quite thorough and included:
ooh mouth shapes (in between targets)
lips mouth up and down (upward and downward facial shturds)
lip corners up/down optional , smile frown
upper and lower lip roll (or lip curl)
lip corner sideways (inward pull/outward strecth)
lip mouth pull forward and back
lip volume shapes flattened /tightened and puffed out lips
eye blinks/wide open eyes
tightly squinted eyes
cheeks up/down (cheek squint, cheek droop)
puffed out and sucked in cheeks
inward outward and updward downward flares, nose sneer snarl
brow up and down (furrow and raise)
forehead brow sideways (inward pull/outward stretch)
jaw clench/foreched clench, neck clench
custom shapes
jaw corrective shape

Overall, the book is quite slim (at 157 pages) which makes it a quick read, but it comes with a DVD full of great example scenes and code scripts/plugins (which I will see about reviewing in another post(s)). If nothing else, the book is useful as a guide to the examples, but has some good information on more high level concepts and information. In some ways it is a sequel to Hyper-Realisitc Creature Creation, so it may be better to read that first, but still stands well enough on its own.

Bye for now,
Michael Hubbard
http://michaelhubbard.ca

Code of the Day: KK Controllers

KK Controllers 1.7.0 script by karim kashefy: http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/kk_controllers--2

KK Controllers 1.7.0 is a MEL script for creating various 3D rig control icons.

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

Functionality: 8.5
The script has some nice functionality in creating 28 different kinds of control icons as well as 1D and 2D sliders. The UI allows for selecting different colors as well as locking various transform, rotate, scale and visibility controls on the controls created. There are also options for mirroring and combining the controls.

Design: 5.5
The code has a lot of magic strings and builtin curves, but overall does a pretty good job of separating out the logic into separate small functions. There are a few quite large functions that have a number of long if/else checks that make the code a little more complex than it should be. In a few cases some of the functionality is repeated with one variable change (which should be separate out into a function that takes that variable).

Style: 5
The formatting and spacing is inconsistent and in a few places even some of the functions are intended which makes the code hard to read. The bracket nesting is not consistent and a few places make the code difficult to read. The naming of functions and variables could be a little more descriptive, since a function name b1-b28 does not really clearly state what is happening in those functions.

Documentation: 5.5
The code comes with a readme and a history example, but has very little comments in the code itself. Since there are such non-descriptive function and variable names, the code really needs some extra comments to help separate out what functionality is supposed to be doing.

Reusability: 5
The code has a few functions that could be reusable, but the code in a lot of places is not obvious what it is supposed to do based on the function names. The code style would also help improve how much debugging would be required in maintaining this script.

Overall: 7
The functionality is actually quite nice, and the controls that are created are well done. The code itself works, but there might be a bit more room for improvement in making it more flexible for extensions and bug fixes.

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

Monday, February 13, 2012

Code of the Day: XPM

XPM.mel 2.0.0 script by ewertb: http://www.creativecrash.com/maya/downloads/scripts-plugins/interface-display/c/xpm-mel

XPM.mel 2.0.0 allows MEL access to the builtin .xpm Maya icons located in the MayaRes.dll

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

Functionality: 4.5
The script is interesting in that it attempts to create a window with all the icons from the MayaRes.dll, unfortunately instead of querying the dll or the icons folder, it uses an if/else for each version (and does not appear to include the 20XX series of Maya). The script creates a window with all the icons from the list and the name of the icon in the display (which is useful if you want to use builtin icons in any of your interfaces).

Design: 5.5
The code does not really share any of the list entries, nor does it have a base list that is common in all versions, but instead creates a single list (often with a significant number of duplicates, for each version). While it would complicate the code a bit to have options like (add or remove certain files), it would overall help better understand what has changed over the different versions of Maya. Otherwise, the code is very simple, but well organized.

Style: 6.5
The formatting and spacing is quite well organized, but it is really quite hard to look past a 8129 line function even if it is straightforward. Separating out the lists into separate functions would make the code more readable and while that is also an element of design, would definitely improve the style of this massive function.

Documentation: 7.5
The header and in code documentation give a good amount of information to the reader explaining what the code does (in a lot of cases with multi-line explanations which are nice). The code is not overly complex, but the comments are still nice to have on what is and is not included in the lists (no textures larger than 32x32).

Reusability: 4.5
The code is very specific to these lists of images, although the code does a pretty good job of commenting what is going on, and the actual functionality that is not related to the lists of images is pretty small. The first thing that would be worthwhile is some minor refactoring to separate out getting the lists into separate functions and organizing the code that displays the images from the code that gets the correct list of images. Otherwise the code should be fairly easy to maintain, but most of the icons in later versions of Maya seem available from the install anyway.

Overall: 4.5
It is probably still useful in older versions of Maya to see what icons are used, but about half the icons no longer exist in Maya 2012. Conceptually the idea is interesting of reusing Maya's icons, however because you do not have any control over which icons Maya keeps (or renames). From a maintenance (and often from a clarity perspective to avoid confusion if your script does something different than the icon script) it can often be better to use your own icons.

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

Sunday, February 12, 2012

Code of the Day: AutoTangent

AutoTangent 1.0.3 script by martin freitag: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/autotangent

AutoTangent 1.0.3 is a script for changing selected Graph Editor Keys to a smooth tangent.

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

Functionality: 6.5
There are only two main options (flattening start and end keys, and a slider for setting the softness), yet the functionality is very helpful, and in some ways feels like it should be built into Maya as a default option. The results are good, the keys smooth nicely without overshooting.

Design: 6
The code is broken up into a number of functions, the UI is small and compact and the code does not use too many variables (one global variable). There are a few magic numbers (specifically 3.0) that doesn't seem to have much documentation on why it was used either. The error checking handles most cases generally. The main function is fairly long and could have a few areas broken up into smaller pieces to make them more reusable and smaller more robust code base.

Style: 5.5
The formatting is a little inconsistent and the spacing and indentation (especially on the comments) do not seem to follow a consistent standard. There are areas of the code (mostly print statements) that are commented out, which just clutters up the code base.

Documentation: 6.5
The header documentation is decent and some of the comments in the code are pretty good. For being a small file it is not too bad, although it would make for a nicer read if there was not any commented code left in the script.

Reusability: 5
The code is tightly coupled to the UI, and the use of global variables means than no function is capable of reuse without the rest of the code base. Maintainability wise, the code base is tiny, so would be easy to update or modify any bugs as required.

Overall: 6.5
Quick and helpful little script for quickly modifying animation key tangents. In some ways I would not be surprised to see this functionality eventually built into Maya, as it sounds like other packages (like MAX) already have a similar function. It can be a useful little script for now.

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

Saturday, February 11, 2012

Code of the Day: Tornado Maker

Tornado Maker 1.1 script by maya.user: http://www.creativecrash.com/maya/downloads/scripts-plugins/c/tornadomaker

Tornado Maker 1.1 is a script for creating custom particle based tornado system.

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

Functionality: 7.5
The code offers quite a number of options for creating an interesting tornado shape from a cylinder and control lattice, as well as quite a lot of control over the particles and emitters. The options are quite thorough and gives quite a bit of fine grain control over the emitters and movement of the particles.

Design: 6
The code is broken up into a number of small functions which are mostly encapsulated and single use. There are however quite a few global variables being used, and in a few cases the globals are used instead of passing variables into the functions. There is also somewhat of a routing table of functions where a string variable is passed to trigger a function. However, since there is not any additional processing that is done through the function routing table, it actually makes the code more confusing, since the function requires dummy variables to be passed which are often not actually used by the function that is eventually called.

Style: 6
The formatting and indentation and not entirely consistent and in a few places the scoping of nested if statements is difficult to read since the brackets are all in the same column. The variable names are fairly good and functions are fairly descriptive which helps. There was at least one instance where switch/case statements did not use very intuitive names (such as case 1 throught to case 14). This is a little confusing to follow and is not clearly documented what each case does which leads to even more confusion.

Documentation: 6.5
The user documentation located here: http://www.worldofmaya.com/d_tornado.html is very straightforward and does a good job of explaining the tools. The in code documentation is quite sparse however, and the code itself (outside the header) are barely commented at all (would be nice to know what the individual cases were used for).

Reusability: 5
The UI seems to be tightly coupled to a number of functions, which makes debugging more complicated and reuse far more unlikely. It is really the heavy use of globals and unusual formatting that would make this code difficult to maintain or extend.

Overall: 7
The functionality exceeds the code base, the tornado script is a little bit older than some of the other scripts available, but still does a nice job creating an interesting tornado quickly and easily.

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

Friday, February 10, 2012

Code of the Day: Playblast Window

Playblast Window 0.0.2 script by Seamus O'Hearn: http://www.creativecrash.com/maya/downloads/scripts-plugins/camera/c/playblast-window

Playblast Window 0.0.2 is a simple script UI for creating specific playblast options.

Language: Python
Type: Maya Editor Script
Script Files: 1
Number of lines: 119

Functionality: 4.5
The code only offers a few options, mostly related to size which isn't a lot considering that many studios want to display certain elements or use certain compressions, formats etc. The code writes specifically to qt, with compression "H.264", everything off in the display except for polymeshes (with an option for ornaments) and using frame padding = 4. If those are the desired specs (with options for quality and size in the UI), than perhaps the functionality is enough. There do seems to be issues when attempting to add a file path (such as .avi) where the code cuts the last two digits off, the code should instead split on the . or preferably use os.path.splitext. It also looks like the code removes any spaces in directory names, which can invalid paths such as when used for example on a path that include "Program Files".

Design: 5.5
The code base is quite very small, and the functions are separated into UI, getting the file path and initializing the playblast. The code could be split into a few more functions and do a bit more error checking. Attempting to cancel out of the directory selection generates an error. In the UI there is a large warning mentioning which camera to use which is fine, but instead of the message, setting the camera and panel as options may be more intuitive and reusable.

Style: 5
The code comments itself says "it's pretty sloppy", which is honest. Overall, python by its nature does a pretty good job of keeping indentation and formatting similar, but there are a few places where variable names (such as "TheMagicalDirectory") are a little unusual and may not be entirely clear. The code only saw 12 style errors when run against pep8, but for the size of the file that is approximately 10%.

Documentation: 6.5
The code documentation in the header is pretty good. The code itself seems to be a bit overly commented (two of the functions have every line commented). In a few places the comments are useful, however in other places such as the example below, they are not necessary, and end up just cluttering the code.

#printed statement
print("Saved To")

Reusability: 5.5
The code base is tiny so it will be easy to maintain and extend. There are a few places that should have error checks, and the file extension code should be modified as I mentioned.

Overall: 4.5
Overall, the script is just too specific and with a few too many errors on basic use to be too reusable. I imagine that certain studios/artists would use it if there needs exactly matched the specifics of this file, but otherwise needs a few more options for widespread use (perhaps enabling the artist to choose to use the current playblast and/or modelPanel settings to override the builtin script settings).

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

Thursday, February 9, 2012

Code of the Day: PAIE

PAIE 1.3.2 script by Jakob Welner: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/paie

PAIE 1.3.2 (Python Attribute Import/Export) is a script for exporting animation and pose information to a file, and importing them onto the same (or similar) character.

Language: Python
Type: Maya Editor Script
Script Files: 1
Number of lines: 2293

Functionality: 8
The code is quite useful is saving out and loading poses and attributes onto similar (at least in name) objects. It does rely heavily on naming conventions, but is overall a useful tool (giving information about when a file was saved, as well as uses the python pickle module to save out its data.

Design: 8
The code base makes good use of classes and object oriented programming techniques. The code does a good job of checking for exceptions, although in a few places I think checking the input may well prevent an exception from being thrown (such as initializing the GUI class), but some programmers do prefer exceptions in some cases (I prefer not to see it on class initialization without any variables however). There are a few places where both evalDeferred are used to spawn MEL code, but in unusual ways that seem like they might have other solutions (especially when creating the UI). While the data uses the pickle module, I can't help but feeling that using a standard format (like XML or JSON) might make the data more reusable and extendable than writing a custom format.

Style: 8
The code follows pep8 pretty closely (only ~20 warnings from running the code). However there are a few areas that would perhaps benefit from moving the code out into separate files. While the class architecture does help, the overall size of the file is bordering on being a bit larger than it needs to be, especially with standalone classes available which would promote reuse of the package/module. A few of the functions (especially reading and writing) are quite large and the code path can be a bit complex in these cases.

Documentation: 7
The header information is quite good, and there are comments through the code base, but not every class is documented, and doc strings are not consistently used, which would help improve the readability of the code. The example documentation of the structure is good and it helps that most of the code has good variable and class names.

Reusability: 8
The code has a number of pieces that could be reusable as the class architecture and OO development approach naturally does. There are a few places that the code may benefit from additional comments, and there are a couple global variables (debugger and UI) that would make debugging a bit more complicated. Using a custom file format means more care has to be done on writing any extensions, but otherwise is quite straightforward.

Overall: 8.5
Overall, nice functionality implemented in a useful and elegant way. The functionality is pretty useful, and while there are some tools that do similar things, I think the underlying architecture of this script is for the most part well thought through.

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

Book Review: More Python Programming for the Absolute Beginner

One thing I always want to do is try and look at programming from a fresh pair of eyes. While I am certainly not an absolute beginner it is sometimes interesting to see how a development book tries to instill the core concepts of programming into the new reader. In More Python Programming for the Absolute Beginner by Jonathan S. Harbour the focus is to hit the ground running. The book focuses on the pygame module to create 13 small games/demos including: Pie Game, Trivia, Bomb Catcher, Analog Clock, Orbiting Spaceship, Escape the Dragon, Zombie Mob, Block Breaker, Oil Spill, Snake, Tank Battle, Artillery Gunner and Dungeon RPG.

Overall, the code is quite straightforward and well contained, although in a few places it seemed like a little extra engineering might go over a few people's heads, but still produce more concrete code. The code examples actually get better with more classes and better encapsulation later on, and I suppose it can be a bit much to introduce everything to an "absolute beginner". One thing that I thought was interesting was the workarounds necessary to deal with the pygames sprite rotations: "Pygame does not correctly adjust for the change in image size when a sprite is rotated", the fix is to "shift the image by the amount of change in dimensions from the normal image to the rotated image" (pg 203, 205).

Overall, this is a pretty entertaining read, and gives some good quick examples of pygame. The book also links to the author's forum where there is more information and updates: http://jharbour.com/forum/index.php?PHPSESSID=f8s6pkk6tdvb47ullmqormult4&board=23.0

One of the most expansive topics was the Dungeon "Roguelike" RPG. For an example of that, see the link posted in the above forum at: http://roguebasin.roguelikedevelopment.org/index.php/Main_Page

It may be fun to experiment a bit more with pygame for some simple examples, but for now, I am focused far more on other python modules.

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

Wednesday, February 8, 2012

Code of the Day: Batch Animation Transfer

Batch Animation Transfer 1.0.0 script by daagom: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/batch-animation-transfer

Batch Animation Transfer is a script that takes a folder of animations and applies a new rig and copies over the animations (requires that that the names match on the new and old rig).

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

Functionality: 5.5
The code relies on naming conventions for transferring data which is fine, but only works with maya binary files. It also seems to import the rig and animation files which may not work well with a reference workflow. The code does not give a lot of options on how it is transferring the data, but copies the new files into a separate directory so that is does not modify any of the original files. It would also be nice to have some more control over how the new files are named (if they could be named identical to the original it would be better than an additional prefix being added), which in most cases would likely have to be removed again afterwards.


Design: 6.5
The code base is quite small but the functionality is still broken up into useful functions and has some separation of interface and the rest of the code base. There are a few odd places where variables are being passed to functions that never use them, and there are a number of global variables mixed into the rest of the code.

Style: 7.5
The code style is well organized and follows its own standards quite well. Formatting is consistent and most variable names are named appropriately. There are a few places where magic numbers and strings are used, as well as evals, but otherwise is fine.

Documentation: 7.5
The code documentation is pretty thorough and a lot of the code is appropriately commented. There are a few places where there is code that has been commented out, which is better to remove or mention why it was commented out, but otherwise the comments do help in better understanding the code.

Reusability: 6.5
The code globals, and coupling of the interface makes it unlikely that any of the functions would be reusable in isolation. In terms of maintainability, the code base is very small and well documented, so any extensions/bug fixes, should be fairly easy to maintain.

Overall: 6
Overall, the script works only in certain workflows. If you are using maya binary (.mb) files, or a referencing workflow, it is unlikely that this script will be appropriate.

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

Tuesday, February 7, 2012

Code of the Day: AE Skin Weights Transfer

aeSkinWeightsTransfer 1.0.0 script by AndersEgleus: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/aeskinweightstransfer

aeSkinWeightsTransfer is a script for exporting and importing smooth skin weights in Maya by comparing the world space positions control points.

Language: MEL
Type: Maya Editor Script
Script Files: 4
Number of lines: 1602

Functionality: 6
The export does not have any options, or a UI, but relies entirely on selection. The importing and exporting works well, and the importing has some nice options for averaging and the influence of the transforms. It would be nice to have a bit more control over what is saved to the export and the file it is saved to, but overall works well enough.

Design: 6
The logic is separated out into the four scripts and does a good job of keeping the tool organized. The format of the script is a custom format based on whitespace and a custom spacing/naming that has some similarities to XML, but does not appear to follow any standard conventions. The file is saved as a .ma file, which is also a little bit confusing as it can not be read by Maya. A significant portion of the code is dedicated to this custom format, which may have been better spent working on a standard format (like XML, JSON, etc.). Otherwise, the code has a number of standalone functions which work well with the rest of the code, and most of the UI logic is separated (except in a few places).

Style: 8
The code style is pretty good, and is quite consistent. There are a few places were the code is a bit long in places (usually the import and export functions), but the rest of the code is pretty straightforward and easy to follow.

Documentation: 9.5
The code documentation is great and goes through each of the details of the UI as well as some tips on how to use the code as well as documentation on parts of the code that might be confusing. The installation instructions are thorough and the rest of the documentation is pretty straightforward.

Reusability: 7.5
The code has a number of functions that lend themself to reuse. The code would be more extensible if it was using a standard format instead of the custom .ma file format, but otherwise is pretty good. The documentation and comments also improve the chances of finding and debugging errors.

Overall: 7.5
The code quality is pretty good, and the functionality gives a nice result, with some useful options on import. I think using a standard file format for the data would cutdown on the complexity of the codebase and make it more extendible, but otherwise gives a nice result for transfering weights.

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

Monday, February 6, 2012

Code of the Day: dp SaveScenePlus

dp SaveScenePlus 1.2.2 script by diegopri: http://www.creativecrash.com/maya/downloads/scripts-plugins/utility-external/misc/c/dp-savesceneplus

dp SaveScenePlus 1.2.2 is a tool for doing an incremental save.

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

Functionality: 6
The save works on certain naming conventions, basically, the script looks for the last character value to update or append to. The script does not work if the version number is not in the last set of characters, and has a limit of two characters for the version (up to 99). If doing a save as, the code calls the builtin functionality and does not give a version number to the first iteration.

Design: 5
The script has a few odd areas, where it calls eval on builtin mel commands endString, startString and file commands which are entirely unnecessary (makes me wonder if the author was not a fan (or did not know of) using the standard `` calls to the maya api in MEL. The instructions for overriding the markingMenu's status line file "statusLine.mel" just to add the function is something that not everyone is going to want to do. It works well to have it on the statusLine, but may work better as a shelf button or menu item rather than overriding the builtin Maya functionality.

Style: 7
The code is tiny so only contains one function (called from the statusLine button), but still seems to have a number of variables and parsing. Separating out the file parsing into a separate function would be appropriate and while I understand the limitations of MEL, it would really benefit from using some more of the gmatch options to create a regular expression to quickly parse the validation of the filename instead of splitting the file and iterating over it.

Documentation: 8
The code documentation is decent, and the overall documentation and information is quite straightforward and useful. The documentation would do well in letting the user know they are overriding a builtin Maya file by copying it into the markingMenu tab (in case there are other issues).

Reusability: 6
The code would be easy to maintain or debug based on its size alone, however, without any parameters to pass into the function, it is not really extendable, and the code is in some places a bit unusual in its use of evals (without commenting why they are used).

Overall: 6
Overall, the script will work for someone wanting something simple and easy, but for more complex naming conventions it would be better to roll your own.

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

Sunday, February 5, 2012

Code of the Day: DP Transfer Skeleton Keys

dp Transfer Skeleton Keys 1.0.6 script by diegopri: http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/dp-transfer-skeleton-keys

dp Transfer Skeleton Keys 1.0.6 is a tool for transferring skeletal animation from one skeleton to another. The skeleton needs to have the same hierarchy, but does not require identical naming.

Language: MEL
Type: Maya Editor Script
Script Files: 4
Number of lines: 1517

Functionality: 8
The functionality is quite polished from everything in setting up the functionality as an extra menu item in the Skeleton menu to the results of the binding. While a few more options in copying the animation might be nice, the fact that it doesn't rely on naming conventions (instead just skeleton hierarchy) is very nice and likely to be quite flexible for other rigs (parts of the skeleton can be copied separately). In Maya 2012 there are a few warnings/errors that the script had issues with, but the functionality appeared to still work with these errors (below):

// Error: displayString identifier "m_ChaSkeletonsMenu.kRetargeting" does not exist. //

// Error: menuItem: Object 'globalSnapEnableItem' not found. //



Design: 7.5
The separation of UI from the transferring code into separate files is nicely handled, and the overall design is pretty straightforward. There are a few places where the code passed in a string value that is built up to be finally used as an eval which is a little bit error prone, and may benefit from a slightly different approach that instead gathered variables and applied them directly (at least to do some error checking before calling an eval directly). The code also makes use of a number of global variables, and in a few places, magic number and string values.

Style: 7
The code formatting is pretty consistent and quite readable. There are a few places where both the naming conventions and formatting vary slightly, but overall seems to be quite well organized. The internal functionality however in a few places looks like it makes heavy use of if/else statements, to handle up to 30 different types.

Documentation: 8
The code documentation is somewhat light besides the headers there is very little code documentation, except in places where a certain magic number for the types (which would do well to be documented and moved to either a function or constant value). The code does come with a readme and a useful example file to show off the functionality.

Reusability: 6.5
The separation of UI and the rest of the code is a great step, however some of the design decisions and style commitments (building up a string eval and 30 statement if statements) could prove to be more challenging to maintain, upgrade or debug than some other designs would. The fact that there are already errors in the code shows it is has issues on newer versions, yet still seems robust enough to still work (despite the errors).

Overall: 8
The code is quite a useful approach to transferring animation, and the fact that it does not rely on names is a very good idea. There will of course be those people that argue naming conventions when used properly will help be more flexible binding in different ways, but likely if the skeletons are that different, the results will not be that useful anyway. This package is well polished, and while there are a few issues, the end result would be useful for many workflows.

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

Saturday, February 4, 2012

Code of the Day: SRB-AnimTransfer

SRB-AnimTransfer 0.2.0 script by Suchan Bajracharya: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/srb-animtransfer--2

SRB-AnimTransfer 0.2.0 is a tool for transferring animation from one object to another with options for mirroring the keys across different axis for translate, rotate and scale.

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

Functionality: 6
The functionality is pretty straightforward, it allows selecting a source and destination object and options for mirroring across different axis, copying custom attributes, and copying a set of keys from the timeline. Overall, the script does not offer a lot of functionality, but what is there is useful and well organized in terms of usability.

Design: 5.5
The code is quite small and only has two functions (one for UI the other for the applying). The UI function is well organized and straightforward, but the apply seems to be doing a bit too much. Separating out some of the logic (like validating parameters from the UI, and getting values from the UI into separate functions would improve the design and make the code more robust and reusable. The code uses error code values but never returns them in the function. In some cases a variable will be set and checked in the next if statement to see if it was set, rather than simply returning the error code message directly.

Style: 6
The code formatting is quite consistent although only uses indentation in the UI elements, and does not use any indentation for the code logic. This makes a few parts of the code difficult to follow in a few places, that is only offset by the fact that there is very little nested logic and most code if branching is only 2 levels deep. Still, it is surprising to see such care in the UI code and not in the actual logic. The code in places does a bit much, but overall has a good commenting style to break up parts of the function.

Documentation: 8
The code documentation is pretty good, instead of separating out the code into different functions, a lot of comments are used to break up parts of the logic. The code does a good job in describing what is going on, and the package includes a sample maya (.ma) file to show a simple example of applying an animation onto a cube. The code does follow the traditional MEL paradigm of sourcing the script and then calling the function name (from the script name), but additional documentation on how to use the script is always nice to have.

Reusability: 6
Maintenance wise the code is very small and thus would be easy to refactor, bugfix and change. As it stands, nothing can be used in isolation from the UI, so can not be easily extended or expanded upon.

Overall: 6.5
The code functionality is straightforward and to the point. It is sometimes easy to get into a feature creep with a tool, but the options that are provided are pretty useful and would likely help in certain workflows (especially where a lot of mirroring of keys has to take place).

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

Friday, February 3, 2012

Code of the Day: Animation and Pose Copy

Animation and Pose Copy, Batch Transfer 2.6.5 script by sin3d: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/animation-and-pose-copy-batch-transfer

Animation and Pose Copy, Batch Transfer 2.6.5 is a tool for saving and loading animation to a text file and applying the saved animation information to custom attributes from one object to another.

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

Functionality: 6.5
The functionality is decent, although requires that the joints be keyed before copying. This is fine for a number of workflows, but allowing options to copy keys from selections would be a nice option to have. The UI is pretty good, and does a decent job of mentioning most errors, but still will write out an empty file if no attributes are keyed (it would probably be better to mention that nothing is being written to the user).

Design: 6.5
The code separates out a lot of functionality into appropriate functions, but there are a few places (especially related to the UI) where the code is tightly coupled to the interface. Most of the functions are fairly small, but there are a couple (reading and writing the files) which are quite long, and may benefit from separating some of the logic into standalone functions. The placement of the functions is a little disjointed, and could group similar functions together to improve reader flow.

Style: 5
The code formatting is inconsistent, and bracket scoping, indentation and spacing are not very consistent. The style seems to change quite drastically in places, and uses different prefix naming conventions such as "ac_findNodesWithKeysProc" and "ps_findNodesWithKeysProc" which makes me think there were parts that were used from two different authors (or scripts) and then modified to fit certain needs. This type of function naming is confusing and suggests besides making the code more difficult to read, also duplicates some functionality.

Documentation: 6
The code documentation is ok, the header file does a good job describing at a high level what the functionality does, but the code does not tell you how to run it, and does not follow the traditional MEL structure of including a function with the same name as the script. To run the script in this case run the following in the MEL script editor tab.

source "Anm_AnmCopy";

my_AnmCopyWindowProc();



Reusability: 6
The code does have a few places where code will be reusable and maintainable, and would work as standalone functions. A lot of the code (even writing or loading from a file) is tied to the interface (both in getting variable names and refreshing the function, which could be made separate by separating out the UI and file IO with a wrapper function.

Overall: 6
The code functionality for the poses is quite good and the files saved as text files is a good approach, and gives the user quite a few options to set the directory path. A few more options (should as non-keyed values) would help the functionality, some extra error information would also be helpful, especially in debugging the transfer animation options.

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

Thursday, February 2, 2012

Code of the Day: JP Transfer Anim

JP Transfer Anim 1.5 script by arcsecond: http://www.creativecrash.com/maya/downloads/scripts-plugins/c/jptransferanim

JP Transfer Anim 1.5 is a quick tool for copying animation or custom attributes from one object to another.

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

Functionality: 7
The functionality allows copying of user defined attributes and transferring animations from one object to another. The window allows selections of Transforms, Rotation or Scales (X, Y or Z) values, Visibility or User Defined attributes to be copied. There are also option for copying the Whole Curves or Current Values.

Design: 7
The code is small and compact, and is straightforward in its design. There are only three functions, but what is there is separated logically into UI, transferring animation or copying attributes. The code does make use of a number of silent catches, and there is a bit of duplication between the copy and transfer functions. The code is tightly coupled to the interface and does not have any parameters to any of the functions.

Style: 5.5
The code formatting is a little inconsistent, and bracket scoping are not consistent. There are a few areas of commented out code and a few places where the function names are a bit confusing (function names "jpTransferAnim" and" jpTransAnim"). There are a lot of the same array indexing instead of creating a temporary variable for the same value, which could be renamed something like source and destination to make it clearer than animObj[0] and animObj[1].

Documentation: 7
The code documentation is sparse in places, but the code itself is pretty straightforward so is not necessary. The code header is useful, as are mentioning the current limitations is always nice to see in the documentation.

Reusability: 7
The transfer code is too tightly coupled to the interface to be reusable, but the copy attribute only relies on having a selection so that could be separately called. The code is tiny however, so it would not be too difficult to maintain, extend or refactor as necessary.

Overall: 7
The code is short and simple, but gives a powerful little feature set to quickly copy attributes from one object to another. It is limited in that it can only copy one object at a time, but still would have its uses in certain areas. A few more options would be nice to have, but overall it is quick and fairly effective.

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

Wednesday, February 1, 2012

Code of the Day: Shot View

ShotView 2.3.0 script by cammm: http://www.creativecrash.com/maya/downloads/scripts-plugins/c/shotview

ShotView 2.3.0 is a tool that creates a separate window for working on cinematic camera movement, including a navigator camera (zoom/pan) , playblast options, locking the shot camera and more.

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

Functionality: 7.5
The functionality is quite interesting, especially the navigator window which mimics some of the functionality and design of Photoshop's navigator. There is a fair bit of functionality although the majority of it is related to setting up a separate modelEditor to keep track of the shot.

Design: 6.5
The code uses a number of external preferences files, which is great for reusability, although it uses eval to parse them, which makes me wonder in this particular case why the prefs were not MEL files that were invoked directly. The code makes use of a number of global variables, and in a few places does a lot of index referencing which in a few places makes the code difficult to follow (it is hard to remember what is at array index[9] for example).

Style: 5
The code formatting, spacing and indentation are not consistent and makes the code difficult to read in a few places. The formatting and structure actually improve towards the end of the file, but some of the earlier code would benefit from the standards of the later code. There are areas of code that are commented out, which is unfortunate to see without any additional information about why the code was removed.

Documentation: 6.5
The code documentation is sparse and in a few places some of the comments are just two letters, which doesn't really help except to serve as a marker. The installation file is helpful, and a few places of the code (especially the preferences window), has a lot of information in the interface to help guide the user to the correct actions and explain the code.

Reusability: 5.5
Some areas of the code have small encapsulated functions, which would be reusable. The use of globals and the uncommented array indexing makes a few parts of the code obscure and would likely benefit from a little more information or commenting. A few areas of the code have quite long functions and do not take any parameters, which makes them unlikely to have much reusability.

Overall: 6
The code has a number of nice features, particularly the navigator and playblast, but the majority of the code wraps a separate modelEditor panel with some additional options. Overall, I think a number of people would find it useful, and while there might be a few additional features that could make it a little more flexible, but as it stands, it does have its uses.

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