Single Shading Switch Utility Node

In this video I show you a couple of nifty things you can do with the Single Shading Switch utility node within Maya.

Here is the source code that I use in the video:

First Example

// switchNodeName.input[element #].inSingle

setAttr "singleShadingSwitch1.input[0].inSingle" 0.5;

 

Sphere Example

for ($i = 0; $i < 16; $i++)
    setAttr ("singleShadingSwitch1" + ".input[" + $i + "].inSingle") (rand(0, 1));

 

Glow Intensity Example

for ($i = 0; $i < 17; $i++)
    setAttr ("singleShadingSwitch1" + ".input[" + $i + "].inSingle") (($i + 1) / 17.0);

 

MEL Tip 005: Toggle Booleans

In this video I explain what a boolean data type is and how to easily toggle them on or off.

A boolean is a data type that represents two different states. Those states could be true/false, on/off, yes/no, or one/zero.

In MEL we don’t have an actual data type called boolean, but instead we use the integer data type to represent them.

int $boolean = true;

$boolean = (!$boolean);
print $boolean;
// 0 will now print since the number zero represents false

In the above code we have an integer named $boolean and we’re assigning it to be true. The words true and false are keywords in MEL and they’re the equivalent to one and zero, so the following all mean the same thing:

int $boolean = true;    is the same as   int $boolean = 1;

int $boolean = false;    is the same as   int $boolean = 0;

Once line 3 is executed the $boolean variable will now equal false.

When you read line 3 you can think of the exclamation point as representing the word not. On line 1 we assign the $boolean variable to equal true, so when you read line 3 you can say $boolean is equal to not true, which in turn makes it false, because if something is not true then it must be false.

If the $boolean variable were false and we execute line 3 then the $boolean variable will equal true because if it’s not false then it must be true.

int $boolean = false;

$boolean = (!$boolean);
print $boolean;
// 1 will now print since the number one represents true

 

Here are a couple of practical examples using this technique. In this first example is a script that will toggle the Isolate Select on or off.

string $panel = `getPanel -withFocus`;

int $isolateState = `isolateSelect -q -state $panel`;

enableIsolateSelect $panel (!$isolateState);

 

And this example shows how you can use the technique to toggle the -lock flag on each of the attributes in the Channel Box:

string $objects[] = `ls -sl`;

for ($object in $objects)
{
    string $keyableAttrs[] = `listAttr -keyable $object`;
    
    for ($keyableAttr in $keyableAttrs)
    {
        string $objectAttr = ($object + "." + $keyableAttr);
        
        int $lock = `getAttr -lock $objectAttr`;
        setAttr -lock (!$lock) $objectAttr;
    }
}

Toggling boolean data types is a technique you can basically use in any of the programming languages you may learn in the future, so it’s a useful thing to know!

Key Takeaways

1. Using an exclamation point in front of a boolean variable will toggle it to the opposite state.

2. getPanel -withFocus will tell you which panel currently has focus.

3. Using enableIsolateSelect $panel $isolateState will allow you to turn on/off Isolate Select.

4. listAttr -keyable $object will return a list of all the keyable attributes within the Channel Box.

MEL Tip 004: Select Attributes in Graph Editor

In this MEL Tip I’ll be showing you how to create a script that will take the selected attributes in the Graph Editor and select those same attributes for every object you have selected.

Here is the script:

string $objects[] = `ls -sl`;

string $attrs[] = `selectionConnection -q -object graphEditor1FromOutliner`;

for ($attr in $attrs)
{
    string $buffer[];
    tokenize $attr "." $buffer;
    string $attribute = $buffer[1];

    for ($object in $objects)
    {
        if (`attributeExists $attribute $object`)
           selectionConnection -e -select ($object + "." + $attribute) graphEditor1FromOutliner;
    }
}

Key Takeaways

1. graphEditor1FromOutliner is the name Maya gives the outliner panel within the Graph Editor.

2. Use selectionConnection -q -object graphEditor1FromOutliner to query the selected attributes in the Graph Editor.

3. Use the tokenize command to separate a string based on the split character you give it.

4. The attributeExists command will check if an attribute exists on the the given node.

