Hostingheaderbarlogoj
Join InMotion Hosting for $3.49/mo & get a year on Tuts+ FREE (worth $180). Start today.
Advertisement

Quick Tip: Creating Compound Curve Icons in Maya

by

In this quicktip tutorial, we'll walk through one way to create complex NURBS-based icons in Maya. Useful control icons can make or break a good rig, and are essential when creating in-interface GUIs. Putting together simple, one-piece shapes are easy, but making compound icons can be much more difficult. One method for combining multiple curves is to parent them under a single transform node. We'll first do this by hand, and then look at an easy MEL script that automates the process.

Step 1

Create a handful of Nurbs curves. For this example, I've used the Create > Text option box command, changed the text to Cgtuts+ and then selected the Curves type. With that done, hit Create to create this collection of Nurbs shapes:


Step 2

If you look in the Outliner (Window > Outliner), these curves are grouped by letters (in groups with the prefix "Char_"), and under a single "Text_" node, but each individual letter is selectable and moveable. When we hand over our final rig, we want the entire word to be the only thing that is selectable.


Step 3

To achieve this, we first start by selecting and un-parenting all the curves. The MEL code to do this is as follows:

parent -w;

So marquee select around all of your text elements, enter the above command into the command line at the bottom of your interface window, and hit Enter on your keyboard.


Step 4

With all of the curves still selected, freeze their transformations (Modify > Freeze Transformations).


Step 5

Next, open up the Hypergraph hierarchy.


Step 6

By default, only top-level transform nodes are visible in the hypergraph. To show the shape nodes, go to Options > Display > Shape nodes.


Step 7

First select all of the shape nodes for every curve except curve1. In this case I'll have 7 shape nodes selected. Now hold down Shift and select the first curve's transform node, in this case the curve1 node, to add it to your selection. It's very important to select the transform node last. Your hypergraph should now look like this:


Step 8

The following MEL command parents the first selected items (in our case the shape nodes), under the last selected item (the transform node). So type the following code into your command line and hit Enter to parent the shapes under the transform node:

parent -r -s;

Step 9

Now you can click on any of the letters and Maya will automatically select the entire word. Your control-icon is now ready! Here's a MEL script that automates the entire process. Just select all of the curves you want to group and run this script:

global proc groupUnderTransform(){
string $selCurves[] = `ls -sl`;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
select -deselect $selCurves[0];
pickWalk -d down;
select -add $selCurves[0];
parent -r -s;
select -r $selCurves[0];
}
groupUnderTransform;

Advertisement