Samstag, 15. November 2014

Houdini Expression Sheet

Oh no, not another expression sheet!

While I'm working with Houdini I found myself often scratching my head over some expressions. Why the hell can't I use this here? Why do i have to use it there and connect this to this for getting the information here? I am not a developer, okay? so i can't really tell why sometimes nodes show me the middle finger and say "Nope, i don't care!"...
Okay, while expressions and variables alone could be really hard to understand, it is even more complicated to realise when you can use the right expression at the right spot.

For this purpose i start my very own expression sheet. Just to get and keep it in my Head.
Maybe you found it useful. This will be updated from time to time.

Bounding Box

Local variable - $BB [X,Y,Z]
use it if you need: the normalised position of a point within the bounding box.

Expression - bbox(string node, float type)
possible float types:
[0,1,2,3,4,5,6,7,8] or
[D_XMIN, D_YMIN, D_ZMIN, D_XMAX, D_YMAX, D_ZMAX, D_XSIZE, D_YSIZE, D_ZSIZE]

examples: bbox("../nodename", 0) or bbox("../nodename", D_XMIN)
-------------------------------------------------------

CEntroid

Local variable - $CE [X,Y,Z]
use it if you need: the center of the geometry.

Expression - centroid(string node, float type)
possible float types:
[0,1,2] or [D_X, D_Y, D_Z]

examples: centroid("../nodename", 0) or centroid("../nodename", D_X)
------------------------------------------------------- 

Translate

Local variable - $T [X,Y,Z]
------------------------------------------------------- 

Velocity

Local variable - $V [X,Y,Z]
-------------------------------------------------------

Normal

Local variable - $N [X,Y,Z]
-------------------------------------------------------

SIZE

Local variable - $SIZE [X,Y,Z]
-------------------------------------------------------

Fit

fit(value, oldmin, oldmax, newmin, newmax)
fits values in a certain range to a new one. values outside this range will be clamped.
fit01(value, newmin, newmax)
fits values in the range from 0 and 1 to the new range. values outside this range will be clamped.
fit10(value, newmin, newmax)
fits values in the range from 1 and 0 to the new range.  values outside this range will be clamped.
fit11(value, newmin, newmax)
fits values in the range from -1 and 1 to the new range. values outside this range will be clamped.
-------------------------------------------------------

Point Expression

point(string node, point number, attribute name, float type)
possible float types: if attribute is a vector [0,1,2] else [0]

examples: point("../nodename", 0, "P", 0) - get X position of Point 0 of the geometry
-------------------------------------------------------

Primitive Expression

prim(string node, prim number, attribute name, float type)
possible float types: if attribute is a vector [0,1,2] else [0]

examples: prim("../nodename", 0, "P", 0) - get X position of Primitive 0 of the geometry
-------------------------------------------------------

Stamp Expression

stamp(string scope, attribute token, float type)
oh beautiful stamp, i love you!

examples: usually stamp refers to a copy sop, in other cases you will find yourself using it in a foreach sop.
in combination with copy sop: stamp("../copy1", token name, 0) you have to declare the token in the copy sop
in a foreach sop: stamp("..", FORVALUE, 0) you can change the tokenname in the foreach sop