Part
Five: Refine the Asset's User Interface Now
that the digital asset is again editable, changes can be made to
spruce up the user interface. The parameters need to be better organized
and the addition of handles and HUD sliders will provide interactive
tools in the Viewer pane.
Another issue
to address is the fact that the radius, height, length, and width
parameters don't always work depending on which shape you have chosen.
For instance the sphere only uses Radius while the Plane only uses
Width and Length. A good user interface would disable controls for
parameters that do not contribute to the definition of the chosen
shape. A couple of methods are explored for solving this UI dilemma.
1.
Organize the Parameters
In the Operator
Type Properties window, click on the Parameters
tab. From the menu at the top of the Parameter list, select Folder.
Set its Label
to Shape. Repeat this and set the second folder's
Label to Shading.
Any parameters listed below one of these will be placed in a tabbed
section nested in the Controls tab.
LMB-drag
the Shape folder to the top of the list. Next LMB-drag
Diffuse, Specular and Roughness
below the Shading folder.
Click Apply.
Now in the Controls tab you can see the new sections that make it
easier to find specific Parameters.

2.
Create Viewer Pane Controls
In the Viewer
Pane there are two places you can view Parameters. One is in the
Control bar at the top and the other is when you press p
to call up a Floating Tool Dialog.
To promote the
Shapes parameter to the Control bar, go to the
Operator Type Properties window, select Shapes (shapes) from
the parameter list and set Export
to All. To
promote the other parameters to only the Tool Dialog, set Export
to Dialog. Click
Apply to accept.
Now select the
my_primitives object in the Network pane and then
with your Cursor over the Viewer pane press Enter
to go into the editing mode for that object.
The name
My Primitives will be in the top left of the Viewer pane.
Select Pane > Toolbars and Controls
> Operation Controls to open the Control
bar. The shapes menu is now available. If you press p
in the Viewer pane, the Tool Dialog opens with all the parameters
listed. Now your tool is working more like any other Houdini tool.

3.
Create a Custom Handle
When you are
in the My Primitive operator, you do not have interactive
handles for positioning the shape. You could get the Transform
tool and work with that or you can add a transform handle into the
interface for the operator.
In the Operator
Type Properties window, click on the Handles tab.
From the Create New
menu at the top of the Handles list, select Transformer
(xform). This puts the handle in the list and
provides you with a place to map parameters.
Important:
These mappings should not be directed to the parameters found in
the lower levels of the network. Only the parameters that are a
part of the high-level operator can be used. These parameters include
those found in the Transform tab and those in the Controls tab.
Click on the
arrow [>] next to rx
and select Rotate rx.
Repeat this for the following parameters:
ry
| Rotate
ry
rz | Rotate
rz
tx | Translate
tx
ty | Translate
ty
tz | Translate
tz
sx | Scale
sx
sy | Scale
sy
sz | Scale
sz
Press Apply.
Now the handle is available for manipulating the transformations
of this object.

4.
Create Custom HUD sliders
Another useful
handle type is HUD sliders.
You will create HUD sliders for the four main shape attributes belonging
to the object. From the Create New
menu at the top of the Handles list, select HUD
slider (hudslider). Set its Name
to Radius then
click on the arrow [>] next to value
and select Radius (rad).
Repeat these
steps to make HUD sliders for Height
(ht), Length
(lgth), and Width
(wth). Be sure to set each slider's Name
to match the parameter.
Click Apply
to view these controls in the Viewer Pane.

5.
Disable some parameters
To clean up
the user interface, you should disable those parameters that are
not being used when a particular shape has been chosen. In the Operator
Type Properties window, go to the Parameters tab and in the Disable
When field, add the following:
For Radius
enter {
shape 0 } { shape 2 }
For
Height enter
{
shape 0 } { shape 1 }
For Length
enter {
shape 1 } { shape 3 } { shape 4 }
For Width
enter {
shape 1 } { shape 3 } { shape 4 }
These entries
basically say when shape equals the values listed, then disable
the parameter. The numbers represent the values originally found
in the switch SOP.
Click Apply
to view these controls in the Control section in the Parameter pane.
Change the Shape
to see how they work. As you pick each shape, the appropriate parameters
are disabled. If you have problems, make sure that the parameter
name for your Shapes
parameter is entered properly as shape.

6.
Disable some HUD sliders
The disabling
of the HUD sliders requires a couple of more steps. You will need
to create some invisible parameters that will only be used for this
purpose.
Under the Parameter
tab, select Create New > Integer.
Set its Name
to rad_hud_display and its Label
to Radius HUD Display. Click on the Invisible button
so that this won't appear in the Controls tab then put the following
expression in the Default
field:
(ch ("shape")==1)
|| (ch ("shape")==3) || (ch ("shape")==4)
This expression
sets this parameters value to 1 if the shape is set to either the
Sphere, Cylinder or Cone. These shapes all use Radius.
Now go back
to the Handles tab and click on the Radius
handle in the list. From the arrow [>] next to onoff,
select Radius HUD Display
(rad_hud_display).
Now when this value is 1, the HUD slider will be on. When it is
0 then the HUD slider will be off.
Use the same
technique to disable HUD sliders for height, length, and width.
Remember to list the opposite shapes to those used in disabling
the parameters themselves. Click Apply
to accept. Again change the Shape
to see how they work |