Orienting points and lines of a 3D grid

calendar_today

13.01.2023

label

Modeling

mouse

Houdini 19.5

1 Description

Orienting points of three-dimensional grids for copying doors and walls to knots as well as hallways and elevators to pipes.

2 Discussion

Group expression nodes are used to randomly remove line segments of the grid:

rand(@elemnum, chi('seed')) < chf('chance')

Left-over elements are filtered out by counting the specific connectivity class number:

i@num = findattribvalcount(0, 'prim', 'class', i@class);

Only primitives with the maximum count are kept:

@num==`detail(0, 'num_max', 0)`

Line segments are converted to points oriented by the bounding information of the lines:

float b[] = primintrinsic(0, 'bounds', i@primnum);
vector dir = set(b[0]-b[1], b[2]-b[3], b[4]-b[5]);
vector nml = normalize(abs(dir));

int pt = addpoint(0, v@P);
setpointattrib(0, 'N', pt, nml, 'set');
setattribtypeinfo(0, 'point', 'N', 'normal');

removeprim(0, i@primnum, 1);

The resulting points are named "elevator" or "hallway" by their vertical or horizontal orientation:

int cond = v@N.y > 0.1;

string name = "none";
if(cond == 1) name = "elevator";
else{ name = "hallway"; }

s@name = name;

An octahedron is copied to each knot. Its points are named "door" or "wall" depending on their immediate proximity towards the grid lines:

int cond = xyzdist(1, v@P) < 1e-2;

string name = "none";
if(cond == 1) name = "door";
else{ name = "wall"; }

s@name = name;

At last a copy-to-points node assigns objects named "elevator", "hallway", "door" or "wall" to their respective target points.

download

Downloads