Pages

Showing posts with label maya. Show all posts
Showing posts with label maya. Show all posts

Saturday, March 16, 2013

CGS Head Rig Animation

Hey everyone! I want to share my latest animation. I rigged the head over several weeks and animated it in the past few days. I haven't worked on any corrective blends yet so I'm still open to critiques. The animation is meant to push the limits of the rig. Thanks for watching!

Wednesday, March 13, 2013

Angle Based Deformers

What I am about to talk about is closely related to Pose Space Deformers--I’m sure you can find the original SIGGRAPH PSD papers online. However, the setup I present below is a simple network that allows you to trigger actions and/or blends based on the angle between two vectors. Vectors save the day once again…

Why ditch Euler angles when we already have angle positions?? Because of the nature of Eulers, the X, Y, and Z components are calculated in a specific way that won’t work in many situations. One of the main reasons for this is Gimbal Lock. This one reason can make things a living nightmare for us.
Using the dot product, we can find the angle between two vectors, A and B, by using the following equation:

Θ = acos(A · B)

This means that if we were to attach a locator to a pair of adjacent joints, where both locator’s origin is positioned where the joints connect, you can find the arc cosine of the dot product of both of these vectors, and return the angle between them. I know… it sounds wordier than it really is.

Here’s how I set this up in Maya:
psdNetwork_v01

To be able to see the results of my network, I attached the output of setRange to a blendshape channel. I then animated the joint driving the location of a locator to get a change in the angle between locator1 and locator2. Maya’s angleBetween node returns 0-180, so I scaled that value down to 0 to 1 using the setRange node.

We could have just as easily used an expression to put this example together. However, I prefer to stay away from expressions for anything that I can build using nodes. Native nodes evaluate faster and you can’t break their dependencies by duplicating the network or changing their names!

I hope you can find many uses for this angle based setup. Let me know what you come up with!

Saturday, February 9, 2013

NURBS Curves: How to use Knot Vectors

When working in Maya, we create curves freely without crunching numbers. We use them in Maya Hair, Spline IK rigs, Motion/Flow paths, as control curves for characters rigs, create them procedurally for modeling, amongst other uses. My goal in this post is for you to better understand how to generate curves using knot vectors.



Linear curves are simply lines that follow the standard y = mx + b formula. In Maya, they are created as a curve of 1 degree. That means that the highest power in the equation is 1. In theory, this curve type has 2 knots. The relation between knots to CV is: #knots = (#CVs+deg -1).

string $curve = `curve -d 1 -p -2 0 0 -p 2 0 -2`;

Simply pass in your two points, and tell Maya that you’re drawing a linear curve. Let’s attach a curveInfo node to this curve and poke around a little bit.

string $cInfo = `arclen -ch 1 $curve`;
getAttr($cInfo+".knots[*]");

// Result: 0 1 //

 
It seems that there are two knots on this curve that are weighted to each CV on the curve. Using #knots = (#CVs+deg -1), we know that we have 2 CVs on a curve of 1 degree, minus 1: that’s 2 knots. So we know that checks out.

Before we investigate further, let’s try the same thing with a quadratic curve. Behind the scenes, Maya will draw the smooth curve using an equation where the highest degree order is 2. Since we all miss our high school math classes, let’s draw a parabola:

$curve = `curve -d 2 -p -1 0 -2 -p -1 0 0 -p 1 0 0 -p 1 0 -2`;
$cInfo = `arclen -ch 1 $curve`;
getAttr($cInfo+".knots[*]");

// Result: 0 0 1 2 2 //

 
We have a curve of 2 degrees, we plotted 4 points, minus 1: that’s a total of 5 knots. The collection of knots on a curve is referred to its Knot Vector. However, what do these knot magnitudes mean? Each element in the vector determines where in parameter space the curve will be drawn. I know that’s a very vague statement but please stay with me!

