BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Wednesday, December 15, 2010

Simple HUD Buttons

hudButton is a command that kind of flies under the radar mostly, but can be useful. For example making a HUD button that hides nurbs curves in the perspective view:

global int $gCurvesHudActive;
// this procedure could be combined into a single line and put in the button command
// but wouldnt fit in the blog post :D
global proc ToggleNurbsCurves() {
int $nurbsActive = `modelEditor -q -nurbsCurves modelPanel4`;
if ($nurbsActive == 1) hudButton -e -l "Show Nurbs Curves" HUDCurvesButton;
else hudButton -e -l "Hide Nurbs Curves" HUDCurvesButton;
modelEditor -e -nurbsCurves (abs(($nurbsActive)-1)) modelPanel4;
}

if ($gCurvesHudActive == 0) {
hudButton -s 8 -b 1
-vis 1
-l "Hide Nurbs Curves"
-bw 150
-padding 2
-bsh "roundRectangle"
-rc "ToggleNurbsCurves()"
HUDCurvesButton;
$gCurvesHudActive = 1;
}
else {
headsUpDisplay -remove "HUDCurvesButton";
$gCurvesHudActive = 0;
}

0 comments: