Share
 
 

Expression Controller

The Expression controller lets you use mathematical expressions to control these animation aspects: object parameters such as length, width, and height; and transform and modifier values such as an object's position coordinates.

  • Assign Controller > ... Expression
  • Default menu: Animation menu > Position Controllers or Scale Controllers > Expression

Interface Procedures

You can constrain values by basing them on the controller values of other objects in the scene.

An expression is a mathematical function that returns a value. 3ds Max evaluates the expression once for each frame of an animation, generating values that can change from frame to frame.

You can assign expressions to the following kinds of scene elements:

Scene element Controller
Creation parameters Any numeric creation parameter
Transforms Position [X, Y, Z]

X Rotation

Y Rotation

Z Rotation

Scale [X%, Y%, Z%]

Modifiers Any numeric modifier parameter (including creation parameters)
Materials Colors [R, G, B]

Any numeric material parameter

Note: Expression controllers work only with the individual XYZ components of Euler rotation. You can't assign an expression to TCB Rotation or other kinds of rotation controllers.

To learn how to use an Expression Controller to create animation, see Example: To Animate an Object with an Expression controller.

Note: The Expression Controller automatically opens when you add an Expression Float or Expression Point3 expression engine in the Data Channel Modifier process stack.

Procedures

To assign a constant value to a variable:

  1. Highlight the variable name in the Scalars or Vectors list.
  2. Click Assign Constant.

    3ds Max opens a new dialog.

  3. On the dialog, enter the new value (or, in the case of a vector, values) for the constant, and then click OK.

To assign a controller to a variable:

  1. Highlight the variable name in the Scalars or Vectors list.
  2. Click Assign Controller or Assign Controller \ Node if a Vector variable is highlighted. (If the current variable type is Vector, you can assign a scene node to the highlighted variable. The node's world transform position is taken at the current time plus the variable's Tick Offset. See To assign a Node to a Vector variable, below)

    3ds Max opens the Track View Pick subdialog, showing the track hierarchy. The dialog display is similar to the Track View hierarchy.

  3. Highlight the track for the variable to use, and then click OK.

To assign a Node to a Vector variable

  1. Highlight the variable name in the Vectors list.
  2. Click Assign Controller \ Node. 3ds Max opens the Track View Pick subdialog, showing the track hierarchy. The dialog display is similar to the Track View hierarchy.
  3. Highlight the Node for the variable to use, and then click OK.

Interface

Expression Controller dialog: Create Variable set to Vector

Tip: You can resize the dialog by dragging an edge or a corner.

Create Variables group

Name
The variable name.
Scalar/Vector
Choose the type of variable to create. If you choose Vector, the Assign Controller button changes to Assign Controller \ Node. (See interface image, above)
Create
Creates the variable and adds it to the appropriate list.

You must enter a name and specify a type before clicking Create.

Delete
Deletes the highlighted variable in the Scalars or Vectors list.
Rename
Renames the highlighted variable in the Scalars or Vectors list.

First highlight the variable in the list; this places the name in the Name field. Edit the name in the Name field, and then click Rename; the new name replaces the previous one in the list.

Variable Parameters group

Tick Offset
Contains an offset value. A tick is 1/4800 of a second. If a variable has a non-zero tick offset, that value is added to the current time.
Scalars list
Lists the scalar variables you've created. The following pre-defined constant variables are available in every expression controller and cannot be deleted or renamed:
  • F the current time in frames
  • NT the normalized time
  • S the current time in seconds
  • T the current time in ticks
Vectors list
Lists the vector variables you've created.
Assign Constant
Opens a dialog that lets you assign a constant to the highlighted variable.

Constant assignment for a scalar variable

Constant assignment for a vector variable

Assign Controller / Assign Controller \ Node
Opens a Track View Pick dialog that lets you assign a controller to the highlighted variable. The controller's value is taken at the current time plus the variable's Tick Offset.
Note: If the current variable type is Vector the Assign Controller button name changes to Assign Controller \ Node, and you can assign a scene node to the highlighted variable. The node's world transform position is taken at the current time plus the variable's Tick Offset.
Expression window
Enter the expression to evaluate. The expression must be a valid mathematical expression. The result is either a three-value vector for a vector expression (position, scale, or point3) or a scalar value for a float expression.
Description window
Enter optional text do document the expression. For example, you can describe user-defined variables.
Function List
Displays a list of Expression controller functions.

In the list, p, q, and r represent scalar values or scalar expressions; V and W represent vector values or vector expressions.

Save
Saves an expression. Expressions are saved as files with a ..xpr file name extension.
Load
Loads an expression.

A saved expression does not include variable definitions or values. After loading the expression, you need to redefine them.

Debug
Displays the Expression Debug window.

This window shows the values of all variables, and the value of the expression. When you change the variables or move the time slider, the Debug window automatically updates so you can interactively view what's happening with the expression. The values for frames (F), normalized time (NT), secs (S), and ticks (T) are also displayed.

Evaluate
Evaluate the expression for each frame in the animation.

There is no explicit assignment (= or := operator) as in a conventional programming language; the assignment is implicit and takes place over time.

If the expression has a syntax error, an error message is displayed. The error message is the first part of the expression itself. The last character in the error message is the point of the error. This is usually where the error actually is, unless the problem is that opening and closing parentheses (or the braces for vectors) don't match. In this case, evaluation can proceed further before the error is detected.

Close
Closes the Expression Controller dialog.

Was this information helpful?