The expression controller, parameter wiring, and the numerical expression evaluator all use expressions, which are described in this topic.
An expression is a mathematical function that returns a value. You can use expressions to control the following scene elements:
| Scene element | Calculatable property |
|---|---|
| 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: Expressions only work with the individual XYZ components of Euler rotation. You can't assign an expression to TCB rotation or other kinds of rotation controllers.
Note: The links below are to the sections that follow in this topic.
The type of value returned by an expression depends on the kind of controller:
Float expressions return a floating-point scalar value (For example, 5.617). Scalars are used in the animation controllers of numeric parameters.
If the parameter has an integer value, the expression rounds the float value to the nearest integer.
Position, Scale, and Point3 expressions return a three-component vector. For example, [5, 18, 24]. The vector can represent an object's X,Y,Z location, percent scaling in X, Y, and Z, or a color (RGB values) in a material.
In the following tables, p and q are any scalar value or expression, V and W are any vector value or expression. (The character "x" is used as the vector cross-product operator.)
These are the arithmetic operators for scalar values:
| Operator | Use | Meaning |
|---|---|---|
| + | p+q | Addition |
| - | p-q | Subtraction |
| - | -p | Additive inverse |
| * | p*q | Multiplication |
| / | p/q | Division |
| ^ | p^q | power (p to the power of q); |
| ** | p**q | ^ and ** are the same operation |
You can also use logical (Boolean) operators with scalar values. These operators all return 1 if true, 0 otherwise:
| Operator | Use | Meaning |
|---|---|---|
| = | p=q | equal to |
| < | p<q | less than |
| > | p>q | Greater than |
| <= | p<=q | less than or equal to |
| >= | p>=q | Greater than or equal to |
| | | p|q | Logical OR, returns 1 if either p or q is nonzero; otherwise, returns 0 |
| & | p&q | Logical AND, returns 1 if p and q are both nonzero; otherwise, returns 0 |
Tip: Logical operators are useful with the "if" function.
For vectors that have a variable name, you can use a special component operator (.) to refer to the three scalar components of the vector:
These are the operators for vector arithmetic:
Expressions have eight levels of precedence. The higher the operator is on the list, the earlier it is evaluated.
| Operator | Level of Precedence |
|---|---|
| - + | as unary operators, as in -8, +25 |
| . | the component operator, as in V.x |
| ** ^ | |
| X | cross product |
| * / | |
| + - | |
| = < > <= >= | |
| | & |
Parentheses are a special case. They are a grouping or subexpression operator that is provided so you can override the precedence order of the other operators.
In expressions, variables are represented by symbolic names. You create them to contain constant or variable values in your expressions. Several predefined variables are also provided. Some of thes have a constant value, others can vary.
Note: In the numerical expression evaluator, you can't use the predefined variables, but you can use the predefined constants.
These are the predefined variables that have a variable, time-based value (variable names are case sensitive):
| Variable Name | Meaning |
|---|---|
| F | Frame number.For each frame, F equals the current frame number, counting from zero. The range of frames can vary depending on the number of frames in the active time segment. |
| NT | Normalized time.By definition, normalized time (NT) ranges from 0 to 1 over the active time segment, regardless of how many frames are in the segment. If you base an expression on NT, its effect happens exactly once over the range. You can also multiply NT by a factor for the expression's effect to occur a certain number of times (for example, 2*NT causes the expression's effect to occur twice).Expressions based on NT speed up or slow down if you change the length of the time segment. |
| S | Seconds (elapsed time in seconds).Elapsed time is measured from the first frame to the current frame. The range of seconds can vary depending on the total time of the active time segment. |
| T | Ticks (elapsed time in ticks).There are 4800 ticks per second. Elapsed time is measured from the first frame to the current frame. The range of ticks can vary depending on the total time of the active time segment. |
Variable names can contain as many alphanumeric characters as you like. Their length is not limited.
The variable name must begin with a letter. Numbers are valid within a variable name (as in "Pos1" or "M23").
Variable names are case-sensitive. For example, "pos", "Pos", and "POS" designate three different variables.
You can't create a variable with a name that duplicates another name, including the variable names that are predefined.
Following is a list of the functions provided for expressions. In this list, p, q, and r represent scalar values or scalar expressions. V and W represent vector values or vector expressions.
To use a function in an expression, enter the name of the function and appropriate arguments to it.
The sine, cosine, and tangent functions take an angle in degrees and return a floating-point value. The arc functions take a floating-point value and return a value in degrees.
| Function | Meaning |
|---|---|
| Ln(p) | natural (base e) logarithm |
| log(p) | common (base 10) logarithm |
| exp(p) | exponential function exp(p)=e^p |
| pow(p,q) | p to the power of q (p^q) |
| sqrt(p) | square root |
| abs(p) | absolute value |
| min(p,q) | minimum returns p or q, depending on which is smaller |
| max(p,q) | maximum returns p or q, depending on which is greater |
| mod(p,q) | remainder of p divided by q |
Web Designer - offers freelance web design services, redesign, graphic design, content
management, web development and e-commerce.
LTD