So far we have covered one-to-one connections, constraints and modified connections with utility nodes. All of these connections have been to existing attributes. What if you want to create a controller that has other types of attributes on it? Custom attributes? You’ve come to the right place. Let’s learn how. Continuing with our red helmet boy; you can open the file
chpt4_Boy_Polysmooth_v2.mb to see the rig so far. 1. Select the Head_CNTRL.
2. In the channel box select Edit>Add Attribute (in older versions of Maya this is in a different
place. I don’t have an older version anymore. It would be under Attribute>Add Attribute, I believe.)
Figure 4.8 Creating a custom attribute on the Head_CNTRL.
Common beginner mistake: Make sure you have the controller selected and not the geometry.
The Add Attribute window opens up. We can create our own attributes and hook them up to anything.’
3. Label this “ LowHigh.”
4. Make Attributes: Keyable is turned on.
5. Under data type, choose integer. That means there are no decimal points. 6. Minimum = 0.
7. Maximum = 4. (We’ll go a little higher than needed.) 8. Default = 0.
9. Click OK.
Now a LowHigh attribute shows up in the channel box. You can change the numbers, but nothing happens yet. We haven’t hooked it up to anything.
We need a one-to-one connection from this custom attribute to the divisions attribute. Hook it up to the divisions attribute any method you want to. For example:
1. Select the Head_CNTRL and the geometry.
2. Open the Hypergraph: Connections window. Remember you can hit the hot key f to frame
nodes visible.
3. Right mouse click on the right side of the Head_CNTRL. 4. Select the LowHigh attribute.
5. Right mouse click on polysmoothface1 node. 6. Select Divisions.
Test: Select the Move_CNTRL and adjust the LowHigh attribute to make sure it drives the
divisions. You should see the geometry change resolution as you change the LowHigh attribute.
What could Go Wrong?
You could connect it backwards, in which case the LowHigh attribute would turn yellow instead of the divisions attribute. You could have put the custom attribute on the geometry instead of on the controller. Not a good thing since we don’t want the animator to touch the geometry; that is why we create controllers.
Figure 4.9 LowHigh attribute hooked up to the divisions attribute.
ENUM
Are you curious about those other data types in the create attribute window? If you answered yes, I hope you realize that you are definitely showing strong rigger symptoms. I was very curious when I first was learning. Let’s start again and try a different data type, something other than an integer.
Re-open chpt4_Boy_Polysmooth_start.mb. Let’s suppose that the animator doesn’t like scrolling back and forth with a virtual slider (like me) and would rather have an on-screen controller for animateable attributes and a toggle for things like this LowHigh attribute.
1. Select the Head_CNTRL.
2. In the channel box select Edit>Add Attribute. 3. Name: Low_High.
4. DataType: Enum.
Enum means enumerator. At the bottom of the window we can create words that are assigned a numeric value. (Enumerators in other scripting languages let you assign a name instead of a numeric value; tell Th urston.) By default, Maya has the words green and blue created for you. Usually you don’t want to keep those words.
5. Click on the word green and change it to Low. 6. Click on the word blue and change it to Medium.
How do you add a third name?
ten minutes the first time I saw this window. I kept looking for a plus button.)
8. Click on OK.
Figure 4.10 Creating an enumerator attribute to drive the divisions attribute.
These names are given an automatic number based on their position. The first word is given a 0. The second word is given a 1, etc. It is a numbered list that starts at 0, just like an array (if you know what those are). For example: low = 0, mid = 1, high = 2, crazy = 3.
In the attribute editor you will see a pull down menu as your LowHigh attribute. Hook it up as we did before:
1. Locate the controller and the polysmooth nodes. 2. Open the Hypergraph: Connections window.
3. Connect the Low_High attribute to the divisions attribute as we’ve seen how to do
previously. (You aren’t skipping around are you?)
Test. Change the values of the LowHigh attribute to make sure that the geometry indeed changes
resolution.
Note: To delete an attribute, select the attribute in the channel box, then select Edit>delete Attribute.
One Odd thing to Note about the Polysmooth Node
You may have noticed that the eyes do not move with the head when you move poor Robby around. There is a reason for that. They could be a simple child of the geometry. If they had been children, however, when you select mesh>Smooth it will only apply itself to the last object in the hierarchy. That would have been an eyeball, and we would have clicked polysmooth over and over again and thought it wasn’t working. Polysmooth will apply itself only to the lowest item in the hierarchy. What? That’s a good gotcha. You’ll have to perform the polysmooth operation on each object before you make any hierarchies with your objects.
Polysmooth can be used as a modeling tool. If you have divisions set at 2 then delete history, the resolution of that object will stay high. Not really what you want for this class, it will make your rig slow. It is just something to watch out for. To finish up the rig you can make the eyeballs a child of the geometry, if that was bothering you.