• No results found

Utility Nodes and Custom Attributes

Chapter Example Files:

chpt4_BoyWithHat.ma; chpt4_BoyWithHat.mb;

chpt4_Boy_Polysmooth_start.mb; chpt4_Boy_Polysmooth_v2.mb

Rules Covered

Rule #4: Keep geometry (GEO), controls (CNTRL), and skeletons (SKEL) in separate groups in the outliner

Rule #5: Make controls that make sense to the animator

Let’s recap the rules that we have covered so far: #1. Edgeloops—a good or bad rig starts with the loops. #2. Never keyframe on the geometry. (Animate for change.) #3. Lock what isn’t going to be animated.

#4. Keep geometry (GEO), controls (CNTRL), and skeletons (SKEL) in separate groups in the outliner.

#5. Make controls that make sense to the animator.

#6. Happy math—controls and joints should be zeroed out.

#7. Happy history—always delete unneeded history to keep a rig fast.

In this chapter we will talk more about Rule #5: Make controllers that make sense to the

animator. To accomplish Rule #5 we will learn about utility nodes; my favorite!

In the last chapter we put controllers on a toothbrush. In that rig, what might not make sense to the animator? If you aren’t sure, do a test animation with the character. What frustrated you the most? If it frustrated you (and you know the rig), it will really frustrate someone who doesn’t know the rig as well as you.

On our toothbrush rig in Chapter 3, the twist controller turned one way but the toothbrush twisted the other way. That and many other simple user interface issues can get in the way of animating. It takes a little bit of extra care to fix issues like that. That extra care can streamline the animator’s workflow and help production.

I don’t know about you—but I’m a little tired of the toothbrush. If you don’t mind we’ll use a different looking rig with the same type of attributes. In Figure 4.1 we have a fish that has a similar twist issue to the toothbrush. The fish model has a twist deformer for the whole body and a bend deformer for just the whiskers.

Figure 4.1 Rotating the Twist_CNTRL to the right causes the fish to twist to the left. The twist end angle needs a positive number. Model by Stefan Lepera for SCAD 2010 group project “Drag N’ Fly.”

We have a one-to-one connection from the controller to the twist’s end angle attribute. The issue is that the number required is the opposite of what we are getting from the twist controller. The controller is giving a negative number when we twist to the right, but the twist end angle needs a positive number to be twisted to the right.

The type of connection that we need is not a one-to-one connection or a constraint connection. We need to have a modified connection. In other words, the number we need in the twist attribute is not the same as what is coming from the controller. How do we adjust that number? There are those that will jump straight to expressions. Not us. We’ll save expressions for when we can do it no other way. Expressions are a mathematical formula that you can enter into the channel box that will do the math for you and adjust the number. They are neat and those that love them love to use them. However, I do not and will not show you expressions until we have exhausted every other way to do the same thing. Here’s the reason—expressions are not very fast. They calculate every frame, every time you do anything, because they don’t know any better. We are going to learn how to use nodes. Why? We use nodes because nodes do calculate very fast. Use nodes first, expressions last.

Do you want something else to talk to Thurston at that cocktail party about? Hope this is at another black tie affair. You really get around in the social scene, don’t you? When an attribute is marked as having been changed and Maya needs to think about it, it is considered “dirty.” When it is marked as not having changed and therefore can be skipped during an updating of time (when you scrub the time line) then it is considered “clean.” Nodes know when they are dirty or clean. This is how Maya manages what it should update when you scrub through the timeline. It doesn’t think and update everything, only the things that are marked “dirty.” Expressions are always dirty and can never ever be clean. It is how they are designed. So, they calculate every frame. Too many expressions and your rig starts to become very, very slow. (Dirty expressions; take that Thurston! He really is a good friend and admires all of these tidbits you tell him. He can’t get enough.)

1. Select the Twist_CNTRL and open the Hypergraph: Connections window.

There is a line connecting the output of the Twist_CNTRL going into the twist1 node. We want to place something between those two nodes to adjust that number. For example in Figure 4.2 the Twist_CNTRL is at 38 and we want the twist1 end angle to be at a -38. Do you remember junior high math? Maybe it was grade school, I don’t remember. What do we need to do to make a 38 turn into - 38? Multiply it by -1. We want to hijack the number that is going between the controller and the twist and do some funky magic with it and multiply it by -1. We will add in a node to do this. To do this we are going to use a part of Maya that wasn’t really designed to do rigging. It was designed to do color. We will use a render node. Render nodes are great; they weren’t designed for this, but we use them anyway. At the end of the day, colors are just numbers, so the render nodes will work fine for us.

