Pages

Monday, January 25, 2010

Creating A Slider Control GUI Without Using Mel

This week's tip is geared toward riggers & animators alike that prefer all their frequently used controls in their prime work area: the viewport. I enjoy working fullscreen [Ctrl+Space] and I feel that time spent on panels like the channelBox should be minimized and used for animating! So if you find yourself constantly using the virtual slider (that is, selecting the attribute name and then sliding with MMB in the viewport,) then read follow the following tutorial and see if it affects your workflow in a positive way.
  1. First create an empty group called sliderControl.
  2. Then create a NURBS square and stretch out the box—My scales are ScaleX: 8, ScaleY: 0, and ScaleZ: 0.25. Everything else is left default.
  3. Now place a circle with a radius of 0.5 on the origin.
  4. Rotate both objects about their X axis 90 degrees and freeze their transformations.
  5. Now in the outliner, MMB the circle and the NURBS squares' group and tuck it under sliderControl.
  6. Now select the circle and open up the attribute editor.
  7. Select the circle's transform node and open up the Limit Information rollout.
  8. Check Trans Limit X for Min and Max and set them to -4 and 4 respectively.
  9. Set the limits Y and Z limits to 0 and Lock and Hide the rest of the rotate and scale attributes.
  10. Finally, Lock and Hide the Boxes' attributes too.
Now, what you are left with is a slider control that can be turned into an Asset (Maya 2009+) and reused in all your files. You can link the slider knob to any attribute like a foot roll or fist control that requires a range. You can even attach it using an expression if you need to scale the range. However, if you are new to Mel, I recommend adjusting the Limit Information on the circle instead of scaling the values using code. You can link the circle's tx attribute to another attribute using the Connection Editor.

I hope you liked this tip and most importantly, I hope you find it useful.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.