Think of the first and last points on a curve as an anchor. This is the most common type of knot vector: Pinned Uniform Knot Vectors. Each anchor needs to be held down by the same number of knots as the curve’s degree. In our first example, we had a curve of 1 degree being pinned down by one knot on each end point. In our second example, we had a curve being held down by 2 knots on each end point.

So then what does the 1 mean in the [0 0 1 2 2] result? It turns out that these numbers are arbitrary. The number values don’t matter in a Knot Vector. Say what? Yes, that’s right. What matters is the ratios of the values to each other. The main rule is that Maya requires each knot’s magnitude to be in ascending order. So what happens if we create a curve but mess with that middle knot? What results will we get? Let’s try it!
curve -d 2 -p -1 0 -2 -p -1 0 0 -p 1 0 0 -p 1 0 –2
      -k 0 -k 0 -k 0 -k 2 -k 2;
By specifying the knot values to the curve command, it seems we have created a curve with non-uniform weighting. We modified the middle knot in a way that we made the curve appear discontinuous.

Just for fun, we can weight the center knot to the other end to get a mirrored result.
curve -d 2 -p -1 0 -2 -p -1 0 0 -p 1 0 0 -p 1 0 –2
     
-k 0 -k 0 -k 2 -k 2 -k 2;
Go ahead and release the pins on this 2nd degree curve. Notice that you can easily un-anchor the curve from their start and end points by simply supplying different weights. This also makes your curve a lot shorter. This is something you need to try for yourself because it’s one of those things that are too abstract in words.

Uniformly distributing our knots makes our NURBS curve simply a B-Spline. Having the ability to specify and interactively adjust the knots is a feature of NURBS, or Non-Uniform Rational B-Splines. Allowing a partial knot weight is a nice feature:
curve -d 2 -p -1 0 -2 -p -1 0 0 -p 1 0 0 -p 1 0 –2
      -k 0 -k 0 -k 1.5 -k 2 -k 2;
curve -d 2 -p -1 0 -2 -p -1 0 0 -p 1 0 0 -p 1 0 –2
      -k 0 -k 0 -k 0.5 -k 2 -k 2;
Finally, to nail the point, let’s try drawing an pinned cubic curve with a degree of 3.
curve -d 3 -p -1 0 -3 -p -2 0 -2 -p 0 0 0 -p 2 0 -2 -p 1 0 –3
      -k 0 -k 0 -k 0 -k 1 -k 2 -k 2 -k 2;
Notice that I used 3 pinned knots to hold down the end points. The middle knot is exactly half way between 0 and 2. This makes the curve uniformly weighted. If you have questions, please let me know in the comment section! I’m sure there are things I can clarify. I want to be sure the information comes through clearly.


Notes:
- Maya seems to ignore knot magnitudes on linear curves.
- When creating curves with the -pointWeight flag, accurate knot values are not returned.
- When editing curves created with the -pointWeight flag in the viewport, the curves seem to snap to a weighted value of 1 to each CV.





Wednesday, February 6, 2013

A List of My Favorite Books

Several people have asked me about what resources I use to learn my favorite topics. There are informative videos and written tutorials scattered all over the web, and only but a few are concise, efficient, and well prepared. This is why I rely mostly on books that are written by seasoned professionals that know a thing or two about teaching. Here is a list of the books I am in love with:

  • MEL Scripting for Maya Animators
  • Mastering Autodesk Maya
  • Stop Staring: Facial Modeling and Animation Done Right
  • Maya Python for Games and Film
  • Complete Maya Programming I & II
  • Art of Rigging I & II
  • Professional MEL Solutions for Production
  • Maya Visual Effects: The Innovator's Guide
  • 3D Math Primer for Graphics and Game Development
  • Game Development with ActionScript

These gems are not listed in any particular order but MEL Scripting for Maya Animators was the first book I ever read on MEL, or Maya for that matter. I bought the very first edition of that text because I was looking for a source of inspiration when I was stuck at home writing Game Development with ActionScript. They are both considered oldies as far as technology goes, so they might be tough to find.

