Workbench – End Of Assignment Report

Long time no update. I’ve had a bit of a rough time lately so haven’t made as much progress as I really should have. That said, I haven’t completed my script to the extent that I had initially intended. Which, in a less flowery language, means I missed the deadline. But that’s okay, because the grades don’t matter nearly so much as the product itself, which I fully intend to continue developing.

What I have managed to finish so far is a fairly complex node wrapping system which (as I have mentioned before) is written in such a way that will be relatively easy to extend to other 3D applications. Well, okay, ‘finish’ is a strong word, but it’s in a working state. So far it supports 26 different node types (which turns out to be about 41 native nodes – I have some node Classes operating on multiple nodes when appropriate. For example the BlendAttributes class will create either a blendTwoAttr or a blendColors node depending on the types of inputs/outputs you pass to it). I’ve set up a ton of methods for all nodes (most on the Node base class which all nodes inherit from, some on the Shape superclass, some on the Transform superclass, and in some specific cases there are some methods on specific node classes (e.g. joints have orientation methods). Those methods handle anything you might need to do with those nodes and serve to replace the maya (and other applications) commands.

I have separate functions for cases where having methods on nodes wasn’t logical (e.g. getting the currently selected items, creating Set Driven Keys, etc), but other than that the node classes are pretty much the basis of the entire system. The components (I’ll get to them in just a sec) that I have written so far work exclusively with those node classes, and the body modules (which I haven’t gotten to yet) are intended to do the same. The major benefit of this is that porting everything over to new applications really only required functionality to be added to the nodes classes and everything else should follow along. Making everything work like that is part of why it’s taking me so long.
There’s also a class for Attributes, which I think I mentioned in another post. The Attributes class operates exclusively using the maya API, and (at least at the moment) the node classes primarily use maya commands (with some API thrown in – for example I use maya function sets to ensure that node names are never stale).

As for the components (for those of you who haven’t read my previous posts, components are what I’m calling my classes that handle common elements in character rigs) I so far have: insertJoints (which is a function rather than a class since joints are a class of their own), Controls, FkChain, IkChain, and FkIkChain.

I borrowed some of my functionality from the control projection tool for the Control class; mostly the shapes saving and loading system. So users can include their own custom shapes and can very easily access those shapes in the Controls class. This class sets up a full control hierarchy, moves and rotates it into place, colors it, locks channels, etc all according to the user’s parameters. Speaking of colors, I use RGB inputs, but if the user is on Maya earlier than 2016 it’ll find the appropriate override color index by treating the colors as vectors. The code for that is pretty simple (ignore the lack of whitespace. Workbench.cmds is maya.cmds. misc.Vector is my own Vector class (or will be… for now I’m just pointing that at maya.api.OpenMaya.MVector):

colorVector = misc.Vector(color)
vectorDifferenceDict = {}
for colorIndex in range(1,32):
colorIndexVector = misc.Vector(Workbench.cmds.colorIndex(colorIndex, query=True))
vectorDifference = (colorVector – colorIndexVector).length()
vectorDifferenceDict[vectorDifference] = colorIndex
color = vectorDifferenceDict[min(vectorDifferenceDict.keys())]

The Control class also have some methods for retroactively transforming the shape node (without affecting the transform node), changing the size, and changing the color.

The FkChain class sets up a control hierarchy (through the Control class) for each joint you pass to it, sets up the orient constraints, and adds a length attribute (if you want). If you don’t tell it which axis to stretch along, it’ll try to find out based on the translate values of the joint’s children.

The IkChain class sets up an IK chain, a main IK control, and a pole vector control, as well as the appropriate constraints. It finds the mid joint if you don’t pass one and uses vector math to find the best position for the PV control. It sets up stretch and volume preservation (if you want them) and uses the same process as the FkChain to find the aim axis if you don’t pass it. It also has a pole vector locking system if you want it for shots where a character is on their knees or leaning on their elbow or such.
Currently spline and mech IK systems are not supported, but they will be by crikey!

The FkIkChain class (if you haven’t guessed it) creates a duplicate joint chain for each the IK and FK control chains, then sets up the appropriate control systems on top of them using the aforementioned classes. It then sets up a switch control, puts it into a position the user passes, and sets up the switch attribute to pass through the appropriate scale and rotate values from the duplicated to the original joint chain and swapping visibility of controls as appropriate.

The reason most of the components are classes and not just functions is because I will be adding methods for deleting, renaming, duplicating, etc, which will make it must easier to retroactively affect ’em.

So yeah. It’s fairly rudimentary in its usefulness so far; it’s basically limited to setting up arms and legs (or any other arbitrary IK and FK chains you may desire). But it’s a proof of concept for what will hopefully become a very powerful rigging platform.
And, as far as the upcoming group project is concerned, it’ll save the hour or longer it might take to otherwise set up a limb’s control system by hand (as well as remove some potential human error). I consider that a win.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s