3D MAX TUTORIALS

 

Expression Controller

Main toolbar > Curve Editor (Open) > Select a track in the Track View hierarchy. > Track View toolbar > Controller menu > Assign > Expression

Graph Editors > Track View – Curve Editor > Select a track in the Track View hierarchy. > Track View toolbar > Controller menu > Assign > Expression

Interface Procedures

With the Expression controller you can use mathematical expressions to control the following animation aspects:

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 create and manage expression controllers in Track View — Dope Sheet. You can assign expressions to the following kinds of scene elements:

Scene elementController
Creation parametersAny numeric creation parameter
TransformsPosition [X, Y, Z]

X Rotation

Y Rotation

Z Rotation

Scale [X%, Y%, Z%]

ModifiersAny numeric modifier parameter (including creation parameters)
MaterialsColors [R, G, B]

Any numeric material parameter

Note: Expression controllers can 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.

See also

Expression Techniques

Expression Controller Techniques

Trigonometric Functions

Vectors

Procedures

To assign a constant value to a variable:

  1. Highlight the variable name in the Scalars or Vectors list.

  2. Click Assign to Constant.

  3. In the dialog, enter the new value of 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 to Controller.

    The Track View Pick subdialog is displayed, showing the track hierarchy. The display in the dialog is similar to the Track View hierarchy.

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

Example: To create an expression that moves a sphere in a precise circle:

  1. Create a sphere 30 units in diameter.

    Use Track View to create the Expression controller.

  2. In the Hierarchy list, expand Objects/Sphere01 so the sphere's Position track is visible. Select this track by clicking the Position label once to highlight it.

  3. Click Controller > Assign on the Track View—Dope Sheet toolbar.

    The Assign Controller dialog is displayed.

  4. Select Position Expression from the list of controller types, and then click OK.

    The Expression Controller dialog is displayed.

    Note: You can also open the Expression Controller dialog from the Controller > Properties menu in the Track View-Dope Sheet.

  5. In the Expression Controller dialog, create the expression.

    Replace the default expression by typing the following position expression in the Expression field:

    [100*cos(360*NT), 100*sin(360*NT), 0]

  6. Click Evaluate.

  7. Play the animation. The sphere moves in a circle about the world origin (0,0,0). The radius of the circular path is 100 units.

    You've now specified 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.

  1. Make Track View—Dope Sheet visible again.

  2. In the Expression Controller dialog, type radius in the Name field. Click Scalar, and then click Create.

    "radius" is displayed in the Scalars list in the lower-left of the dialog.

  3. Click Assign to Constant.

    A dialog titled "radius" is displayed.

  4. Type 150 in the value field, and then click OK.

    The radius variable is now 150.

    Now use the new variable in the expression.

Example continued: To replace the literal value with the variable name:

  1. In the Expression field, change 100 to radius in both places. The expression should now look like this:

    [ radius*cos(360*NT), radius*sin(360*NT), 0]

  2. Click Evaluate.

  3. Play the animation. The sphere moves in a circle about the world origin (0,0,0). The radius of the circular path is 150 units.

Example continued: To make the sphere rotate about a box:

  1. Create a box about 40 units square, and animate its position over three or four keyframes.

  2. Select the sphere.

  3. In the Expression Controller dialog, type boxposn in the Name field. Click Vector, and then click Create.

    The name "boxposn" is displayed in the Vectors list in the lower-left part of the dialog.

    Variable names are case sensitive; the variable name should be lower case.

  4. Click Assign to Controller.

    The Track View Pick dialog is displayed. It shows the object hierarchy as it appears in the left side of Track View-Dope Sheet.

  5. In the Hierarchy list, highlight the Position controller for Box01 and then click OK.

  6. In the Expression field, add boxposn as an offset:

    [radius * cos(360*NT), radius * sin(360*NT), 0]+boxposn.

  7. Click Evaluate, and then click Close.

    Play the animation again. The sphere moves in a circle around the box and follows the box wherever it moves.

Interface

Create Variables group

Name—Contains the variable.

Scalar—Selects the type of variable to create.

Vector—Selects the type of variable to create.

Create—Creates the variable.

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

Delete—Select a variable in the Scalar or Vector list, then click to delete it.

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.

Expression group

Type an expression in the Expression box.

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 group

Type text in this group to document an 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 save 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 may proceed further before the error is detected.

Close—Closes the Expression Controller dialog.


Comments

Home
Selectiong Objects
Selection Commands
Objects Properties
Programmers Forum
Birthday Gift Baskets
Creating Geometry
Transforms: Moving, Rotating, and Scaling Objects
Creating Copies and Arrays
Effects and Post-Production

Systems Animation
Character Assemblies Lights and Cameras
Advanced Lighting
Material Editor, Materials, and Maps
Rendering
3D MAX FORUM

Managing Scenes and Projects
Utilities
User Interface
Customizing the User Interface
Default Keyboards
Transforms: Moving, Rotating, and Scaling Objects
Creating Copies and Arrays
Rendering to Textures

Introduction
Glossary
Getting Started with 3ds max
Viewing and Navigation 3D Space
Modifiers
Surface Modeling
Precision and Drawing Aids
SpaceWarps and Particle
Adobe_Premiere Tutorials

Web Designer - offers freelance web design services, redesign, graphic design, content management, web development and e-commerce.
LTD