Saturday, February 2, 2013

Understanding 3D Vectors

DISCLAIMER: This post covers the vector type in Maya. If you are new to vectors, please acquaint yourself with them and review the help docs before reading this post. I tried to keep this post as light on math as possible, however, I will clarify where needed, based on your suggestions. This is a huge topic and this post merely summarizes how useful vectors are.

User Guide > Scripting > MEL and Expressions > Useful functions

Let’s break one of our toys apart and learn how things work from the inside out. The knowledge we acquire from doing this allows us to build bigger and better toys. In physics, a vector is described as an entity that has both a magnitude and a direction. In MEL, a vector is represented by x, y, and z components. These components can be combined back into their scientific form at any time. Vectors can represent a location in space, the velocity and/or acceleration of an object, tracing rays between two points, etc.

Retrieving a vector’s magnitude is trivial in MEL:

vector $A = << 1, 2, 3>>;
vector $B = << 3, 2, 1>>;
int $length = mag($A);


Finding the direction vector can by done by using the unit function.

When you perform arithmetic with vectors, the output is considered the resultant. Addition yields a vector that is said to be a diagonal in a parallelogram.

This is interesting to us because if you were to take the B and move a copy (by adding it to A) to the head of A, we build ourselves a triangle that can used to solve for solutions. If we then move a copy of A to the head of B, we end up with a parallelogram. When you subtract a vector from another, the resultant yields a magnitude that is the distance between the heads of A and B. If you take B-A (, which is not the same as A-B, ) and add it to A, we have ourselves another triangle. Still with me? This is only possible because a vector can be equal (& parallel) to any other vector in space as long as they are equal in direction and magnitude. So if you need to reposition a vector, do so by adding it to another vector location. That was the heaviest paragraph in this post, I promise!