5. Using the command selectionConnection -e -select “objectName.AttributeName” graphEditor1FromOutliner will allow you to tell Maya what attribute you want to select inside the Graph Editor’s outliner.

Free Autodesk MasterClasses

Came across a whole bunch of free MasterClasses on Autodesk’s web site.

They have videos for all their different products featuring a wide range of different topics like 3D math, rigging, animation, texturing, plug-in development, and using Qt.

Great stuff!

HandBrake Video Converter

handbrake logo HandBrake Video Converter

I needed to convert an 8.5 gigabyte .AVI file into a .MP4 file with a more manageable file size without too much of a loss of quality. After trying many different kinds of video conversion software I came across one that was not only the best one I found, but also free, multi-platform, and open source.

It’s called HandBrake and you can download it here.

It quickly converted an 8.5 gigabyte .AVI file to a 207 megabyte .MP4 file with a negligible loss of quality. I tried Xilisoft Video Converter, QuickTime, and After Effects to create a decent looking .MP4 file and they didn’t come close to the quality and ease of use I got with HandBrake.

Rigging Demo Reel 2014

Woohoo! Just finished my rigging demo reel featuring some of the work I’ve done in the mobile games industry. You can click here to watch it on Vimeo.


downloadDemoReel Rigging Demo Reel 2014

 

The Last of Us Keynote

Creative director Neil Druckmann gives a keynote speech about the story development for The Last of Us.

He talks about the different iterations of the story, why they failed, and
what they did to make them better. He also goes over how female characters are sexualized in entertainment and how they wanted to create a game that avoided the typical stereotypes you find in games.

Personally I’m sick of the same story of a guy rescuing a female wearing an outfit showing her cleavage. I hope more games do what games like The Last of Us and Beyond: Two Souls have done and create strong female characters.

Here are the links to the speech:

Part 1: A Cop, A Mute Girl, and Mankind
Part 2: Developing a Story
Part 3: A Feminist Ending

Autodesk Python Videos

Came across the Autodesk Scripting and SDK Learning Channel on YouTube today.

They have a bunch of useful tutorial videos about Python scripting. Here are the links:

Introduction to Python Scripting in Maya
Introduction to Maya Python Plug-ins
Introduction to the Python FBX SDK
Introduction to Python in MotionBuilder

How To Make Birds Fly Good

Read this article: How to make birds fly good by Brendan Body.

It’s hands down the best resource about bird flight I’ve seen. Great info for animators and riggers with plenty of example pictures and videos.

MotionBuilder 2012: Mirror Animation

In this tutorial I’m going to show you how to mirror animation using MotionBuilder 2012.

First, select the take you want to mirror, then create a new take and click Yes when the message box pops up that says, “Copy the data from the current take to the new take.”

step01 create new take 300x183 MotionBuilder 2012: Mirror Animation
Double click the character node in the Navigator and under the Character Settings tab check Mirror Animation and change CharacterSolverSelector to MB Character Solver.

step02 mirrorAnim and solver 300x138 MotionBuilder 2012: Mirror Animation
Now Bake(plot) To Skeleton then Bake(plot) To Rig.
(If you use Plot All (All Properties) under Key Controls instead of Bake(plot) To Skeleton then make sure the character’s Control Rig is unchecked.)

step03 plot to skeleton and rig 300x182 MotionBuilder 2012: Mirror Animation
After doing the above steps my character rotates in the Y axis by 180. If something like that happens to you then do the following to turn him/her/it back around:

Select the Reference control, delete its key frames, uncheck Mirror Animation, and set its rotateY to 180. (If you need the key frames on the Reference control then you’ll need to rotate the Y axis by 180 on the key frames instead.)

step04 rotate character 300x182 MotionBuilder 2012: Mirror Animation

At this point you could leave the Reference control with a value of 180 for its rotateY, but if you want to zero out its rotations then Bake(plot) To Skeleton and set its rotate X, Y, and Z back to zero. Then do Bake(plot) To Rig one more time and you’ll have a character with mirrored animation and the Reference control will have zeroed out rotations.

 

So those are the manual steps if you want to mirror an animation, but I created a script that will automatically do all those steps for you. You can download it here: