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.
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 |
To assign a constant value to a variable:
3ds Max opens a new dialog.
To assign a controller to a variable:
3ds Max opens the Track View Pick subdialog, showing the track hierarchy. The dialog display is similar to the Track View hierarchy.
Example: To create an expression that moves a sphere in a precise circle:
You'll use Track View to create the Expression controller.
3ds Max opens the Assign Controller dialog.
3ds Max opens the Expression Controller dialog.
[100*cos(360*NT), 100*sin(360*NT), 0]
The expression specifies a circular path for the sphere. NT is a variable that means "normalized time." Movement based on NT happens exactly once per the active time segment, regardless of how many frames are in the animation.
Example continued: To change the radius of the circle:
The two 100s in the position expression from the previous procedure specify the radius. To adjust the radius of the circle's path, create a symbolic variable to represent the radius. The variable has a constant value that is easy to edit.
The variable name "radius" appears in the Scalars list of the dialog.
3ds Max opens a dialog titled "radius".
The radius variable is now 150.
Next you'll use the new variable in the expression.
Example continued: To replace the literal value with the variable name:
[ radius*cos(360*NT), radius*sin(360*NT), 0]
Example continued: To make the sphere rotate about a box:
The name "boxposn" is displayed in the Vectors list in the lower-left area of the dialog.
Variable names are case sensitive; the variable name should be lower case.
The Track View Pick dialog is displayed. It shows the object hierarchy as it appears in the left side of Track View-Dope Sheet.
[radius * cos(360*NT), radius * sin(360*NT), 0]+boxposn.
Play the animation again. The sphere moves in a circle around the box and follows the box wherever it moves.
You must enter a name and specify a type before clicking Create.
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.
Constant assignment for a scalar variable
Constant assignment for a vector variable
In the list, p, q, and r represent scalar values or scalar expressions; V and W represent vector values or vector expressions.
A saved expression does not include variable definitions or values. After loading the expression, you need to redefine them.
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.
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.