By multiplying a vector by a scalar value, we are simply scaling the the vector’s magnitude by that number. There are other types of vector products that are extremely important in computer graphics, the dot product, which yields a scalar value, and the cross product (, which yields another vector perpendicular to the first two. Nuff talk, let’s get to work.



In Maya, create 4 locators. Name them A, B, C, & D. In the script editor, retrieve their world space positions and store those values in vectors. Imagine each locator to be a ray, that originates at the origin, and each locator shape being the vector’s head. Spread the locators in space away from the origin and each other, arbitrarily and for variety.

Make C perpendicular to the first two, by taking the cross product of A & B and move C to the resultant. Now that you know that C perpendicular to the first two, there’s a good chance there is one axis that is not perpendicular to another. You can verify this by taking the dot product of two vectors. If the dot product is not 0, then your vectors are not perpendicular.

TIP: Make the result of AxC a unit vector, a vector with the length 1, by using the unit function on C. The 'x' in this notation signifies we're taking the cross product of these two vectors.

Anyway, take the cross product of A & C, and feed the result to B. You now have 3 axis that are perfectly orthogonal to each other. Assuming that A was already at the “lookAt” location, let’s place D along A’s axis, but with a magnitude of 1. Vectors of this length are called unit vectors. The process of getting this result is call normalization.

Normalize A and pipe the results right into D. You now have solved for the same things that the aim constraint solves for in most 3D software, including games. If you were to normalize all 3 orthogonal axes, you would have what is called an Orthonormal Basis.

Here's a code snippet:

// 3D (Basis) Vectors
// By Lewis M., 2013
// Usage:

// Arbitrarily place four locators in the scene
// Name them A, B, C, & D


// Retrieve A & B's locations
float $a_coord[] = `xform -q -ws -t A`;
float $b_coord[] = `xform -q -ws -t B`;


// Find an orthogonal vector to both A & B

vector $a = <<$a_coord[0], $a_coord[1], $a_coord[2]>>;
vector $b = <<$b_coord[0], $b_coord[1], $b_coord[2]>>;
vector $c = cross($a, $b);
vector $d;


// Scale it down to the length of 1
$c = unit($c);
move -a ($c.x) ($c.y) ($c.z) C;
print dot($a, $b);
// Most likely not zero

// Adjust B to be orthogonal to both A and C
$b = cross($a, $c);
$b = unit($b);
move -a ($b.x) ($b.y) ($b.z) B;


// Finally, scale down A and place D in the position
$d = unit($a);
move -a ($d.x) ($d.y) ($d.z) D;


// Just for fun, draw some visually appealing curves
curve -d 1 -p 0 0 0 -p ($a.x) ($a.y) ($a.z) -k 0 -k 1 ;
curve -d 1 -p 0 0 0 -p ($b.x) ($b.y) ($b.z) -k 0 -k 1 ;
curve -d 1 -p 0 0 0 -p ($c.x) ($c.y) ($c.z) -k 0 -k 1 ;

//grid -tgl 0;
//refresh;


As an exercise, you can use MEL, Python, or even utility nodes to create the connections.

Utility Nodes

Above is a picture of my little aim constraint node setup.  It differs from my discussion above because this version is interactive. In this version, I am able to position A wherever I want and have the other locators automatically update. The NURBS curves you see there are strictly for visual appeal 

Thursday, January 31, 2013

Useful Regular Expressions

Regular Expressions, or RegEx, are very powerful string parsers that are usually built into most popular programming languages. Both MEL and Python have a version that can be used to speed up your every day scripting tasks.

Just the other day, I rewrote my sav+.mel script in python; it versions up the current file with the click of a button... It's so convenient to use and made me think of sharing some of the tools that I used to write it.

Anyway, in MEL, two commands you should know are gmatch and match. gmatch lets you know if it found a match, by returning a boolean, and match returns the string result. Let's say you wanted to extract information from a path:
 
string $path = "C:/folder/image01.jpg";
// Note: Windows users might want to look
// into using substituteAllString($str, "/", "\\")
// to replace those '/' with '\' or
// vice versa, as needed 

There are a few important pieces of information that we can immediately extract using RegEx. To extract the file name with its extension, try:

// This says: Starting from the end of
// the line ($), extract every character
// that is not a '/' or '\'
// As soon as it finds an '/' or '\',
// it stops the match and returns the
// string it gathers thus far
string $fullName = `match "[^/\\]*$" $path`;

To extract the file name, try:

// This expression matches everything from the
// beginning of the line (^), except '.'
// After it encounters the '.', it ceases to
// match and returns the string
// Notice we are feeding it the result from
// the previous line above... 
string $fileName = `match "^[^.]+" $fullName`;

To get the extension by itself, execute this line:

// This says: From the end of the line,
// find anything up until the '.' or '\'
// Note that if there isn't a file extension,
// the $result will match the original $path
string $ext = `match "[^/\\.]*$" $path`;

To extract any trailing version numbers at the end of the file name, try:

// This says: From the end of the line,
// extract some digits. It's a good idea
// to check if the file name even trails
// with numbers before extraction by using
// gmatch with the same expression
string $ver = `match "[0-9]+$" $file`;

Now that you have all this data extracted, store it as useful information in an object. Unfortunately, MEL isn't an Object Oriented language so there is no straight forward way to create a class of objects that encapsulates attributes and behaviors. You have full support for these things when using C++ and Python. Here's how I would store the info in MEL:

// Now all the information is neatly packed in an array
string $fileInfo[] = { $path, $fullName, $fileName, $ext, $ver };
print $fileInfo;

If you guys and gals would like to know how to extract other pieces of data from strings, let me know. I'll be happy to discuss similar topics as well. I'll write up another post.




Saturday, December 22, 2012

Wednesday, February 22, 2012

The Stray

Here's how a stray dog calls for back up. I spent all of last week animating this puppy. I hope you like it!

Sunday, February 19, 2012

Missing Parts

Next time you sign up for something, read it through thoroughly. Or parts can go missing...

Wednesday, February 1, 2012

Professional Advice

Happy New Year everyone! This blog has been mighty quiet lately since I've been in my cave updating all my older shots. I spent the entire month of January updating and tweaking the crap out of "Professional Advice."

Here's a toon handing out unsolicited advice. Bad things happen with toons do things they are not supposed to do... like shaking neon chemicals before mixing them with other explosive elements!

Tuesday, October 19, 2010

Maya, What Do Those Weird Color Codes Mean?

I work with Maya every day and I really enjoy our relationship. I love learning things about her and I also love teaching others what I've learned. I'm all about shortcuts and efficiency. Maya can get cranky if you don't notice her communication signals within your pipeline so it's best that you learn her mannerisms. If you don't, she will crash your file. Trust me.

I recently noticed that many people haven't noticed what the channelBox color codes mean. If you haven't noticed these, I recommend you look closer. This knowledge can aid you if something goes wrong... and sometimes it does.

When a channel is orange, this means the attribute is connected to an animation curve . When the channel is yellow, it means the value has an incoming connection or is shared with another object. Usually that object is a character set or the object has dynamic forces affecting it.

When the object is purple, this means that there is an expression driving its value. When the channels are blue, this means it is driven by a constraint.

If the channel is either gray or light gray, this means it cannot be animated and/or it is locked.

You can mute a channel so it has no affect on the scene--when you do this, the channel is coded brown. And finally, the channels can be coded green, meaning that its value is blended with another attribute.

Sometimes the way things are connected in the Hypergraph can affect the way things behave and are computed. Noticing the wrong color on your channel can indicate early signs of trouble. I hope this brief note has been helpful.

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.

Saturday, February 20, 2010

Animating Hidden Keyable Attributes

When taught to animate in Maya, we tend to become very comfortable with the channelBox, but the channelBox only offers a small portion of all the attributes we are able to animate. The keyable attributes you see in the channelBox are usually only the most common ones available to you. In this tutorial, I will describe how to locate, setup, and animate the color attribute on an object that has a Phong shader connected to it. After acquiring this knowledge, I encourage you to experiment with other keyable attributes. In a later edition, I will show you how to animate non-keyable attributes.

Let's start out by creating a simple NURBS sphere on the stage and by pressing 5 on your keyboard so you can see the sphere shaded gray. What you see is a default Lambert material that is assigned to NURBS objects at creation. Let's right click the sphere and assign a new Phong material to it. Open your Attribute Editor by pressing Ctrl+a and find the phong1 tab. Make sure your playhead is on frame 1 because we're about to key a color. Locate your color attribute in the Attribute Editor under the phong1 tab. Right click it, then click on Set Key.

At this point, it appears nothing has happened. There is no red tick on the timeline and Maya did not alert you of a change. If you look to the right of the color slider, the checkered box turned into the input symbol. If you click it, you'll see that the color attribute is now an input to an animation curve!

After clicking the input symbol, you should be on the phong1_colorR tab of the phong1 Attribute. Under the Keys section is a charted version of the keys you set on this curve. This isn't too user friendly so let's bring this up in our Graph Editor. Wait a second? We need to be able to select this object before the Graph Editor can load it... that means we'll need to open up our Hypergraph so we can find and select the object.

Select the sphere you created and go to Window:Hypergraph:Connections. Find and select the phong1SG (read: phong shader group.) Let's graph the input connections by navigating to Graph:Input Connections. Viola! You are now looking at phong1_colorR, phong1_colorG, and phong1_colorB. You can select them and they will appear in your Graph Editor. You are now able to modify the curve as you see fit and best of all, since it's a color that you're animating, you get an instant preview in your viewport.

To finish the exercise, hold k+LMB and click on frame 24 inside the GE. Hold i+MMB to insert a key. Now press w, select the key you just created and move it up to give it a value of 10. You have just created a glowing light. Select Curves:Post Infinity:Cycle to give it a pulsating effect.

I hope you have found this tutorial useful. Please experiment with this technique and share your experiences.

Friday, February 12, 2010

More On The Graph Editor

Being able to buffer curves and having the ability to mute/unmute tangents are useful tools when refining an animation. Using these tools along with ghosted frames and motion trails (to check spacing and arcs) will give you the tools you need to create high quality shots.

Let's say you had an animation of a bouncing ball (and who doesn't?) In this animation, you probably are using more than one animation curve so it should suffice for this example. You are able to temporarily silence curves that are interfering with your motion by selecting the channel(s) in the graph editor and muting them. This will cause the curve(s) to flatten out and behave as though there were no keys set on them.

