OpenVDB 10.0.1
|
float@myattribute = 0.0f;
which sets the value of this attribute on the geometry to `0.0f`. Category | Type | Definition | Attribute Syntax | Points | Voxels |
---|---|---|---|---|---|
Scalars | bool | Boolean value, true or false | bool@ | Yes | Yes |
int16 * | 16-bit signed integer value | int16@ | Yes | No | |
int32 | 32-bit signed integer value | int32@, int@, i@ | Yes | Yes | |
int | Alias for integer type (typically int32) | ||||
int64 | 64-bit signed integer value | int64@ | Yes | Yes | |
float | 32-bit floating point value | float@ f@ @ | Yes | Yes | |
double | 64-bit floating point value | double@ | Yes | Yes | |
Vectors | vec2i | 2-element vector of integer values | vec2i@ | No | No |
vec2f | 2-element vector of float values | vec2f@ | No | No | |
vec2d | 2-element vector of double values | vec2d@ | No | No | |
vec3i | 3-element vector of integer values | vec3i@ | Yes | Yes | |
vec3f | 3-element vector of float values | vec3f@ v@ | Yes | Yes | |
vec3d | 3-element vector of double values | vec3d@ | Yes | Yes | |
vec4i | 4-element vector of integer values | vec4i@ | No | No | |
vec4f | 4-element vector of float values | vec4f@ | No | No | |
vec4d | 4-element vector of double values | vec4d@ | No | No | |
Matrices | mat3f | 3x3-matrix of float values | mat3f@ | Yes | No |
mat3d | 3x3-matrix of double values | mat3d@ | Yes | No | |
mat4f | 4x4-matrix of float values | mat4f@ | Yes | No | |
mat4d | 4x4-matrix of double values | mat4d@ | Yes | No | |
Strings | string | A string of characters | string@ | Yes | Yes |
int + float
) values may need to be converted to another type before the operation is performed. To allow for easier writing of expressions, AX will automatically detect these cases and convert values when necessary. This is known as implicit type conversion and the way in which the target operation type is chosen is known as type precedence. mat3f
to mat3d
. The conversion rules for more than the element type (e.g. int
to mat4f
) are governed by AX's assignment and operator rules, detailed in the Operators section of this documentation. vec2i
to vec2f
). Each scalar type has a ranking which is compared, and the resulting highest rank is chosen as the target type for all values. These rankings are defined as follows:double
, all other element types are converted to double
float
, all other element types are converted to float
int64
, all other element types are converted to int64
int32
, all other element types are converted to int32
bool
Operators | ||||||||
---|---|---|---|---|---|---|---|---|
Binary Operators | Unary Operators | Other | ||||||
Assignments | Arithmetic | Comparisons / Relational | Logical | Arithmetic | Logical | Increment / Decrement | Container Access | Other |
|
|
|
|
|
|
|
|
|
Operator Name | Operator Syntax | Returns |
---|---|---|
Simple assignment | `lhs` = `rhs` | Reference to `lhs` |
Addition assignment | `lhs` += `rhs` | Reference to `lhs` |
Subtraction assignment | `lhs` -= `rhs` | Reference to `lhs` |
Multiplication assignment | `lhs` *= `rhs` | Reference to `lhs` |
Division assignment | `lhs` /= `rhs` | Reference to `lhs` |
Modulo assignment | `lhs` %= `rhs` | Reference to `lhs` |
Bitwise AND assignment | `lhs` &= `rhs` | Reference to `lhs` |
Bitwise OR assignment | `lhs` |= `rhs` | Reference to `lhs` |
Bitwise XOR assignment | `lhs` ^= `rhs` | Reference to `lhs` |
Bitwise shift left assignment | `lhs` <<= `rhs` | Reference to `lhs` |
Bitwise shift right assignment | `lhs` >>= `rhs` | Reference to `lhs` |
rhs
: `lhs` = `rhs` |
Left Operand Type | Binary Op(s) | Right Operand Type | Description |
---|---|---|---|
scalar | = | scalar | On type mismatch, right hand side is copied and implicitly cast to the left hand side type. |
vector | = | scalar | Each element of the vector is set to the right hand side scalar. i.e. a[0] = b; ... a[n-1] = b; where n is the size of the vector. If the scalar type does not match element type of vector, the scalar is copied and implicitly cast to that type. |
vector | Component wise assignment i.e. a[0] = b; ... a[n-1] = b; where n is the size of the vector. vec3f a = 0, b = 1;
a = b;
vec3f a = 0, b = 1;
for (int i = 0; i < 3; ++i) a[i] = b[i];
| ||
matrix | = | scalar | Diagonal matrix construction. Each diagonal component of the left hand side matrix is set to to the right hand side scalar. All other components are zero initialized i.e. mat3f a;
int dim = 3, b = 1;
for (int i = 0; i < dim; ++i)
a[i] = (i % (dim+1) == 0) ? b : 0;
a is the matrix, dim is the dimension of the matrix (e.g. 3 for mat3f ) and b is the scalar. If the scalar type does not match element type of matrix, the scalar is copied and implicitly cast to that type. |
matrix | Component wise assignment i.e. a[0] = b[0]; ... a[n-1] = b[n-1]; where n is the total size of the matrix. mat4f a = 0, b = 1;
a = b;
mat4f a = 0, b = 1;
for (int i = 0; i < 16; ++i) a[i] = b[i];
| ||
string | = | string | Replaces the contents of the left hand side string with a copy of the contents in the right hand side string. |
`lhs` op `rhs` |
+= | -= | *= | /= | %= | &= | |= | ^= | <<= | >>= |
a += b
) is similar to replacing the compound assignment with a direct assignment followed by a binary expression with the same operands and given arithmetic token (i.e. a = a + b
). However, compound assignments imporantly do not evaluate the `lhs` twice. This is important when assigning to an expression which is not an attribute or local value. The best example of this is assigning to a pre-crement operation: rhs
following the rules of AX's arithmetic type precedence. See the arithmetic operations section for more information on arithmetic type precedence and explanations on the above compound operators. Operator Name | Operator Syntax | Returns |
---|---|---|
Addition | `lhs` + `rhs` | The sum of both operands |
Subtraction | `lhs` - `rhs` | The first operand minus the second operand |
Multiplication | `lhs` * `rhs` | The product of both operands |
Division | `lhs` / `rhs` | The first operand divided by the second operand |
Modulo | `lhs` % `rhs` | The floored modulo operator. See Multiplicative operands |
Bitwise AND | `lhs` & `rhs` | The integral bitwise AND result of each bit in the first operand applied to the bit at the same location in the second operand |
Bitwise OR | `lhs` | `rhs` | The integral bitwise OR result of each bit in the first operand applied to the bit at the same location in the second operand |
Bitwise XOR | `lhs` ^ `rhs` | The integral bitwise XOR result of each bit in the first operand applied to the bit at the same location in the second operand |
Bitwise shift left | `lhs` << `rhs` | The integral bitwise left shift of the first operand by the second operand |
Bitwise shift right | `lhs` >> `rhs` | The integral bitwise right shift of the first operand by the second operand |
`lhs` `+` `rhs` |
`lhs` `-` `rhs` |
Left Operand Type | Binary Op(s) | Right Operand Type | Description |
---|---|---|---|
scalar | + - | scalar | Returns the result of the scalar addition or subtraction. |
vector | Performs per component binary operations (after implicit conversion) with the left hand side scalar to every element of the right hand side vector or matrix, returning a vector or matrix. vec3f a = 2.0f;
int b = 1;
vec3f c = b + a;
vec3f a = 2.0f;
int b = 1;
vec3f c;
for (int i = 0; i < 3; ++i) c[i] = b + a[i];
| ||
matrix | |||
vector | + - | scalar | Same as scalar op vector |
vector | Performs per component binary operations (after implicit conversion), returning a new vector with each element holding the corresponding result. Operand sizes must match. vec3f a = 2, b = 1;
vec3f c = a - b;
vec3f a = 2, b = 1;
vec3f c;
for (int i = 0; i < 3; ++i) c[i] = a[i] - b[i];
| ||
matrix | + - | scalar | Same as scalar op matrix |
matrix | Performs per component binary operations (after implicit conversion), returning a new matrix with each element holding the corresponding result. Operand sizes must match. mat4f a = 0, b = 1;
mat4f c = a - b;
mat4f a = 0, b = 1;
mat4f c;
for (int i = 0; i < 16; ++i) c[i] = a[i] - b[i];
| ||
string | + | string | Performs string concatenation |
a + b = b + a
) but is not necessarily associative. i.e. (a + b) + c
is not necessarily equal to a + (b + c)
. `lhs` `*` `rhs` |
`lhs` `/` `rhs` |
`lhs` `%` `rhs` |
d % D
returns the result D - d * floor(D/d)
. This is in contrast to truncated modulo operations D - d * (D/d)
where the division is truncated. %
and /
differ when either `d` or `D` is negative. i.e.: (d/D)*D + (dD) != d
Left Operand Type | Binary Op(s) | Right Operand Type | Description |
---|---|---|---|
scalar | * / % | scalar | Returns the result of the scalar multiplication, division or remainder of the division respectively. |
vector | Performs per component binary operations (after implicit conversion) with the left hand side scalar to every element of the right hand side vector. The scalar is effectively treated as a vector of the same size as the right hand side type. vec3f a = 2.0f;
int b = 1;
vec3f c = b * a;
vec3f a = 2.0f;
int b = 1;
vec3f c;
for (int i = 0; i < 3; ++i) c[i] = b * a[i];
| ||
* | matrix | Performs matrix multiplication after diagonal matrix construction from the left hand side scalar. mat3f a = 1;
float b = 1;
mat3f c = a * b;
mat3f a = 1;
float b = 1;
mat3f tmp = b; // diagonal matrix
mat3f c = a * tmp;
| |
vector | * / % | scalar | Same as scalar op vector with the operands reversed (importantly for division and modulus) |
vector | Performs per component binary operations (after implicit conversion), returning a new vector with each element holding the corresponding result. Operand sizes must match. vec3f a = 2, b = 1;
vec3f c = a * b;
vec3f a = 2, b = 1;
vec3f c;
for (int i = 0; i < 3; ++i) c[i] = a[i] * b[i];
| ||
* | matrix | Transforms the left hand side vector by the right hand side matrix using matrix multiplication. This is the same as calling the transform function. e.g: mat4f a = identity4();
vec3f b = { 1, 2, 3 };
b = b * a;
mat4f a = identity4();
vec3f b = { 1, 2, 3 };
b = transform(b, a);
mat4 can only be applied to a vec4 . However, it is often useful to be able to directly apply mat4 transformations to vec3 types, most often due to positions being represented as vec3 . vec3 * mat4 multiplication is supported, where by the vec3 is extended with a 1 component and the resulting last last component is dropped from the return value: mat4f a = identity4();
vec3f b = { 1, 2, 3 };
// b * a is equal to:
vec4f tmp;
tmp[0] = b[0];
tmp[1] = b[1];
tmp[2] = b[2];
tmp[3] = 1;
tmp = tmp * a;
b[0] = tmp[0];
b[1] = tmp[1];
b[2] = tmp[2];
| |
matrix | * | scalar | Same as scalar * matrix |
vector | Transforms the right hand side vector by the left hand side matrix using matrix multiplication. This is the same as calling the pretransform function. e.g: mat4f a = identity4();
vec3f b = { 1, 2, 3 };
b = a * b;
mat4f a = identity4();
vec3f b = { 1, 2, 3 };
b = pretransform(a, b);
mat4 can only be applied to a vec4 . However, it is often useful to be able to directly apply mat4 transformations to vec3 types, most often due to positions being represented as vec3 . mat4 * vec3 multiplication is supported, where by the vec3 is extended with a 1 component and the resulting last last component is dropped from the return value: mat4f a = identity4();
vec3f b = { 1, 2, 3 };
// a * b is equal to:
vec4f tmp;
tmp[0] = b[0];
tmp[1] = b[1];
tmp[2] = b[2];
tmp[3] = 1;
tmp = a * tmp;
b[0] = tmp[0];
b[1] = tmp[1];
b[2] = tmp[2];
| ||
matrix | Performs matrix multiplication and returns the matrix product, which is matrix of matchign size and type. Operand sizes must match. e.g: mat4f a = 1, b = 2;
mat4f c = a * b;
mat4f a = 1, b = 2;
mat4f c;
for(int i = 0; i < 4; ++i) {
for(int j = 0; j < 4; ++j) {
for(int k = 0; k < 4; ++k) {
c[i,j] += a[i,k] * b[k,j];
}
}
}
|
a * b = b * a
) but is not necessarily associative. i.e. (a * b) * c
is not necessarily equal to a * (b * c)
.`lhs` `&` `rhs` |
`lhs` | `rhs` |
`lhs` `^` `rhs` |
`lhs` `<<` `rhs` |
`lhs` `>>` `rhs` |
|
(pipe token) is the result of the logical OR operation on each pair of the corresponding bits of the input operands.Operator Name | Operator Syntax | Returns |
---|---|---|
Equal to | `lhs` == `rhs` | Returns true if both operands are equal |
Not equal to | `lhs` != `rhs` | Returns true if operands are not equal |
Less than | `lhs` < `rhs` | Returns true the left hand side value is less than the right hand side |
Greater than | `lhs` > `rhs` | Returns true the left hand side value is greater than the right hand side |
Less than or equal to | `lhs` <= `rhs` | Returns true the left hand side value is less than or equal to the right hand side |
Greater than or equal to | `lhs` >= `rhs` | Returns true the left hand side value is greater than or equal to the right hand side |
Left Operand Type | Binary Op(s) | Right Operand Type | Description |
---|---|---|---|
scalar | == != < > <= >= | scalar | Returns the result of the scalar comparison. |
== != | vector | Performs per component comparisons (after implicit conversion) with the lefthand side scalar to every element of the right hand side vector or matrix and perform a logical AND combination on the results of these comparisons. This effectively returns true if every element of the vector or matrix is equal to the scalar. vec3f a = 2.0f;
int b = 1;
bool c = b == a;
vec3f a = 2.0f;
int b = 1;
bool c = a[0] == b;
for (int i = 1; i < 3; ++i) c &= a[i] == b;
| |
matrix | |||
vector | == != < > <= >= | scalar | Same as scalar op vector |
== != | vector | Performs binary comparison operations (after implicit conversion) on each pair corresponding components in the vector operands and returns true if all component pairs are equal. Operand sizes must match. vec3f a = 1, b = 2;
bool c = a == b;
vec3f a = 1, b = 2;
bool c = a[0] == b[0];
for (int i = 1; i < 3; ++i) c &= a[i] == b[i];
| |
matrix | == != < > <= >= | scalar | Same as scalar op matrix |
== != | matrix | Performs binary comparison operations (after implicit conversion) on each pair corresponding components in the matrix operands and returns true if all component pairs are equal. Operand sizes must match. mat4f a = 1, b = 2;
bool c = a == b;
mat4f a = 1, b = 2;
bool c = a[0] == b[0];
for (int i = 1; i < 16; ++i) c &= a[i] == b[i];
|
Operator Name | Operator Syntax | Returns |
---|---|---|
AND | `lhs` && `rhs` | Returns true if both operands are true. Otherwise, the result is false. This operator is short-circuiting. |
Inclusive OR | `lhs` || `rhs` | Returns true if either the first or the second operand is true. This operator is short-circuiting. |
Operator Name | Operator Syntax | Returns |
---|---|---|
Unary plus | + `a` | Returns the value of its operand, `a` |
Unary minus | - `a` | Returns the negative representation of `a` |
Bitwise NOT | ~ `a` | Returns the bitwise NOT (one's complement) value of `a`. This operator is only valid on integral element types. |
Operand Type | Binary Op(s) | Description |
---|---|---|
scalar | + - ~ | Returns the result of the scalar unary operations. |
vector | Performs per component unary operations, returning a new vector with each element holding the corresponding result. Operand sizes must match. vec3f a = 2;
vec3f b = -a;
vec3f a = 2;
vec3f b;
for (int i = 0; i < 3; ++i) b[i] = -a[i];
~ operator is only valid on integer vector types; vec2i , vec3i and vec4i . | |
matrix | + - | Performs per component unary operations, returning a new matrix with each element holding the corresponding result. Operand sizes must match. vec3f a = 2;
vec3f b = -a;
vec3f a = 2;
vec3f b;
for (int i = 0; i < 3; ++i) b[i] = -a[i];
|
Operator Name | Operator Syntax | Returns |
---|---|---|
Logical NOT | ! `a` | Returns true if the operand is false. Otherwise, returns false. |
Operand Type | Binary Op(s) | Description |
---|---|---|
scalar | ! | Returns the result of the scalar logical operation. The scalar operand is converted to a bool if it is not already. |
vector | Performs per component unary operations, returning a new vector with each element holding the corresponding result. Operand sizes must match. vec3i a = 2;
vec3i b = !a;
vec3i a = 2;
vec3i b;
for (int i = 0; i < 3; ++i) b[i] = !a[i];
! operator is only valid on integer vector types; vec2i , vec3i and vec4i . |
Operator Name | Operator Syntax | Returns |
---|---|---|
Pre-increment | ++ `a` | Returns a reference to the incremented result. |
Post-increment | `a``++` | Returns a copy of the incremented result. |
Pre-decrement | -- `a` | Returns a reference to the decremented result. |
Post-decrement | `a``--` | Returns a copy of the decremented result. |
Operand Type | Binary Op(s) | Description |
---|---|---|
scalar | ++(pre) (post)++ --(pre) (post)-- | Returns the result (reference or copy) of the scalar increment or decrement operation. Note: boolean incrementation and decrementation is not supported. Only int32 , int64 , float and double types are valid. |
Operator Name | Operator Syntax | Returns |
---|---|---|
Dot Component Access | vector . `component` | Reference to component `component` of `vector` |
Container Component Access | container [ `exp` ] | Reference to component at index `exp` of `container` |
Matrix Component Access | matrix [ `exp1`, `exp2` ] | Reference to component in row exp1 , column exp2 . Also equal to returning a reference to component at index: [exp1 * dimension + exp2] of `matrix` where `dimension` is the the size of the matrix |
[]
operator is valid for both types. However the . operator is only valid on vector types, and the [,]
operator is only valid on matrix types. As return values for these operators are references, any modifications through assignments will update the stored value in the container. `vector` . `component` |
[]
operator with the corresponding integer index.
Component | Access Index | Result |
---|---|---|
`A.x` | 0 | ![]() |
`A.r` | 0 | ![]() |
`A.y` | 1 | ![]() |
`A.g` | 1 | ![]() |
`A.z` | 2 | ![]() |
`A.b` | 2 | ![]() |
[]
operator is valid for both vectors and matrices. It has the form: `container` [exp ] |
[,]
operator is only valid for matrices. It has the form: `matrix` [exp1 , exp2 ] |
|
| |||||
Access [a] | Access [a,b] | Result | Access [a] | Access [a,b] | Result | |
---|---|---|---|---|---|---|
A[0] | A[0,0] | ![]() | A[0] | A[0,0] | ![]() | |
A[1] | A[0,1] | ![]() | A[1] | A[0,1] | ![]() | |
A[2] | A[0,2] | ![]() | A[2] | A[0,2] | ![]() | |
A[3] | A[1,0] | ![]() | A[3] | A[0,3] | ![]() | |
A[4] | A[1,1] | ![]() | A[4] | A[1,0] | ![]() | |
A[5] | A[1,2] | ![]() | A[5] | A[1,1] | ![]() | |
A[6] | A[2,0] | ![]() | A[6] | A[1,2] | ![]() | |
A[7] | A[2,1] | ![]() | A[7] | A[1,3] | ![]() | |
A[8] | A[2,2] | ![]() | A[8] | A[2,0] | ![]() | |
A[9] | A[2,1] | ![]() | ||||
A[10] | A[2,2] | ![]() | ||||
A[11] | A[2,3] | ![]() | ||||
A[12] | A[3,0] | ![]() | ||||
A[13] | A[3,1] | ![]() | ||||
A[14] | A[3,2] | ![]() | ||||
A[15] | A[3,3] | ![]() |
Operator Name | Operator Syntax | Returns |
---|---|---|
Call / Explicit Cast | a (...) | Returns the result of a function call or inbuilt explicit cast |
Comma | a , b | Returns the value of `b` after chained evaluation |
Ternary Conditional | a ? b : c | `b` if `a` is true, `c` otherwise. |
Vector/Matrix Initializer | { a, b ... } | Returns a temporary vector or matrix |
func(a, b, c, ...) |
a , b |
a ? b : c |
c
are expressions of the same or implicit-castable types. `b` is evaluated and returned if the condition is true, `c` is evaluated and returned if the condition is false. Only the expression out of `b` and `c` that is returned will be evaluated. Expressions with no return value (a.k.a `void`) are supported as long as `b` and `c` are both of this type. a
?
:
c
(or ?:
). Here, `a` is evaluated once, and if when converted to bool is true, `a` is returned, otherwise `c` is evaluated and returned. In this case, `a` and c
must be the same or implicit-castable types, and both implicit-castable to bool.{ a, b ... } |
a[0]
is copied into the initializer operator. Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | () | Parenthesis | Left-to-right |
2 | a++ a-- | Suffix/postfix Increment / Decrement | |
type() | Functional cast | ||
a() | Function call | ||
a[] . | Container Access | ||
3 | ++a --a | Prefix Increment / Decrement | Right-to-left |
+a -a | Unary plus and minus | ||
! ~ | Logical NOT and Logical NOT | ||
4 | a*b a/b ab | Multiplication, division, and remainder | Left-to-right |
5 | a+b a−b | Addition and subtraction | |
6 | << >> | Bitwise left shift and right shift | |
7 | < <= | For Comparisons / Relational operators < and ≤ respectively | |
> >= | For Comparisons / Relational operators > and ≥ respectively | ||
8 | == != | For Comparisons / Relational operators = and ≠ respectively | |
9 | & | Arithmetic AND | |
10 | ^ | Arithmetic XOR (exclusive or) | |
11 | | | Arithmetic OR (inclusive or) | |
12 | && | Logical AND | |
13 | || | Logical OR | |
14 | a?b:c | Ternary operator | Right-to-left |
= | Direct assignment | ||
+= -= | Compound assignment by sum and difference | ||
*= /= %= | Compound assignment by product, quotient, and remainder | ||
<<= >>= | Compound assignment by bitwise left shift and right shift | ||
&= ^= |= | Compound assignment by bitwise AND, XOR, and OR | ||
15 | , | Comma | Left-to-right |
a = b = c
is parsed as a = (b = c)
, and not as (a = b) = c
because of right-to-left associativity of assignment, but a + b − c
is parsed (a + b) − c
and not a + (b − c)
because of left-to-right associativity of addition and subtraction. Note that this is based off the C++ operator precedence.Type | Literal Tokens |
---|---|
bool | Tokens `true` and `false` |
int32 | No suffix, automatically infered from integral literals |
int64 | The letter `l` e.g. int64 a = 10l;
|
float | The letter `f` e.g. float a = 0.0f;
|
double | No suffix, automatically infered from floating point literals. |
string | Character strings wrapped in double quotes " " |