Houdini VEX Types
| Type | Syntax |
|---|---|
| float | f@name |
| int | i@name |
| string | s@name |
| vector | v@name |
| vector2 | u@name |
| vector4 | p@name |
| matrix2 | 2@name |
| matrix3 | 3@name |
| matrix (4x4) | 4@name |
| integer array | i[]@name |
| vector array | v[]@name |
| string array | s[]@name |
Declaring just a plain vector:
vector scale = {1,2,3};
A vector array:
vector stuff[] = { {1,2,3}, {4,5,6} };
Declaring the above as an attribute :
v@scale = {1,2,3};
v[]@stuff = { {1,2,3}, {4,5,6} };
VEX implicitly casts to float
@pscale = 1; // No type declaration, 1.0
@pscale = {1.0, 1.0, 1.0}; // This is still just 1.0 since we didn't declare its type
To access one element of a vector:
vector fuckyou = {1, 2, 3};
f@suckadick = fuckyou.y;
You can use x y z w or r g b a or x y etc. depending on the vector’s dimensions. Houdini just assumes 3-element vectors are xyz or rgb – it’s all the same.
GOTCHA
You cannot use variables in literal declarations (due to casting), instead use set:
v@someshit = {@P.x, @P.y, @P.z}; // this is invalid v@someshit = set(@P.x, @P.y, @P.z); // using set