You can find the mute item under your Curves menu of your graph editor.


Using our simple bouncing ball example, you can try muting your horizontal anim curve so you can focus on the vertical motion of the ball. Conversely, if you wanted to focus on the rolling and settling of the ball, you could then mute the vertical motion. If you were swinging a pendulum in a figure 8 motion, the same rules still apply.

When muting a curve in the graph editor, there will be a little symbol next to the channel indicating that it has been muted. The original keyed anim curve will become a dotted curve and the temporary replacement will become a flat solid line. You can unmute the curve(s) from the Curve menu in your graph editor.


Handling one dimension at a time by muting channels you temporarily don't need is useful but sometimes this isn't enough to help you tweak efficiently. At times, you need to edit two or more channels at once and when this happens, your arcs and spacing become priority.

To check out your spacing, go under your Animation menu set and under the Animate menu, you'll find the Ghost Selected item. Go ahead and reset the settings one by one based on your situation. I usually like having 2 keys ghosted after and 1 key ghosted before. Or having two steps ghost after and 2 steps ghosted before.


Once your spacing is neatly arranged, you will want to double check the arcs that your objects are moving in. Do this by switching on Motion Trails. You can also find this one under the Animation, Animate menu. You can have it update when you change a key--you can also have different display styles for the tool. My favorite display style is the line type because it visually plays "connect-the-dots" with all my keys.


