Run Over: DETAIL Scale geometry based on id
#include <voptype.h>
#include <voplib.h>
//noise controls
vector freq = chv("Frequency"); // (1,1,1)
vector offset = chv("Offset"); // (0,0,0)
int turb = chi("Turbulence"); // 5
float amp = chf("Amplitude"); // 1
float rough = chf("Roughness"); // 0.5
float atten = chf("Attenuation"); // 1
string attributeName = chs("attribName");
int countVal = nuniqueval(0, "point", attributeName);
for(int k = 0; k<countVal; k++)
{
int attrib = uniqueval(0, "point", attributeName, k);
vector centroid = 0;
int count = findattribvalcount(0, "point", attributeName, attrib);
int points [];
for(int i =0; i<count; i++)
{
int ptnum = findattribval(0, "point", attributeName, attrib, i);
vector pos = point(0, "P", ptnum);
centroid += pos/(float)count;
push(points, ptnum);
}
foreach(int point; points)
{
vector pos = point(0, "P", point);
vector normal = point(0, "N", point);
int id = point(0, "id", point);
vector noise = anoise(pos*freq - offset, turb, rough, atten) * amp; // range (0, 1) *amp
vector randScale = fit01(rand(id),0.2,1);
vector randNoise = (pos*normal*noise);
pos-=centroid;
pos*=chf("scale");//*randScale;
pos+=randNoise;
pos+=centroid;
setpointattrib(0, "P", point, pos);
}
}