Growing a Mycelium

calendar_today

14.05.2022

label

Modeling, Organic

mouse

Houdini 19.0

1 Introduction

A simple growing algorithm which is randomly adding points at the rim of a point cloud and is more likely to do so nearby food.

2 Code discussion

This code refers to the mycelium_groth_simple.hip. A weighted average of the surrounding point positions pcfilter is subtracted from the current point position v@P - pos to create a normal potentially pointing away from the point cloud. Calculating the normal vectors magnituge f@magn works for isolating the boundary of the point cloud while measuring the distance dist towards food will further motivate growth.

float r = chf('radius');
int pts_max = chi('points');

int handle = pcopen(0, 'P', v@P, r, pts_max);
vector pos = pcfilter(handle, 'P');

float dist = xyzdist(1, v@P);

v@N = v@P - pos;
f@magn = length(v@N);
f@dist = dist;

Remapping and normalizing distance and magnitude attributes to direct growing behaviour. The search radius and number of search points in the first wrangle affect the growing behaviour, as well.

f@dist = pow(fit(f@dist, 0.0, 1.0, 1.0, 0.05), 9.1);
f@magn = fit(f@magn, 0.004, 0.006, 0.0, 1.0);

Comparing magnitude and distance with random point values before adding points nearby existing points.

vector val = nrandom('mersenne');

if(f@magn > val.x && f@dist > val.y){
    vector offset = v@P + normalize(v@N) * 0.005;
    offset.y = 0.0;
    int pt_add = addpoint(0, offset);
    addprim(0, 'polyline', i@ptnum, pt_add);
}
download

Downloads

smart_display

Videos

Growing a Mycelium with VEX – Houdini Tutorial