XaiJu
entagma
entagma

patreon


VEX 101 - Functions

Functions are the commands we call in VEX to tell Houdini to do stuff: Create a point, find points nearby, generate random numbers etc.

We go over the general structure of a function call, how to find functions and how to read Houdini's function reference. The function reference might be one of the main tools that we'll be using when designing VEX code. It is ike a dictionary that translates VEX into human readable text. It is kind of neat but takes a bit of getting used to.

After this section it is time we start building our first real world setups.

VEX 101 - Functions

Comments

Hi Wirginia, what you just discovered is one of those reasons inlining can be troublesome sometimes. Here VEX tries to guess the right data type by looking at the constants in your formula. In essence VEX doesn't know which data type to return from the random function an settles on returning a single float, because all the other values in your formalu are floats. The resulting float number then gets cast to all three components of N. There are several ways to avoid this: Explicitely tell houdini to expect a vector by using the vector() keyword: @N = (vector(rand(@ptnum)) - 0.5)*2; Use only vector constants in your formula: v@N = ((rand(@ptnum)) - {0.5, 0.5, 0.5}) * {2, 2, 2}; Cheers, Mo

Entagma

I've been playing a bit with rand function, specifically for setting up random normals (vectors) and I've found this rather strange issue: When I say v@gorbert = rand(@ptnum); @N = (@gorbert - 0.5)*2; it works perfectly fine - I get bunch of random normals on my grid! But if I try to collapse that together to: @N = ((rand(@ptnum)) - 0.5)*2; My normals Nx=Ny=Nz which is not what I want most of the time. Looks like it should be the same but vex works out some casting tricks differently depending what you have in line with the function?

Wirginia Romanowska

thanks , this is what I always was looking for!

Mick Graas

Such a helpful series, really appreciate you taking it back to the bare bones ! Nice 1 :)

Sam


More Creators