Online Book Reader

Home Category

3ds Max 2012 Bible - Kelly L. Murdock [385]

By Root 1782 0
controller track for the variable, such as the position of an object.

FIGURE 36.3

The Track View Pick dialog box displays all the tracks for the scene. Tracks that you can select are displayed in black.


Assigning a variable to a controller enables you to animate the selected object based on other objects in the scene. To do this, create a variable and assign it to an animated track of another object. For example, if you create a Vector variable named boxPos and assign it to the Position track for a box object, then within the expression you can use this variable to base the motion of the assigned object on the box's position.

Building expressions

You can type expressions directly into the Expression pane of the Expression Controller dialog box. To use a named variable from one of the variable lists (Scalars or Vectors), type its name in the Expression pane. Predefined variables (presented later in the chapter) such as F and NT do not need to be defined in the variable panes. The Function List button opens a list of functions, shown in Figure 36.4, where you can view the functions that can be included in the expression. This list is for display only; you still need to type the function in the Expression pane.

Tip

One way to learn the syntax for different expressions is to enable the MacroRecorder in the MAXScript Listener window and look in the upper pane while performing a task in the viewports. •

Note

The Expression pane ignores any white space, so you can use line returns and spaces to make the expression easier to see and read. •

Debugging and evaluating expressions

After typing an expression in the Expression pane, you can check the values of all variables at any frame by clicking the Debug button. This opens the Expression Debug window, shown in Figure 36.5. This window displays the values for all variables, as well as the return value. The values are automatically updated as you move the Time Slider.

FIGURE 36.4

The Function List dialog box lets you view all the available functions that you can use in an expression.


FIGURE 36.5

The Expression Debug window offers a way to test the expression before applying it.


The Evaluate button in the Expression Controller dialog box commits the results of the expression to the current frame segment. If the expression contains an error, an alert dialog box warns you of the error. Replacing the controller with a different one can erase the animation resulting from an Expression controller.

Managing expressions

You can use the Save and Load button to save and recall expressions. Saved expressions are saved as files with an .xpr extension. Expression files do not save variable definitions.

Caution

If you load a saved expression into the Expression Controller dialog box, you need to reassign all variables before you can use the loaded expression. •

Tutorial: Creating following eyes

As a quick example, you'll start with a simple expression. The Expression controller is very useful for setting the eye pupil objects to move along with the ball's motion. This same functionality can be accomplished using a manipulator and wiring the parameter, but you show it with the Float Expression controller.

To make eye pupil objects follow a moving ball object, follow these steps:

1. Open the Following eyes.max file from the Chap 36 directory on the CD.

This file includes a face taken from a Greek model made by Viewpoint Datalabs, along with a ball that is animated to move back and forth.

2. Select the left eye pupil object named “pupil_l” (the right pupil has been linked to move with the left pupil), and open the Motion panel. Select the Position track, and click the Assign Controller button. Select the Position Expression controller, and click OK.

The Expression Controller dialog box opens.

3. Create a new vector variable named ballPos by typing its name in the Name field, selecting the Vector option, and clicking the Create button.

4. With the ballPos variable selected, click the Assign to Controller button. In the Track View Pick dialog

Return Main Page Previous Page Next Page

®Online Book Reader