As far as I know, there is no magic "remove motion trail" button. However, you can delete the trail by selecting it and pressing delete.

Using Buffer curves can be a life saver. As animators, we're used to having multiple files for the same scene and sometimes this is true even if there is a minor tweak on a curve. Buffer curves can make your work more efficient by allowing you to test out different key configurations without throwing away all the hard work you put in.

Before you use Buffer curves, you need to switch them on in the graph editor view menu.


Once you are ready to tweak an anim curve and turned on Buffer curves from the view menu (in the graph editor), you can select the curve and go to Curves->Buffer Curve Snapshot. This "saves" your current configuration for your current maya session. You can now start tweaking until you can't tweak anymore. You'll be able to see the original curve ghosted in the back but if you don't like what your new curve is doing, you can always go to Curves->Swap Buffer Curve.

A small note on weighted vs. non-weighted tangents: I disagree that it should always be one or the other. I think it's fair to say that it's best to use the right one for the job. I generally start out with non-weighted tangents but if I find my particular situation better fitted for weighted, then I will switch to weighted tangents.

A pro of weighted tangents is that they require less keys since they use different math to interpolate the curves. A pro with non-weighted tangents is that they can scale uniformly without a fuss.

A con of weighted tangents is that they do not always behave when you scale them. Sometimes the tangents reset and act funny especially if you have stretched too much. There is plenty round off error to pull this off successfully. A con of non-weighted tangents is that they require more keys to do the same thing a weighted tangent can do.

I hope this follw-up tutorial has been helpful.

Thursday, February 11, 2010

Graph Editor Tangent Types Explained

Some of us have become overwhelmed with all the tangent types that exist when we first meet the graph editor in Maya. Knowing when to use what type of tangent and which tangent type is preferred is often baffling. However, I feel that if you understand the differences between the tangents themselves, their purpose will all become clear. The following few paragraphs describe tangent types in simple terms. I hope this is useful for those that are quietly wrestling with your anim curves.

