Friday, 6 March 2020

Interactive interpolation visualisation tool

Here's a nice tool for visualising bezier curves, and how they're made.
This was really helpful when coding up my own lerp (linear interpolation) python library and writing a recursive bezier function.

Here's the main lerp algorithm in a python function to start you off:

def lerp(input1, input2, step):
    """ Linearly interpolation between input1 and input2 given
    a value between 0.0 and 1.0.
        input1 (int): starting integer to lerp from.
        input2 (int): destination integer to lerp towards.
        step (float): float value between 0.0 and 1.0
    return (1 - step) * input1 + step * input2

Tuesday, 29 October 2019

Maya Sine Node

Ever wanted a sine node, but realised maya doesn't have one, so you have to use an expression?
Well.. turns out Maya does have one after all!

Karolis Galkus posts this great tip on using the eulerToQuat node to drive sin and cos here:

Thanks to Chris Lesage @ for making me aware of this.

And while we're on the topic of sine, I always refer to this page (and have done for years) when trying to visualise sine and am in need of reminder of the algorithm:

But all you really need to know is: sin(time * frequencyMultiplier) * amplitude) + offset;

Tuesday, 10 September 2019

Convert MEL to Python

Still converting MEL to python the oldschool way by deleting semi-colon here, adding a bracket there?

Pffffttt just use this!

import as mel2py

print mel2py.mel2pyStr("""spaceLocator -p 0 0 0;""")


spaceLocator(p=(0, 0, 0))

Remember to add a cmds. to the start, because for some reason it doesn't add it on for you!

Now you can just replace 'spaceLocator -p 0 0 0;'  with any other MEL code that the script editor may spit out whilst you're Maya'ing and BAM insta-python!

Sure, it doesn't work for all cases but for other cases where you just want to copy & paste a handy addAttr line and can't be bothered to google it, it can come in handy and help speed things along.

Wednesday, 7 August 2019

Free Soft IK plugin - ToolChefs

A handy new plugin that handles all of the math of the main functions you'd want on an IK limb.

The best thing about this, is that it can be easily swapped out with the conventional IK-solvers on any old rig, as it appears as a drop-down in the IK handle node. Not only that, but the source code is available on github. Sweet.

Some of the in-built attributes are:

  • Soft Distance: Distance to translate the IK before the 'softness' kicks in.
  • Activate Stretch: Activates the stretch! (Makes things stretchy)
  • Mid Joint Slide: Slides the mid joint between the start and end joints.
  • Mid Joint Lock: Allows the user to translate all joints.

Read all about it, and download it here:

Thanks Tool Chefs!

Wednesday, 31 July 2019

Bifrost for Maya

Bifrost for Maya has finally arrived! Complete with an arsenal of nodes, Bifrost will allow you to create a visual programming (nodal-based) approach at building deformers, FX, rig functionality and much much more. Whilst this isn't a completely new methodology to the 3d scene - it is for Maya. It will certainly be interesting to see how it compares to the likes of Houdini.

Check out the announcement video here:

My gut says that whilst this will provide a powerful new approach for creating FX with Maya, it will not be enough to rival the brute force that Houdini allows the user with its point-based approach, but i'll reserve judgement until I give it a go.


  • Ready-to-Use Graphs—Artists can quickly create state-of-the-art effects that meet today’s quality demands.
  • One Graph—In a single visual programming graph, users can combine nodes ranging from math operations to simulations.
  • Realistic Previews—Artists can see exactly how effects will look after lighting and rendering right in the Arnold Viewport in Maya.
  • Detailed Smoke, Fire and Explosions—New physically-based solvers for aerodynamics and combustion make it easy to create natural-looking fire effects.
  • The Material Point Method—The new MPM solver helps artists tackle realistic granular, cloth and fiber simulations.
  • High-Performance Particle System—A new particle system crafted entirely using visual programming adds power and scalability to particle workflows in Maya.
  • Artistic Effects with Volumes—Bifrost comes loaded with nodes that help artists convert between meshes, points and volumes to create artistic effects. 
  • Flexible Instancing—High-performance, rendering-friendly instancing empowers users to create enormous complexity in their scenes.
  • Detailed Hair, Fur and Fuzz—Artists can now model things consisting of multiple fibers (or strands) procedurally.

 Any version 2018 onwards will be compatible with this new plugin.

Here are some tutorials to get you started:
Bifrost Basics: Part 1
Bifrost Basics: Part 2
Bifrost Basics: Part 3
Make Custom Peak/Push Deformer

All kinds of shennanigans!

Tuesday, 30 July 2019

Casadeur - Physics Based Animation Software

I have been following this swanky new piece of physics-based animation software over the past few months called 'Cadadeur'. Not sure if any of y'all have seen it yet, but it seems to have some really impressive looking tools within the software itself.

Check out this machine learning pose helper:

Or this auto-velocity/center of mass tool:


But how much is it?
Nothing! At least not at the moment, you can download beta test it here:

Monday, 24 June 2019

Better Boolean Topology in Maya!

Aah booleans.. if only they were actually useful and didn't create horrendous topology that you can't really work with. I mean, there's always zRemesh in Zbrush but.. that's a whole lotta exporting and importing and opening another software and yadda yadda yadda.

So in Maya 2019, Autodesk have implemented two brand new shiny MEL commands!

polyRemesh;  - Takes disgusting topology and converts it slightly less disgusting triangles!
polyRetopo; - Takes slightly less disgusting triangulated topology, and turns it into beautiful quads!

Only works in Maya 2019 onwards
Only works in Windows (needs confirmation)...  (sorry VFX industry)

For more info, take a look at this video:

Happy booleaning!

Monday, 20 May 2019

Maya's new combinationShape node

Check out this great post explaining how to use Maya's new combinationShape node. This node is useful for an array of things, including driving blendShape targets in a facial rig & creating a min/max function.

Tuesday, 19 March 2019

Love letter to Python Classes

So, after about 5 years into python I started to understand and use classes a lot at DNEG. There were a few things that I never understood about classes,and subsequentially went through the 9 stages of coding class-denial:
  • Shock: In what situation/context would I use them?!
  • Denial: Why not just have a lovely file full of lovely methods/functions instead? I don't need them!
  • Anger: Guh! Another class! Why do I need this complicated nonsense that I don't understand!
  • Bargaining: Maybe if I use enough well-written efficient methods, i'll never need classes!
  • Depression: Urgh.. guess i'll have to learn to use classes someday...
  • Testing: This didn't work.. this didn't work.. hmm intriguing..
  • Acceptance: Everything is an object. Everything is a class. They're beautiful.
 On-queue nerd out.

Yes, believe it or not, after years of trying to avoid them, I finally love classes.
The thing about a class is that I've never understood all of its true values that it brings to a piece of code.
The perspective it brings helps you to think about your code truly as an object.

The first thing people tell you with such confidence is that a class is an 'object', and in your head you're sitting there thinking "okaay..."

"Think of it like a T-rex" they say, "where it has variables like 'tail' and arm_length'."

Aaand you'll still be none-the-wiser, because whilst you now know that variables can belong to a 'class', you don't know how to apply this abstract word called 'class' to your code, how they help you or when/where/how to use them.

Someone else may mention "They help you to organise your code." Which - in parts - is very true, but it still does not help you to understand when to actually implement them in your code.

The thing about coding is that it needs to be clear to read and easy to understand. The vast majority of your code that you write will either be read by someone else, or future you who has completely forgotten what it was that you wrote. So, it needs to be: Clear, Fast & Easy to read.

If you have never used dictionaries - you should. I would highly recommend to learn them before learning classes, because they'll only take you 5 mins to learn and will help you understand classes quicker and easier.

In python, a dictionary's syntax is this:

my_dict = {key : value}

The key can be anything, from a string called 'pinapple', to the float 725.23
The value can be anything, from the integer 3 to the string 'delicious'.

my_dict = {"shangrila": 17}
Anything, really.

The important concept here though, is that one value is linked with another, 'soul-bonded' if you will.

cheese_shop = { "cheddar_in_stock": 7, "wenslydale_in_stock":3}
print cheese_shop["cheddar_in_stock"]
returns: 7

This is similar to using zip( ) with two lists, except that it's much nicer to read it by using a dictionary in lots of cases like this. Damn ain't that swell?

Now, wouldn't it be nice if we didn't have to write our variable:

with square brackets and quotation marks? I mean we are lazy after all and want to write less for more.. right?

Wouldn't it be nice if we could instead write:


"Aah, no brackets! No nasty quotation marks" I heard you cry! Yes, that's right ladies and gentlemen, a whole 4 characters of you typing less thanks to classes.

It's kind of like a dictionary, in that it links two variables together. But it's like a beautiful swiss-army knife dictionary, because instead of the 'variable' you want to refer to being a string in square-brackets:

it's actually a variable:


 A.) Isn't it waay nicer to read:
       cheese_shop.cheddar_in_stock    than    cheese_shop["cheddar_in_stock"]

Friday, 21 December 2018

Saving data to json with python

Wabaluba dub dub it's free-code Friday!
Sometimes you sit down on nice chill weekend and think to yourself, oh boy I want to store some data!

But in all seriousness, let's say you want to run something this evening and return to it tomorrow. Or perhaps you would like to retrieve data from a previous Maya session that crashed, or from a different Maya session entirely - You can save this data out to a separate file (essentially a big text file) called a Json.
Json's are nice to use because they're easy to read/edit and easy to implement into your code. Here's some example code of how to use them below!

import json

# Create some data
data = {1 : 'a', 2 : 'b', 3 : 'c'}

filePath = "C:/User/Documents/test_data.json"

# Write/Export from variable to text file

with open(filePath, 'w') as f:

  json.dump(data, f, indent=4)

# Read/Load from text file to variable

with open(filePath, 'r') as fp:

    data = json.load(fp)

# Read/Load from dictionary text file to ORDERED dictionary

with open(filePath, 'r') as fp:

    data = json.load(fp, object_pairs_hook=collections.OrderedDict)

Wednesday, 18 July 2018

Python dictionary examples

Over the course of my ramblings and 3d work I have collated a collection of example scripts that I refer back to every once in a while, perhaps when I forget how to use a particular piece of syntax or if it's something I use fairly irregularly.

Dictionaries are something that I use all-the-time. And if you're looking to get into python scripting then is definitely something you'll want to be using too.

Dictionaries are like a more-lovely list/array.
Here's what I have jotted down in my file:
# Create an empty dictionary, just like we would with a list.
vegetables = {}

# Append/Create our first entries; 'carrot' and 'tomato'. We assign a sub-dictionary to both of them as their values.
vegetables['carrot'] = {'colour' : 'orange','grown' :' underground'}
vegetables['tomato'] = {'colour' : 'red','grown' : 'vine'}

# An example of looping through each key and values using the in-built '.iteritems()' dictionary method:
for key,value in vegetables.iteritems():
    print key, value

# An example of running logic with a '.get()' method:
for key, value in vegetables.iteritems():
    if value.get("colour") == "orange":
        print "{} is an orange vegie".format(k.title())

# Make it ordered - (Explaination below)
import collections
vegetables = OrderedDict(sorted(vegetables.items()))

One thing about dictionaries, is that by default they store their information un-ordered. This means if we wanted to access the first element when we created the dictionary, it would not necessarily be the first element returned when we go to retrieve the first element later on. 

Think of the process like this:
creating a dictionary = drawing out a new deck of cards
immediately afterwards, python helpfully shuffles this deck of cards, keeping all the cards & data, but not the order. This is to help save memory when dealing with large amounts of data but.. this has caused me more than one headache when I assume that the dictionary would retain the order that it had when I first created it. BEWARE of this.

Happy.. dictionarying?

Tuesday, 17 July 2018

Intuitive Maths

Check out this b-e-a-utiful website dedicated to helping people understand common maths concepts intuitively.

From articles about the history of mathematical language, to the incredibly intuitive explanation of the Pythagoras theorem. This website details methods that have completely changed my perspective on the way I view some key mathematical concepts.

Tuesday, 29 May 2018

Incredible Photoshop plugin - Nezumi (lazy mouse)

Hot diggity dog this one is a game-changer.
Do you ever think to yourself one of these three things:

"Man, I wish I could have lazy mouse in Photoshop just like I do in Zbrush."
"If only Photoshop's brushes were just slightly.. smoother.. more voluptuous.."
"... just one more ctrl+z... need to redraw this line as its not quite perfect yet.."

Well fret no longer! Take a look at this fancy Photoshop plugin
It has a 15 day free-trial, and believe me at the end of your trial you'll be throwing your wallet at this goddamn beautiful plugin.

Nezumi essentially takes your line, and makes it lovely. Fortunately, they've included a load of fantastic gifs on their website which I will put right below here so I don't need to arduously type out the description of what this thing does:



And a beautiful array of settings you can choose from.

Not only that but as well as the smoothing function it has a load of awesome, easily editable rulers that you can use to help draw circles/ovals. Go grab this tool.

Friday, 25 May 2018

List of Insanely Useful Sine Graph Equations

Hooolla hola hola hola! This is insanely useful!

Do you want to animate something with code, but you don't want it to be your everyday dull sine?
Look no further, I have found an -incredible- image!


Look at all these glorious equations beautifully laid out before your eyes!

Now you can have a bouncy-ball (pointy) sine, which could be useful for procedurally animating waves,
A linear zig-zag sine, which could be useful for animating a robot or mechanics,
A slightly rounded sine, which could be useful for animating something gently hovering

and much much more!

The possibilities are limitless! Now GO! Go use these fantastic formulas and animate me all that is siney and wavey!

Wednesday, 31 May 2017

Be aware of your open windows!

Just a quick note, if things seem to be running un-naturally slow in Maya, just check what windows you have open.

Selecting LOADS of verticies? Don't have the component editor open whilst doing so.
Moving LOADS of keys? Don't have the graph editor, dope sheet and trax editor all open whilst doing so.
Creating LOADS of nodes? Don't have the node editor open.


Wednesday, 1 March 2017

Unity hates 0 scale

It's been a while, but that's because I've left games to do some VFX work at Double Negative in London!

However, back to Unity problems...

The Problem:
Animation/Geometry not appearing upon import .fbx in Unity. Specifically geometries that had been animated in their scale.

The Fix:
Do not animate to complete 0. Animate to 0.001.

Don't ask me why, Unity is a mysterious woman, yadda yadda yadda.

Friday, 28 October 2016

8 bit to 16 bit PSD glitch

Hey! Look at this!

I was texturing a character today, when I decided to switch from 8 bit to 16 bit in my PSD file, and I found this cool glitch! As cool as it is, I'm sure it's caused someone headache somewhere. Anyway, here's what the transition looks like:

8bit (original)

16bit conversion

Wednesday, 26 October 2016

maya.mel.eval() not working

The Problem:
I got these errors when trying to run my batch FBX exporting script today:

global name 'maya' is not defined
# Error: NameError: file <maya console> line 1: name 'maya' is not defined

How annoying. After rummaging through my script I came to the line which was causing me the error, which was the maya.mel.eval() script (whereby you can run MEL commands in python).

The Fix:
Turns out, Maya had turned off all of its plugins and that's what was causing the error. Not sure which one was the correct one to turn on, as I didn't have the time or patience to test it out, so I just turned them all back on under Windows>Preferences>Plug-in Manager and checked the box 'Loaded' under 'Apply to all'.

Thursday, 20 October 2016

Maya viewport running slow

"Hey Alex, my Maya viewport is running slow, especially when selecting nurbs curves whilst animating!"

Yeah? Well, maybe you should un-check this badboy. (Graph Editor > View > Show Results) Honestly, the amount of times I've thought, "Huh, weird this animation is running unusually slow", only to discover it's this silly little option box has been frustrating.

Wednesday, 12 October 2016

Unity breaking once again.


Triangulation, Deformation & Max influence issues - Maya to Unity

I'm working on a game trailer at the moment, and encountered a bug regarding deformation issues and things not appearing in Unity as they do in Maya. Thanks Unity.

The Problem:

A side by side comparison between Maya and Unity shows that in the middle of an animation being played, we are getting different deformations.
It may be hard to see because of the lighting, so I have drawn a blue outline of the jacket beside each image. As you can see, the image on the left (Maya) has a nice smooth deformation. The image on the right has a 'nice' lumpy deformation.
The reason this happens I believe, is due to the way Unity interprets the influences of joints, and also the triangulation on export/import.

The Fix:

1.) First, go into your quality settings in Unity (Edit>Project Settings>Quality) and try changing your blend weights. If it's on 2 bones, change it to 4, and vice versa. This should hopefully fix your problem.

2.) Still not fixed the issue? Have a look at your rig in Maya, what are your max influences on your mesh? Play around with these settings and try capping your max influences at 4 with the 'set max influences' option. You shouldn't be using any more than 4 for a game rig anyway (with the exception of cinematics/trailers etc.)

Happy riggydigdigging!

Saturday, 1 October 2016

Can't drag select multiple objects?

So, I had an annoying bug today.

The Problem:
Can't drag select multiple objects (meshes) in Maya.

The Fix:
Go to your device manager, select your GPU (graphics card, under the heading of 'display adapters'), right click is and select the 'driver' tab. If you can, roll back the driver, if not try updating. Hopefully this will sort out this problem for you, and other funky stuff eg: outliner icons being a weird size.

Can't drag select multiple objects?

So, I had an annoying bug today.

The Problem:
Can't drag select multiple objects (meshes).

The Fix:
Go to your device manager, select your GPU (graphics card, under the heading of 'display adapters'), right click is and select the 'driver' tab. If you can, roll back the driver, if not try updating. Hopefully this will sort out this problem for you, and other funky stuff eg: outliner icons being a weird size.

Thursday, 16 June 2016

Rigging a character for Unity

Okay, so this is more of a future reference to myself to come back and finish this post. However, the things I want to cover will be:

-Deciding whether you want to use mecanim before rigging.
-Handling squash and stretch within unity.
-Avoiding translation.
-Optimisation, combining your meshes.

Check back next month, this post will be updated when I get the time!

Tuesday, 24 May 2016

Importing reference crashes my scene!

Just a quick one, but I feel as though someone out there is probably going to have a similar problem.

Let's say you have 2 animated 'things' in a scene, for example: a sword and a character.
Let's also say both of these things are referenced.
Let's ALSO say that the sword has a constraint coming from the characters hand.
Let's finally say you want to import the reference at some point.

Nooooope. Crash crash crash crash crash crash.

I didn't know why I was getting this issue for a while, but it turns out that the thing that was causing it was the mixing of constraints between two referenced objects. Best to bake out the keys you need and delete the constraint before importing!

Thursday, 19 May 2016

Animation amplify/mute

I made another thingy!

So, you have an animation and you're reasonably happy with it but you wish one section was slightly more exaggerated, or maybe less so. You could go in and tweak every individual curve ooor...

...You could use my script! Download it here: AT_anim_amplifyMute

What the script does, is scales every selected curve up/down by a specified amount, using the mid-point (between the max min values of the selected curve range) as the pivot.

Here it is in action:



Tuesday, 17 May 2016

More Unity Animation Mismatches

Yet again, another mysterious animation mismatch.
You have your animation in Maya, it's all set up how you want it, you export it, open it up in Unity and boom - something's out of line, mis-placed or rotated in the wrong way.

The problem that caused the issue for me this time round, were rotational values dipping from negative to positive. In the gif below, you can see the mismatch:

As you can see, the hand is rotated as intended in Maya, and yet when exported and brought into Unity, something is happening along the way.

The fix was to go into the graph editor and edit the rotate X value, so that it no longer crept up into the positive values. Interestingly, using the Curves>Euler fix button actually caused the issue for me this time round. Here, you can see the graph editor before and after:

Still not entirely sure what causes this, but it looks as though Mecanim has something to do with it, as when set to 'generic' mode, the issue no longer persists within Unity.

 Unity is a mysterious woman.

Tuesday, 12 April 2016

Unity GUI errors

Recently i've been getting a lot of GUI errors. This is one of the errors that flags up in my console:

Reported delta does not match with progression of time. Check that the OnInteractivePreviewGUI function only updates the Animator on Repaint events.

If you're unsure why you're getting an error (not specifically this one) try resetting your layout. As mad as this sounds, it's fixed a multitude of errors for me now.. buggy old Unity.

Mecanim update bone bug!


If you want to go back and edit your rig after you have already exported it into Unity, and created an avatar - you're going to have a fun time.

Unity doesn't seem to take to updating files very well - especially avatar files. This is the problem I faced and how I fixed it:

1.) Export Rig into Unity - everything hunky dory, avatar bones configured. Great.
2.) Export animations - link to avatar. Everything working okay.
3.) Update rig in Maya (in my case, the positioning of the bones were changed)
4.) Re-export to Unity, overwriting the old avatar file.
5.) Look at animations, things are looking wroooong. Intersection issues everywhere. WHAT IS GOING ON.

And the solution:
6.) Make an entirely new avatar file, re-link animations to new avatar file. Eureka! Things work.

I can only assume that when you create and configure a new avatar, Unity will set this in stone, even if the file is overwritten. Creating an entirely new avatar forces Unity to re-do this configuration process, thus updating any bone/rig changes.

Tuesday, 5 April 2016

Delete half frames

I came across something really annoying the other day whilst I was re-timing my animation.
I select all my character's controls, and scaled the keys down - as I wanted a certain part of the animation to be faster.

I then right clicked and attempted to 'snap' the newly scaled keys, only to find that because some keys were next to one another to begin with, they couldn't snap to the same frame - bummer!

This leaves you with a whole bunch of keyframes that are now on a time value of eg: 1.5, 2.034, 10.56767 etc. Not cool! You will never see these keys, as you will only ever be able to view one frame at a time - thus rendering them useless!

So, grab my script here:

Then, select all curves you want to clean (delete any half frames) and run it! Begone fowl subframes!

Hope this helps someone. :)

Wednesday, 16 March 2016

Flight cycles

Could well be useful!

bindPose error

Error: file: C:/Program Files/Autodesk/Maya2016/scripts/others/newSkinCluster.mel line 73: Skin on exampleName_joint was bound at a different pose. Go to the bindPose to attach new skins. //

So this can happen when trying to bind a new mesh to your current joints. God bloody damn it.

To fix this error, simply type into the 'select by name' option box in maya: *bindPose* 
Now press your delete key.

You are now free to bind away! This has fixed all my bindPose error problems, and to date hasn't broken any of my rigs yet. (I have been using this fix for over a year now.) 

Wednesday, 9 March 2016

Keyframe Offset Script

I was playing around with scripting today and made a new tool which you may find handy!
It takes a bunch of objects with keyframes that you have selected, and offsets each of those keyframes by a specified number.

Here's some things I made while playing around with it:

You can download it here. It doesn't have a GUI for now, but I will be making one soon!

Thursday, 3 March 2016

The mysterious 'update' button.

After coming across numerous problems with Mecanim and setting up avatars, I came across an unusual 'fix'. Whilst this seemed to fix things from the onset, it caused major problems further down the pipeline and is something you should avoid.

Here, you can see the default settings of a .fbx animation file upon first loading it into Unity. Excellent, now we want to change the Animation type to 'humanoid' and avatar definition to 'copy from another model' (something which has already been set up previously).

Now, for whatever reason the order in which you click these buttons seemingly yields a different result. You'll notice that if you change the animation type to humanoid then click apply, then change the avatar definition, and then click apply once more, a little button labelled 'update' will appear.

How interesting, I wonder what happens if we change all the settings in one go without going through this two stage process of clicking 'apply' twice.

No update button... What!? Whether this is a bug or a feature, I have no idea. However, from an initial glance, it seemed as though leaving this button un-clicked fixed a lot of problems (intersecting parts of the rig with the mesh, additional bones/joints affecting the avatar etc).


In the long run, it seems to leave the avatar in a weird limbo between 'generic' and 'humanoid' setups. For one, no root motion will be generated when this update button is still visible, your looping indicators will not change depending on the frame range, amongst many other problems.

For anyone with any further knowledge, please let me know what this feature is for. For anyone else, to save yourself from future pain, just click the button.

Wednesday, 2 March 2016

Creating python GUIs

Check out this link, super handy.

Recording Mouse Movements - Animation in Maya

If you're familiar with Adobe After Effects, you may also be familiar with something called 'Motion Sketch'. It's a pretty awesome function that lets you animate certain objects in real time just by using your mouse... kind of like puppetry.

Well guess what! I was looking for a feature like this the other day because I was working on a project where we were animating puppets in 3D! (you can view the finished product here:

Turns out, it's another secret bloody function in Maya! Good job Autodesk, keep us guessing.
Anyway, select an object to record and run this MEL script:

recordAttr -at "translate";
play - rec;

For rotations, unfortunately it's not as simple as changing the word 'translate' to rotate. You have to convert the data from degrees, to radians and then back to degrees again. Bit of a faff, but here's the necessary code:

string $curAngleUnits = `currentUnit -q -a`;
currentUnit -a rad; // Temporary set to radians 
recordAttr -at "rotateX" -at "rotateY" -at "rotateZ";
play -record; 
currentUnit -a ($curAngleUnits);

Hey presto, real-time, on-screen recording.

Saturday, 13 February 2016

Spring IK

Spring IK
There's a cool and somewhat secret function in Maya for whatever reason, called the "IK Spring Solver".
It's great for creating quadraped legs, amongst other mechanics in rigs. In order to 'unlock' this secret attribute when creating your IK node, type in the MEL command line: ikSpringSolver;

In my opinion, this should be something that should load automatically with Maya by default. But then that's just a rigger's way of thinking, right?

Problem when moving the Global Control
Depending on your creature/character rig setup, when moving the global control you may find that the IK spring solver does not follow the way it should. In my case, I had a broken hierarchy, linked together with parent constraints. The way this issue was fixed was to delete the constraints and just use good ol' fashioned parenting. 

Have a mess around with it, and if you have any problems leave a comment here.

Wednesday, 10 February 2016

Euler Rotation Problems

Recently I've been having an issue when animating that a control will flip 180° or 360°. This usually occurs for me when I am matching FK/IK manually or animating a character turning around.

You can see the issue occuring here:

Very annoying - especially if to fix it you go in frame-by-frame. Fear not, there is an extremely handy and seemingly magical button in the graph editor called 'Euler filter'. It is located under Curves>Euler filter. Select the problem keyframes, hit this button and voila! Like magic, Maya interprets the information, and prevents any curves from exceeding 360°. Perfect.

Why this isn't a MASSIVE button outlined in red I don't know...

Monday, 11 January 2016

Importing rigs from Maya to Unity

I have been working at the games studio: Mojo Bones for a little over 2 months now. This is my first job in games and I have had to overcome a range of problems when importing rigs from Maya into Unity.

Here are some of the key problems I faced and resolved which I shall discuss in this post:
  • Hierarchy - Why Unity hates broken hierarchy and how to deal with it.
  • Scaling - stretchy squashy joints. Why this won't work out of the box and how to overcome it.
  • Naming conventions (naming clashes can cause problems whatever program you are in!)
  • Avatars - what they are, and how to set them up.
  • Exporting to an FBX - what to include, and what settings to set.
  • Humanoid setup with Mecanim.
  • Extra/Additional bones when using Mecanim (like wings, clothes, or in my case a backpack.)
  • Jittery Animation? Probably keyframe compression.

The Fix:
If you are using a broken-hierarchy rig, follow these steps:
  1. Select all joints you want to be bound (or are already bound) to the skin in the initial broken hierarchy rig. 
  2. Duplicate them.
  3. Remove any constraints and connections. 
  4. Parent any broken sections ( eg: ribbon joints ) 
  5. Parent constraint each of the newly duplicated joints to their respective broken hierarchy rig counterparts. 
  6. Give them a suffix. ( eg: 'game_' )

The Explanation:
Mecanim hates broken hierarchy. That is the nub of it. If any part of your rig uses broken hierarchy (such as ribbons) Unity will spit it right back out.

You can follow the fix above and do this manually each time for every character OR you could save yourself potential hours and script it... OR you could save yourself even more time and use my script,
which you can download for free below.

Extract the download into your Maya scripts directory, and then run these three lines of code:

import gameRigJnts
from gameRigJnts import *


Scaling joints - squash and stretch 
The Fix:
You will need 2 rigs for this to work as mentioned in the hierarchy section of this post. When all game rig joints have been constrained to the broken hierarchy rig, you can now see that the scaling in the axis that points down the joints (in most cases the 'x' axis) works. Whilst this now squashes and stretches it does not retain mass.

Unfortunately you will need to effectively 'scrap' the conventional 'y' and 'z' stretch nodes/expressions and fake it with blendshapes instead. Blendshapes are fairly heavy on game engines, some do not support their use and you will never get an exact mathematical squash and stretch - but it will do the job.

The Explanation:
Turns out Unity hates scaling joints too. After scripting my own stretchy/squashy spine in Python and implementing it into a rig for Unity, I soon discovered that the deformations were not transferring over as they looked in the viewport for Maya as they did in Unity's animation inspector (viewport).

Annoyingly, I couldn't seem to find the issue immediately, as nothing seemed to be out of the ordinary and no warnings were flashing up upon import. However... after doing a bit of searching around on the internet, I discovered that Unity does not evalate scaling in the same way that Maya does. Infact, Maya seems to have it's own scaling algorithm built into it when it comes to scaling joints.

Naming Conventions
The Fix:
Make sure no two items are named the same when importing to Unity. Batch add prefixes if necessary with the 'prefix' tool in Maya.

The Explanation:
Naming conventions are something which cause problems all the time all over the place. Not only do naming conventions help keep everything tidy, organised and legible for when you or somebody else opens your scene up in 18 months time, it also prevents further problems down the line.

Naming conventions are ESPECIALLY important in rigging (although I'm sure every department would say that about their own part of the pipeline).
When you have 200+ joints in your rig, you need to be able to find something fast and efficiently. Naming may also help with specific scripts that you'll want to run in the future.

In this particular case, when I imported my first ever rig into Unity, I came across a problem with my naming conventions; name clashes.

The reason that I had a name clash was because I have 2 separate skeletons, one serving as a normal, broken hierarchy rig that I would usually use for vfx or cg film and the other - since Unity hates broken hierarchy - is a non-broken hierarchy rig. This serves as a 'dummy' or 'slave' rig that just follows the initial rig through parent constraints.

These two separate hierarchies (effectively duplicates of one another) each had the same names for the same bones - a bad practice whatever program you're in, but for Unity it was particularly bad for dealing with the Mecanim system and may have caused other errors down the line. Best just to avoid it at the outset.

Fortunately, this is a very quick and simple fix - just add a prefix to one of the skeletons, (eg: game_head_jnt, game_pelvis_jnt, etc.) Once this is done you are good to import to Unity.