Expressions are combinations of variables, operators, functions, and constant values that generate result values. You can use the result of an expression to set primitive attribute values, vary the effect of XGen modifiers, control how a Ptex map is applied to a Description, and more. You can create new expressions or load pre-authored expressions using the XGen Expression Editor.
The expression below consists of variables, functions, parameter definitions, comments, and operators. Each of these components is described in the following sections below.
$minLength = 1.0; # 0, 2 $maxLength = 5.0; # 0,10 rand($minLength, $maxLength)* $Pref #randomizes the min and max values.
In an expression, variables are names that represent values. These values can be used in calculations, such as in functions, or used to set attribute values. Things you need to know about variables are:
In the expression above, $minLength and $maxLength, are local variable names, and $Pref is a global variable that represents a point on a bound mesh.
Local variables can have any name with the exception of names reserved for global variables. Global variables do not need to be declared. As expressions become more complex, they often include a number of local variable declarations.
Functions perform evaluations for specific tasks. The input values that functions evaluate on are called arguments and can be variables, constants, or a combination of both. A function's arguments are enclosed in parentheses (), with commas separating each input value.
In the expression above, the rand () randomization function generates random values using the $minLength and $maxLength variables as inputs.
Some other commonly used functions include noise() and map(). Expressions do not always include functions.
Parameter definitions and comments begin with a pound sign (#) followed by numbers and text. In XGen expressions, typical parameter definitions can be used to set the value range of local variables or the texel resolution of Ptex map files. In the example above, # 0, 2 and #0, 10 appear after the local variable declarations to define the value ranges (0 to 2 and 0 to 10) for the variables.
Comments can include any text that provides information about the expression, making them easier to understand. For example, you can include comments to explain the reason of a local variable or function evaluation. In the example above, the comment, #randomizes the min and max values, describes the rand() function evaluation.
An operator is a symbol that representations a calculation or order of calculations. Operators typically perform arithmetic calculations, comparisons, and conditions such as addition (+), multiplication (*), less than (<), and greater than (>), or equal to (=).
To start using expressions in your hair and fur grooms and landscape scenes, see Basic expression examples.