Spline, linear, and stepped tangents are the 3 basic tangent types. One uses zero interpolation between keys: Stepped Tangents are good for blocking. Another tangent type interpolates evenly (linearly) from one key to the next: Linear Tangents. And finally, the other basic tangent smooths all the paths between keys. These are the Spline Tangents.

The Flat Tangent is good for peaks and valleys of your curves... if you want to prevent a spline value from not overshooting, you can set it to flat. This will ensure that the highest or lowest value is the highest or lowest value between affected keys.

The Clamped Tangent is a mixture of flat and spline tangents. The clamped curve is all spliney, however, there is one exception. When two consecutive keys share the same value, they will automatically "clamp" by flattening out. This is usually used for holds... like when you have a footstep that needs to stick. The foot shouldn't move from its position until it comes off the ground.

Finally, my favorite one is the Plateau Tangent type because it is like a clamped tangent on steroids. Unlike clamped tangents, it will flatten out the first and last keys. Any keys in between a peak or valley will be treated like a spline. I like to set this type as my default.

I hope this clarifies a few things for those that were struggling with tangent types. Please leave a comment if you want to discuss the graph editor further.

Monday, February 1, 2010

Useful Maya Hotkeys & More Hidden Menus

Welcome to the month of February! I'll start this month off by talking about important hotkeys that I use when working in Maya. I recommend using hotkeys because I believe in spending more time with your work and less time in the menus. I originally wanted to include a few of the most frequently used hotkeys but let's face it, Maya isn't Microsoft Paint. It is huge! I didn't even get to go into the hotkeys for Artisan, the Graph Editor, or even the all-important Outliner! These are core components of Maya and I should cover using them in the future.

Make These Basic Hotkeys Part of Your DNA
To the left of your backspace key, you have your - and your + keys that adjust the size of your current manipulator. Adjust your manipulators when geometry gets in your way. Parent things using p and unparent them using shift+p. Duplicate objects using ctrl+d. Press h to hide selected objects and press shift+h to show selected objects. The 4 key displays your objects in wireframe while 5 displays them in shaded mode. Press ctrl+g for creating a group of objects or deselect everything to create an empty group. Empty groups are super useful but that's a topic all on its own.

One of my favorite things in Maya is the ability to toggle UI elements and going into fullscreen mode by pressing ctrl+space. Toggle back by using the hotkey again. The a key frames all objects while the f key frames selection. If you hold shift while using these keys, it will do this operation in all your current views.

The q key is your selection tool. This is an important tool because it doesn't let you do any harm. It only allows you to select things. I find myself using q often when I simply want one of the w, e, or r manipulators to disappear.

Temporarily hide everything around the currently selected object by pressing shift+i. To get everything back, deselect the object and press shift+i again.

Make Animation Hassle Free By Learning These Hotkeys
The alt+v combination plays and stops your animation while alt+shift+v rewinds it. The , key goes to previous keyframe while the . goes to the next keyframe. If you hold alt while using hotkeys, you will step one frame at a time. Use k+LMB to use an awesome the time dragger tool. Press alt+b to cycle your background color in the viewport. Keyframe your translates by pressing shift+w, key your rotation by pressing shift+e, and finally, key your scale by pressing shift+r.

[This would be a good time to take a break and try out some shortcuts if you are new to Maya.]

Another Hidden Marking Menu
When I first fire up the program, I usually get a blank grid. If I were to start modeling, I would need some geometry on my grid so the first thing I would do is hold shift+RMB gesture down in the viewport. This will create a polyCube for me. If you want to go back to that (context sensitive) menu, you'll have to deselect the cube (and everything else you have selected) and drag your RMB to see what else is there. This is the rapid fire way to create geometry. There are a few more hidden menus, but I'll save these for future posts.

Try These Hotkeys Out While Editing Objects
I like using F8 to go into component mode, but you can get even more specific by using F9 to dive into vertex mode, F10 for edge mode, and F11 for face mode. You can also use < and > to shrink or grow a selection of a component.

