马上注册,加入CGJOY,让你轻松玩转CGJOY。
您需要 登录 才可以下载或查看,没有帐号?立即注册
×
本帖最后由 19silly 于 2009-10-21 11:57 编辑
Contents
1. What is a rollout ? 2. A first rollout 2.1 Adding user interface elements 2.2 Example user interface 3.User interface layout 4. User interface events 5. Generated code 6. Palisade generator 7. Opening and closing the rollout 8. Installing a button
1. What is a rollout ?
In 3D Studio Max , a rollout is a top level user interface component that acts as a container for other user interface components. There is a visual editor that can be used to add user interface components into a rollout and this tool also allows you to change the properties of these user interface components (such as the caption, width, height, position, tool tip ... )
The interesting fact is that the visual editor generates code that supports a full round trip. Changes in the code are reflected back into the visual editor, and changes made in the editor are reflected back into the code.
Normally, a rollout is shown as a sub window of the 3D Studio Max environment and this subwindow will be shown when a user presses a button or when a users clicks on a menu item.
2. A first rollout
The first rollout will be a simple "Hello World" rollout , and we will integrate this rollout in 3D Studio Max via the UI Customizer tool.
First we create a new script via the menu item MAXScript --> New Script.
Instead of a utility we now create a macroscript , and define some properties for the appearance of this macroscript on a button or a menu item :
macroScript RolloutTest
category:"DAE Tools"
internalCategory:"DAE Tools"
buttonText:"RolloutTest"
icon:#("Systems",2)
tooltip :"This is a rollout test"
(
-- contents
)
A macroscript is defined by the following properties :
- category : provides an easy way to find scripts in the UI customizer (see further).
- internalCategory : the value of this property is used in .cui , .kbd and .mnu files.
- buttonText : if this macroScript is bound to a button, this is the text that will appear on the button.
- icon : the icon to use for this button. There are a number of predefined categories for icons, and the example uses the second icon from the "Systems" icon category.
- tooltip : The tooltip that will be shown when the mouse hovers overs the button or menuitem.
2.1 Adding user interface elements
Now we can start adding user interface elements via the visual editor. Place the cursor inside the body of the macroScript and click on the menu : Tools --> New Rollout
This will off course create a new rollout and start the visual editor :
| Image 1 : Visual editor
| The bottom row of the visual editor contains the user interface elements that can be added to the user interface.
The "Value" tab contains all the properties of the current component. Because we started with a new rollout the rollout itself is selected as current component.
For now , there are two important properties :
- name : this property will be the name for the rollout in the script. For this example , change this property to PalisadeRollout.
- caption : The title for the rollout. For this example, change this rollout to "Palisade generator".
Keep the visual editor open for the next part of this tutorial. As long as the visual editor is open, it is not possible to change the macroscript via the MAXScript Editor.
2.2 Example user interface
As an example we create a palisade generator user interface. To make things a little more interesting we add small variations in radius and height for the individual trunks of the palisade.
| Image 2 : Palisade example
|
The user interface for the palisade generator allows the user to set the following parameters :
- number of trunks
- radius : the radius for the trunks of the palisade
- height : the height of the palisade
- color : the color for the trunks in the palisade
2.2.1 Number of trunks
We will set the number of trunks with the help of a spinner control. Select the spinner control component in the bottom row of the visual editor :
| Image 3 : Select spinner component
| Next click somewhere on the rollout and drag the outline for the spinner component :
| Image 4 : Add spinner component
|
Next we need to set the properties of the new spinner component. The important properties are :
- name : this is the variable name for the spinner component. By default a spinner component has the prefix spn. Give this property the value spnNumberOfTrunks.
- caption : the caption for the spinner component. Give this property the value "Number of trunks :".
- range : the range for the spinner component. A range of [1,100,10] means that the spinner component has a minimum of 1, a maximum of 100 and a default value of 10.
- type : the number of trunks is an integer, so set this property to #integer.
The position and dimension of the spinner component can be adjusted by dragging the control handles of the component on the rollout, but it is easer to use the "Layout" menu to align and space components.
The controller property allows you to directly set a rotation , translation or any controllable value for an object in the scene. We will not use this property in the
Important note : There are difficulties setting the range property when the locale is set to a language that uses the comma as a symbol for floating point numbers. In that case it is necessary to set the range in the script file. |