Sunday, March 28, 2010

Blocking Keys Without Setting Keys Video

My last article, Blocking Keys Without Setting Keys, was lengthy so I decided to supplement it with a video walk-through. I hope the video helps to make sense out of everything I previously wrote about.

Blocking Keys Without Setting Keys Video from Lewis Moronta on Vimeo.

Friday, March 26, 2010

Blocking Keys Without Setting Keys!

Ok, so the title to this article may be a little exaggerated, but hey, I'm an animator and it is one of the principles of animation. I will also explain how the title is a white lie by the end of this article...

An important phase in most character animations is the blocking phase. This is where you focus on your golden poses, then phase into your keyframes, breakdowns, and finally, block in your extremes. Assuming you have your planning sketches handy, you would normally start at the beginning of the scene, setting a keyframe on every control while treating every key as drawing. After setting several poses, your timeline can easily become cluttered with red ticks representing your keyframes. If you wanted to adjust the timing of your animation, you would normally select all your controls and scale the keys either on your timeline or the dope sheet.

The Character Set
Aside from the usual workflow, Maya has built in tools, that if used properly, can allow us to focus on the blocking phase without having us worry much about what the computer is doing down at the key level. It is possible to abstract all your rigs' control curves into a single Character Set and capture Poses on a higher level.


The first step is to grab all the control curves on your character rig and navigate to Animation:Character:Create Character Set:Options. Name your set Poser. Select Poser as your current Character Set to the left of the Auto Keyframe Toggle button. Now that you have a Character Set active, navigate to Animation:Animate:Create Pose:Options. Name it bindPose.

The Visor

To see what just happened, open up the Visor by navigating to Window:General Editors:Visor and finding the Character Poses tab. From now on, when when pose your character, your poses will be stored here. If you would like to apply a pose or go back to the default pose you just created, RMB the pose in the Visor and select Apply Pose. Try posing your toon and storing a few of more poses to play with.

The Trax Editor

As you lay out all your key poses, it would be helpful to see them played in time. They are the building blocks of your animations after all. This is where non-linear animation tools comes to the rescue. Allow me to introduce the Trax Editor. This editor alone can fill several chapters in a book so I am only going to to skim the surface of what it can do. Basically, the Trax Editor can play your poses in time, blend them together, which is synonymous with tweening, group blended pieces into Animation Clips, allow you to layer, replace, cycle, mute, stretch, and time warp animations. That being said, let's jump right in.

Open the Trax Editor by navigating to Window:Animation Editors:Trax Editor. Since your current Character Set is selected, you will see a blue strip with the name of your set on it. Drag a pose from the Visor onto here. If you zoom into the block that you just created, you will notice that it will have the name of the pose, and a few numbers. We can overlook the numbers for now--they simply tell you how many cycles of this animation will be played, what percentage it is scaled in time, and how long it is being held for. Basically, if you pull the top right corner using the Shift key, you can extend your holds and if you pull the bottom right corner, you can cycle your animation. If you pull the bottom right corner without using the Shift key, you will scale the animation in time.You can check the Maya help files for more information.

If you were to drag another pose from your Visor onto the Trax timeline, you'll be able to play your blocked animation. Adjusted the timing and holds for each pose is as easy as dragging them around. To blend the poses, Shift+Select two of them on the track and click on the Create Blend button. This will have Maya tween the two poses for you. If you would like to adjust the anim curve in the Graph Editor, select the Blend arrow and navigate to View:Graph Anim Curves... and your animBlendInOut node will appear in the GE.

If you were to look at what is happening here behind the scenes in your Hypergraph, you would see a neatly integrated network of useful nodes making your life easier. Thank you Maya! If you marquee select all your poses and blended objects in the Trax Editor, you will noticed that each pose is indeed recorded with keys--you just didn't set them directly, but you set them nonetheless. This is why the title to this article is a white lie.

In order to be able to edit your animation directly in the Graph Editor, grab all the current poses in Trax and navigate to Edit:Merge:Options and name your animation. You are now left with a bunch of curves that need some cleaning up. You may now use the standard GE utilities to do this.

Best of all, you can treat this animation as a whole. If you would like to change the timing of it, try scaling the clip or applying a time warp node to it. You can also chop up this clip into little pieces and eat it for breakfast. After you do that, you can even merge it with new clips you create. If this is not enough, you can still set keys on the timeline during the refining stage of your animation to give it that extra polish.

Oh, one more thing, you can always go back to your controls and bake the channels if you do not want to work in the Trax Editor at some point. It is easy to go back and forth between these workflows.

I hope have you enjoyed this article as much as I had writing it. Comments?

Sunday, March 7, 2010

Creating and Baking Expressions

In this week's Maya Tip, we'll work through creating expressions and using the motion data to create anim curves that we can edit in the Graph Editor. Expressions are custom algorithms that you can write in a modified version of MEL script that can be linked to almost any node in Maya. This might sound complicated but in reality it can be as simple as connecting one value to another by writing a simple expression like ty = frame; On the left of this expression, you see the attribute that is being modified and on the right you see the value that is being assigned to the attribute on the left. Maya uses a reserved variable called frame to store the current frame number.

Start a new Maya scene and throw a NURBS sphere on the stage. Select its Translate Y attribute in the channelBox.  Navigate to the Edit menu in the channelBox and select the Expressions... item.

This opens up the Expression Editor. You should now have nurbsSphere1.translateY as your Selected Object and Attribute. In the big text box below (labeled Expression) is where we can type in the following: ty = sin(frame); Press the create button. You have now attached an expression node to your ty of your sphere. The connection is indicated by the purple tint in the channelBox.

Go ahead and play your animation and you will see your sphere bobbing up and down. It is a bit fast, so let's slow it down by decreasing the frequency of our sine wave. If you closed the Expression Editor, open it back up by going to Window:Animation Editors:Expression Editor. Make sure the sphere is selected then Select By Expression Name from the Select Filter menu. This will allow you to retrieve any expressions you created on your sphere (or any other object.)

Our current expression should be named expression1. Click it and you should see that Maya expanded our code to read: nurbsSphere1.translateY = sin(frame); Enjoy the fact that Maya allows you to write shorthand in the Expression Editor! Divide the frame number by some number to reduce the frequency. I divided it by 6: nurbsSphere1.translateY = sin(frame/6); Click Edit to commit the changes and then play the animation.

Just for fun, link another attribute in the same script window by writing this code on the next line: nurbsSphere1.rotateZ = cos(frame/6); Click on Edit again to commit the changes.

Play the animation again. Notice that the sphere barely moves in rz. This is because Cosine returns a value from -1 to 1 and these angle values are very tough to detect when the ty motion is in effect. This means we need to increase the amplitude a bit. Do this by multiplying the trig function by the angle range you would like to see in motion. I multiplied mine by 10: nurbsSphere1.rotateZ = cos(frame/6)*10;

If you know some MEL, you can really go crazy in the Expression Editor. But for now, let's bake this simulation so we can edit the curves in the GE. Select the sphere and visit Edit:Keys:Bake Simulation. Open your GE because it is time for some cleanup. Luckily, the GE has a function that can do most of it for you. If you select the ty anim curve, you'll notice there's a key on every frame. There are ways to have the animation bake with less keys but let us continue with this example so we can use another useful tool.

Select the entire ty anim curve in the GE and navigate to Curves:Simplify Curve. You will find that the function approximated your baked data using less keys. Now you are at complete freedom to edit this curve any way you please.

I hope you found this tutorial useful.