Figure 4.2 Attaching a multiply/divide node between the Twist_CNTRL and the twist1 nodes.

2. Right mouse click in the Hypergraph: Connections window and select Rendering>Create Render Node. This opens a window. You are probably used to looking at material nodes in

here.

3. Select the Utilities section found at the left of the window. This will show you all sorts of nodes

that were created to help you change your material network.

Inside of Maya you can basically do compositing type of effects with your textures. It’s pretty neat if you haven’t gotten into it. However, we’re going to use these for rigging and make them do our bidding. (Insert evil laugh.)

4. Click on Multiply Divide.

When you click on this be careful. The new multiply/divide node shows up in your Hypergraph: Connections window. If you had moved nodes around in the hypergraph window when you add in the multiply/ divide node it rearranges the window on you. Don’t freak out. Just move the view around until you locate the multiply/divide node. It is usually in the upper right-hand corner. If you were to refresh the hypergraph window the multiply/divide node would go away (out of view) because it is not hooked up to anything. You can get it back. We’ll see how in a little bit. But for now, you didn’t freak out—it is still there. We can connect it.

If you select this new multiply/divide node and look in the attribute editor you can see that it has an input one and an input two and a pull down for you to choose multiply, divide, or power. You probably learned power in a math class that I never took. We won’t use it in this class. The node is setup for three numbers. They are not labeled. You can assume they stand for either RGB or XYZ. You can use any of them. We’re going to use just the first column and ignore the rest. The first input is going to be the number from the controller and the second input will be what we want to multiply it by.

5. In input 2 X type -1.

6. Change the operation to Multiply (if it wasn’t already there).

We need to get the rotate z number from our twist control and pipe it into the input one. This is where you might want to use the connection editor or you can use the hypergraph window. I like the hyper-graph window, even though it will have some refresh issues here.

7. Right mouse click on the Twist_CNTRL and select rotate> rotate Z.

8. Right mouse click on the multiplyDivide1 node and select input1> input1X.

Don’t freak out. You don’t see the line connecting the two in the hypergraph window—not at first. If you select the multiply/divide node and look in the channel box, the input1 attribute is yellow. You know the connection is there. The Hypergraph: Connections window did not update and draw the

line. If you are getting nervous, select the Twist_CNTRL and refresh the Hypergraph: Connections window. ( Warning: If you select the MultipyDivide1 node instead of the Twist_ CNTRL and then refresh, the twist1 node will not stay in the window for the next steps.)

Ooops: Did you lose your multiply node in the Hypergraph: Connections window? It still exists. If

that happens you can get it back again:

a. Open the hypershade window by going to Windows>Rendering Editor>Hypershade. b. In that window, locate the utilities tab.

c. Select the multiply/divide node there and then shift select Twist_CNTRL in the outliner,

hypergraph, or perspective widow.

d. Refresh the hypergraph connections window and you see that you have that wayward

multiply/divide node back.

Gotcha: That connection between the two nodes shows up as a grey arrow. That is a unit

conversion arrow, which is why the hyper-graph doesn’t refresh and show it when you first hook the nodes up. Unit conversion gives it fits. You also cannot delete that connection. It is doing math behind the scenes and you can’t delete it. If you ever need to get rid of the connection, you’ll have to break connection in the channel box. Do you remember how to do that? Right mouse click on the attribute and select Break Connection.

Figure 4.3 Completing the connection from the multiplyDivide1 node to the Twist1’s endAngle. Now to finish the connection:

9. Right mouse click on the multiply/divide node and select output>output X. 10. Right mouse click on the twist1 and select endAngle.

To keep you on your toes, the hypergraph window still does not refresh. Select the Twist_CNTRL node and refresh to make sure your connections are looking correct.

Now your twist controller should work correctly and the twist control and the twist of the fish should all go in the same direction. This is such a nice thing that the animator appreciates. For example, in bipeds, to be able to rotate both arms down at the same time is a nice thing and saves time. However, depending on the arm setup you use it is not an automatic thing. Usually the arm controls, when selected and rotate together make the arms go in an opposite direction: one up, one down. It can take a utility node to give that functionality to the animator. (Go try it on any Tom, Dick, or Harry rig you can download out there. Most of them don’t have that feature, do they? That’s what I thought.)

It takes a little bit of clicking and faith in the hypergraph to get the multiply/divide node to work. Once you get it though, utility nodes are excellent tools for you to have. There are many ways to use them. Maya 2013 added a new window called the node editor. Check the companion data to see a

video of how to use it for this process.