Showing posts with label X. Show all posts
Showing posts with label X. Show all posts

Apr 20, 2007

Quick Trick: Gimbal Lock... Just Ignore It ! ( with a little help from Maya )

Update 2012:
Wow.. this is really old. I`m not sure I would suggest this workflow anymore. At the time of writing I did a lot of my animation by "just looking at it" in the viewport and not looking at how curves were actually driving movement in the graph editor. I have since discovered the magic of actually understanding what the graph editor is telling me and using it to animate more logically ( because its easier to polish that way ). If you use local rotation manipulator, youre STILL going to see curves that make no sense in the graph editor, at the cost of getting that direct manipulation.. euler filter or not. I would try and figure out a way of using the "extra node" approach, where you basically make a controller that rotates your object along its widest and most common axis, and your xyz rotates sit under that extra node as a child. 


Saying that though... I animated for a LONG time without ever looking in the graph editor, and got results I really liked. We change our approaches a lot over time, and that's all good. If you're struggling with this, I would still read the article below and see if it could work for you as it was a winner for me for years.


What is gimbal lock ?

To tell you the truth, despite the fact that I am pretty well versed in the technical side of 3D animation, I never really fully understood exactly what gimble lock is. As I understand it, its when one or more of your controller's rotation axes become "locked" or "stuck" ( or more accurately - stuck on a plane that no longer properly represents the direction of that axis ):



Time and time again I hear animators moaning about gimbal lock, and I am used to seeing many bizarre and long winded approaches to solving it scattered around on the internet. My solution to this odd problem is simply to ignore it! Gimbal lock has practically never been a problem for me, and here's the quick trick to show you how:


Broad workflow technique, and what rotation manipulator you use is the key...

When I first started in 3D animation, I had only a very small level of 2D experience, and none of it professional, but I thought in a 2D way. I still probably don't think 2D enough from day to day, but I never made the mistake of thinking about 3D animation as separate channels of X Y and Z. Many animators do however. They spend too much time worrying about organization of keyframes, only changing the X rotate value if thats all they need to do, and not keying the translation for example if they don't need it on that frame. In my opinion this is a strange and analytical way of working, that takes longer to manage, and takes away from the core experience of animating. I don't care what channels are keyed on what frame, in fact I deliberately key all the channels on an object when I'm finished posing it.

The nuts and bolts of this workflow is that I never use the gimbal rotation mode for my rotation manipulator. I always work in local mode, and Maya is great because its still doing the same mathematics behind the rotations, but its always giving you all three axes to work with, and never locking them. The gimbal rotation manipulator is for people who like to work in the analytical way - they only need an X rotation so they only rotate the X axis. With Local rotation mode setting, you can still only rotate the X axis, but maya will rotate the other axes also ( unnoticeable to you ) so you don't get axes stuck on top of each other.



Its a mystery to me why some people choose not to work this way. I suppose its easier to manage your curves if you only have keys you specifically set, and easier to cleanup and make changes. On the whole, "keyframe messiness" has never really been that much of a problem for me. I like to concentrate on the performance, and if I have specific areas of keys that I need to clean up or delete, I just do it then as I see fit. I'm not saying its wrong or "dumb" to manage your keys so carefully, I'm sure lots of animators are very happy this way and have their own solutions to gimbal lock... I'm just giving an example of a workflow that has worked very well for me.


Euler Filter - your best friend when you work in Local mode...

So what happens when gimbal lock happens in Local mode ?

When you work with Local mode, you never really see gimbal lock happening - in that you never see the axes getting stuck, but you occasionally see the result of a rotation calculation not going entirely as planned, because gimbal lock is under the hood causing problems. See the image below:



I just want to take the arm and rotate it around the Y axis ( green ). I also rotated just a tiny amount around X and Z.. but the main big rotation here is in Y. Notice that after I have rotated into the new pose, my rotation manipulator is still giving me full control of all 3 axes.

So from the images above, you would expect the arm to do a nice clean sweep from the first pose into the second pose. Most of the time that is what happens, but occasionally this happens:



Strange ? yeah. Well its not what I wanted at least. It seems like the arm is going through the torso, and doing a slight weird twisting at the same time... you must have seen this happening before in your animations.
When I first started animating, I used to go in and add inbetweens whenever this happened to fix the problem... it used to really annoy me, because I had no understanding of why it was happening. This is gimbal lock going on in the background, and because you're using Local rotate mode, its kind of "hidden" from you by Maya.
This is where the magical wonder that is the "Euler filter" ( pronounced "oiler" ) comes into action. Maya takes these rotation curves that have become entangled, and reorganises them so we get the rotation we originally wanted - effectively completely solving the gimbal lock problem in one mouse click.



After applying the euler filter, the rotation of the arm is exactly as we "planned" it to look when we set the original poses. There is probably some pretty intense mathematics going on here, but luckily we don't have to worry about that!



So if you choose to work in a certain way, you can effectively just ignore gimbal lock and concentrate on your animation. If you ever see weird interpolation happening on your rotations, just apply the euler filter, watch it fix itself, and carry on animating!