Difference between revisions of "VexCheatSheet"

From cgwiki
(Created page with "A glossary of terms and stuff, more complete explainations are over on the HoudiniVex page. === Vex type prefixes === The default is float, so you rarely need the f@ pr...")
 
Line 31: Line 31:
  
 
The ones I use a lot, more can often be found by opening a vop for various contexts and looking at the default global ins and outs, pulling apart sidefx nodes.
 
The ones I use a lot, more can often be found by opening a vop for various contexts and looking at the default global ins and outs, pulling apart sidefx nodes.
 +
 +
I've added prefix types here too. You don't need them, but its good practice, both to remind you what these attrib types are, and to avoid accidentally setting normal as a float or a transform as a quaternion. :)
  
 
<syntaxhighlight lang='javascript'>
 
<syntaxhighlight lang='javascript'>
@Frame; // current frame
+
i@Frame; // current frame
@Time; // current time in seconds
+
f@Time; // current time in seconds
@ptnum; // current point number
+
i@ptnum; // current point number
@vtxnum; // current vertex number
+
i@vtxnum; // current vertex number
@primnum; // current prim number
+
i@primnum; // current prim number
@numpt; // total number of points. both @ptnum and @numpt are integers, so if dividing, remember to cast @ptnum to a float
+
i@elemnum; // handy morphing attribute; if you're in a point wrangle its ptnum, if in a vertex wrangle its @vtxnum, primwrangle @primnum.
@numvtx; // total number of verticies
+
i@numpt; // total number of points. both @ptnum and @numpt are integers, so if dividing, remember to cast @ptnum to a float
@numprim; // total number of prims
+
i@numvtx; // total number of verticies
 +
i@numprim; // total number of prims
 +
 
  
@N; // the normal. If this hasn't been set, vex will calculate it for you just by calling it without initialised values
+
v@N; // the normal. If this hasn't been set, vex will calculate it for you just by calling it without initialised values
@up; // a vector to control the spin around the normal when using instancing/copytopoints/etc
+
v@up; // a vector to control the spin around the normal when using instancing/copytopoints/etc
@orient; // vector4 used as explicit rotation for instances
+
p@orient; // vector4 used as explicit rotation for instances
@transform; // matrix3 used to control rotation and scale for instances
+
3@transform; // matrix3 used to control rotation and scale for instances
@localtransform; // matrix (4x4) used for kinefx joints
+
4@localtransform; // matrix (4x4) used for kinefx joints
  
 +
@P; // current elements position. can be set for points, can be read for vertices and prims. Prims will guess the midpoint, not always reliable!
 
@Cd; // diffuse colour
 
@Cd; // diffuse colour
 
</syntaxhighlight >
 
</syntaxhighlight >

Revision as of 16:42, 8 July 2022

A glossary of terms and stuff, more complete explainations are over on the HoudiniVex page.

Vex type prefixes

The default is float, so you rarely need the f@ prefix.

// floats and integers
f@myfloat = 12.234; // float
i@myint = 5; // integer

// vectors
u@myvector2 = {0.6, 0.5}; // vector2 (2 floats)
v@myvector = {1,2,3}; // vector (3 floats)
p@myquat = {0,0,0,1}; // quaternion / vector4 / 4 floats

// matricies
2@mymatrix2 = {1,2,3,4}; // matrix2 (2x2 floats)
3@mymatrix3 = {1,2,3,4,5,6,7,8,9}; // matrix3 (3x3 floats)
4@mymatrix4 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // matrix (4x4 floats)

// strings and dictionaries
s@mystring = 'a string'; // string
d@mydict = {}; // dict, can only instantiate as empty type
d@mydict['key'] = 'value'; // can set values once instantiated

The sidefx documentation is here: https://www.sidefx.com/docs/houdini/vex/snippets.html#attributes

Common attribute names

The ones I use a lot, more can often be found by opening a vop for various contexts and looking at the default global ins and outs, pulling apart sidefx nodes.

I've added prefix types here too. You don't need them, but its good practice, both to remind you what these attrib types are, and to avoid accidentally setting normal as a float or a transform as a quaternion. :)

i@Frame; // current frame
f@Time; // current time in seconds
i@ptnum; // current point number
i@vtxnum; // current vertex number
i@primnum; // current prim number
i@elemnum; // handy morphing attribute; if you're in a point wrangle its ptnum, if in a vertex wrangle its @vtxnum, primwrangle @primnum.
i@numpt; // total number of points. both @ptnum and @numpt are integers, so if dividing, remember to cast @ptnum to a float
i@numvtx; // total number of verticies
i@numprim; // total number of prims


v@N; // the normal. If this hasn't been set, vex will calculate it for you just by calling it without initialised values
v@up; // a vector to control the spin around the normal when using instancing/copytopoints/etc
p@orient; // vector4 used as explicit rotation for instances
3@transform; // matrix3 used to control rotation and scale for instances
4@localtransform; // matrix (4x4) used for kinefx joints

@P; // current elements position. can be set for points, can be read for vertices and prims. Prims will guess the midpoint, not always reliable!
@Cd; // diffuse colour