Code in Houdini

Houdini expression and script snippets.

Template for point cloud lookup.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
float radius = chf("radius");
int maxpoints = chi("maxpoints");

int handle = pcopen(0, "P", v@P, radius, maxpoints);

int cloud_ptnum = -1;
float cloud_dist = 0.0;
vector cloud_P = {0.0, 0.0, 0.0};
vector cloud_foo = {0.0, 0.0, 0.0};

while (pciterate(handle)) 
{
    // Skip self
    pcimport(handle, "point.number", cloud_ptnum);
    if (cloud_ptnum == i@ptnum) continue;

    pcimport(handle, "point.distance", cloud_dist);
    pcimport(handle, "P", cloud_P);
    pcimport(handle, "foo", cloud_foo);
}

Create default node color.

1
2
3
4
5
import soptoolutils

node = soptoolutils.genericTool(kwargs, '$HDA_NAME')

node.setColor(hou.Color(.4392, .3804, 0.7843))

Grab input.

1
bbox(opinputpath(".", 0), D_YMAX)

VEX @attribute_name syntax for different datatypes.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
float
f@name

vector2 (2 floats)
u@name

vector (3 floats)
v@name

vector4 (4 floats)
p@name

int
i@name

matrix2 (2×2 floats)
2@name

matrix3 (3×3 floats)
3@name

matrix (4×4 floats)
4@name

string
s@name

Create orient attribute.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
matrix3 m = ident();
vector z_front;
vector y_up;
vector x_left;

z_front = normalize(v@tangent);           // set front
y_up = normalize(v@normal);               // set up
x_left = normalize(v@bitangent);          // set left

m = set(x_left, y_up, z_front);

p@orient = quaternion(m);