Thursday, December 08, 2005

Space Switching, animating topology, and eliminating gimbal lock

Among the features I've been trying to solve, space switching on the hands has been a big one.

What I wanted to end up with was a pulldown menu on the hand control that would let you switch seamlessly from the hand being parented to the clavicle, upper torso, hip, head and thigh. Without jumping position when the switch is thrown.

I'd planned to use the xform command. And I did to some extent. But I found using an interim object as a position marker (via my align script integrated into an expression in a scriptJob) and then realigning to it was a bit more reliable. I found that for xform to work, I had to run the same line twice. The first time would throw the hand off in space, and the second would do what it was supposed to. I'll probably revisit removing the interim synchronizer later, but it's working now.

For some reason, everything works perfectly with the autokeyer off. But when it's on, and you scrub, it sometimes drops a key when you stop scrubbing. On both hands, not just the one you have selected. Where the scriptJob should be actuating the expression only when the attribute is changed, as the flag suggests, it seems to detect the changed attribute that's been keyed.

I also found that using the script "live" was unreliable. That is, relying on the script to flip the switch as you went forward or backward isn't fast enough because of the order in which Maya evaluates nodes. So I added channels to the hand that reflect the channels on the parent constraint underlying this whole technique. Set those at the same time the other channels on the hand are set, and it's flawless. With the channels on the hand control itself, connected to the channels on the constraints, an animator can move keys around in the dope sheet without having to worry about channels on some remote object screwing them up.

So now I can animate, and if I want to rest a hand on the hip, I just pulldown "hip" on the "Wrist Parent" channel, and the hand stays on the hip. If the character wants to put his head in his hands and have the hands stick while shaking his head in woe, just pulldown the "head" option. If the character is leading the hand action by moving his shoulder first and you want the hand to follow a couple of frames later, just switch the Wrist Parent to "UpTorso". The other two options are "Thigh" and "World". "World" just does what people usually do with IK hands. The hands just sit in space, waiting for you to move them. The cool thing about this as a simple pull down option, is that when you get that bump from some combination of body moves, but you want to maintain a smooth arc for a few frames, it's just a quick switch away. Switching back with perfectly synchronized hand movement is simple and more important...fast.

This took two days to come up with. There are a lot of logical things that just don't work in Maya, or at least not the way you'd think they would. Of course, now that I know what works, it won't take as long next time ;)

Next up, was finishing off a simple topology control on the head. Basically just two controls on the side of the head that let you pull the upper face of this character like taffy, just as the control on top of the head pulls the top of the head like taffy.

Added rudimentary whisker controls.

Also added, anti-gimbal locking for the hands. First hand control operates Y and Z rotations only, second control handles x rotation only. ScriptJob to actuate automatic selection of both objects at the same time (something I've found quite useful, as used on the ear controls as well). I added a channel to display the X rotation of the gimbal control, but numeric input must be done in the non animatable X channel of first control. The rotation gizmo functions as you'd expect in "gimbal" mode. Only all the X rotation is being done on a completely separate object.

I wish I could make this a little more transparent. Like substituting the "Rotate X" channel for the one on the gimbal x rotate controller. But no dice, at least not yet if at all. At this point the compromise of functionality over transparent elegance will have to be sufficient.

Scripts
I put up my first script on HighEnd3D. sg_syncOb. This is a script I use a lot for making control objects, or just objects that automatically name themselves and locate themselves where a previously picked object is. No nifty GUI, which disappoints some people, but very powerful. Works with multiple selections, a lot of options, including color selection. Makes objects that are non-shading and non rendering. Can parent or constrain the original objects to the new ones. Or not. Automatically picks up the name, parses out mid name object type, and substitutes it for one that is user assigned. The naming scheme should be useful in other scripts.

I commented the script so others who use the script can part it out and add new features or functions. Also, so I could remember what I was thinking when I wrote it.

I'm writing scripts now trivially for searching and getting results line by line so I can paste things into a script faster, sometimes for quickly connecting large numbers of attributes. I've refined script testing so there's less trial and error, or at least the trial and error cycle is faster. Looks like I'll have to come up with my own attribute reorganizing script, because attributeMan.mel didn' t want to work on the hands. Or it would only work on one of the attributes and I couldn't move the new attributes further up the line. So I had to manually reorganize them.

A task for another day.

1 Comments:

Blogger Sean said...

Hey,
I'm curious about your anti-gimbal lock setup. I've seen something similar on Victor Vinyal's demo reel, but I still can't picture how its avoiding gimbal. Could you possibly give more detail?

7:23 AM  

Post a Comment

<< Home