3ds Max 2012 Bible - Kelly L. Murdock [386]
FIGURE 36.6
Select the Position track for the Sphere01 object in the Track View Pick dialog box.
5. In the Expression pane, erase the existing expression and type the following:
[ -3.1 + ballPos.x/20, -2.9, 41.0 ]
Then click the Debug button. The Expression Debug window appears, in which you can see the variable values change as items in the scene change. With the expression complete, you can drag the Time Slider back and forth and watch the pupil follow the ball from side to side. If you're happy with the motion, click the Evaluate button and then the Close button to exit the interface.
This is a simple example, but it demonstrates what is possible. Figure 36.7 shows the resulting face.
FIGURE 36.7
The Expression controller was used to animate the eyes following the ball in this example.
Using Expression Controllers
You can use expressions to control the transforms of objects. You can access these transforms from the Track View or from the Motion panel. You can also use expressions to control object parameters such as a box's length or material properties such as the amount of illumination applied to a material. You can access all these parameters from the Track View.
Animating transforms with the Expression controller
After you assign a controller to a transform track, the Expression pane in the Expression Controller dialog box includes the current values of the selected object. Position transforms display the X, Y, and Z coordinates of the object; Rotation transforms display the rotation value in radians; and Scale transforms display values describing the relative scaling values for each axis.
Note
Radians are another way to measure angles. A full revolution equals 360 degrees, which equates to 2 × pi radians. The Expression dialog box includes the degToRad and radToDeg functions to convert back and forth between these two measurement systems. •
Animating parameters with the Float Expression controller
To assign the Float Expression controller, select an object with a parameter or Modifier applied and open the Track View. Find the track for the parameter that you want to change, and click the Assign Controller button. Select the Float Controller from the list, and click OK.
Note
The actual controller type depends on the parameter selected. Many parameters use float expressions, but some use Transform controllers. •
After you assign the Expression controller, the Expression Controller dialog box opens, or you can open it by right-clicking the track and selecting Properties from the pop-up menu to load the dialog box. Within this dialog box, the Expression pane includes the current value of the selected parameter.
Tutorial: Inflating a balloon
The Push Modifier mimics filling a balloon with air by pushing all its vertices outward. In this tutorial, you'll use a balloon model created by Zygote Media to see how you can use the Float Expression controller to control the parameters of a modifier.
To inflate a balloon using the Float Expression controller, follow these steps:
1. Open the Balloon and pump.max file from the Chap 36 directory on the CD.
This file includes a pump created from primitives and the balloon model with the Push modifier applied.
2. Next, open the Track View by choosing Graph Editors⇒Track View⇒Curve Editor. Select the balloon and navigate the balloon object's tracks until you find the Push Value track (found under Objects⇒b3⇒Modified Object⇒Push⇒Push Value). Select the Push Value track, and click the Assign Controller button (or select it from the right-click pop-up menu). From the list of controllers, select Float Expression and click OK.
The Expression Controller dialog box opens.
3. In the Expression pane, you should see a single scalar value of 0. Modify the expression to read like this:
2 * NT
Click the Debug button to see the value