Switching menu sets can get clumsy so I use my hotbox for all menu sets. Press space to access this baby. It's the quickest way. Other ways to get to your menu sets are to use the F2-F5 keys to switch the sets or use the h+LMB marking menu. Give it a shot and see which one you like.

Snapping can come in handy especially when snapping with MMB. Using MMB instead of LMB allows you to click and drag anywhere on the viewport instead of being forced to use the manipulator. Snap to grids by holding x, snap to curves by holding c, and snap to points by holding v.

A Final Word
I should have known this tip was going to be lengthy--I even cut a bunch of stuff out. Either way, please communicate what you would like for me to explain if something doesn't work out for you or if something isn't clear. I know these hotkeys are in the numbers, but I encourage you to try them out. It is worth the effort to memorize these because your workflow will improve dramatically if you cut out all the menu searches down to a single key combo.

Monday, January 25, 2010

Creating A Slider Control GUI Without Using Mel

This week's tip is geared toward riggers & animators alike that prefer all their frequently used controls in their prime work area: the viewport. I enjoy working fullscreen [Ctrl+Space] and I feel that time spent on panels like the channelBox should be minimized and used for animating! So if you find yourself constantly using the virtual slider (that is, selecting the attribute name and then sliding with MMB in the viewport,) then read follow the following tutorial and see if it affects your workflow in a positive way.
  1. First create an empty group called sliderControl.
  2. Then create a NURBS square and stretch out the box—My scales are ScaleX: 8, ScaleY: 0, and ScaleZ: 0.25. Everything else is left default.
  3. Now place a circle with a radius of 0.5 on the origin.
  4. Rotate both objects about their X axis 90 degrees and freeze their transformations.
  5. Now in the outliner, MMB the circle and the NURBS squares' group and tuck it under sliderControl.
  6. Now select the circle and open up the attribute editor.
  7. Select the circle's transform node and open up the Limit Information rollout.
  8. Check Trans Limit X for Min and Max and set them to -4 and 4 respectively.
  9. Set the limits Y and Z limits to 0 and Lock and Hide the rest of the rotate and scale attributes.
  10. Finally, Lock and Hide the Boxes' attributes too.
Now, what you are left with is a slider control that can be turned into an Asset (Maya 2009+) and reused in all your files. You can link the slider knob to any attribute like a foot roll or fist control that requires a range. You can even attach it using an expression if you need to scale the range. However, if you are new to Mel, I recommend adjusting the Limit Information on the circle instead of scaling the values using code. You can link the circle's tx attribute to another attribute using the Connection Editor.

I hope you liked this tip and most importantly, I hope you find it useful.

Thursday, January 21, 2010

Improving Workflow Using Hidden Marking Menus in Maya

I enjoy a smooth workflow and I rather memorize hotkeys to clicking 5 times to get somewhere. Maya has so many menus that it even has a "Find Menu..." feature! This beast of a program, has many hidden marking menus and I would like to share several with you.

When posing Stu's parts, there is no doubt you've used the Move Tool manipulator--if you were to visit the options panel for this tool, you will be able to see that you can switch the orientation of the tool from local/object to world space. At times, it might be easier to use one space over the other--but visiting the Tool Options is clumsy (for me), especially if all I need to do is get to a radio/toggle button.

Assuming your caps lock key is off*, you can press and hold q, w, e, or r to get marking menus for the selection, move, rotate, and scale tools, respectively. You can make gesture adjustments on the fly without leaving your workspace and even work in maximized viewport mode--that is, selecting your viewport and Ctrl+Spacing it.

For example, if you were to press w (to select the move manipulator), and then hold w and LMB drag the mouse to the left, you'll set the manipulator to world space. If you gesture to the north west, you'll set it to object space. This will come in handy when posing Stu's limbs.

* Make sure you keep the caps lock key off while using keyboard shortcuts in Maya because this program is case sensitive. Note that pressing W versus w will actually sets a key on your object's translation vector. The same goes for E and R.