Elyg
11/8/2017 - 10:18 PM

## Create curves around prims

Run Over: Primitives

Creates helix curves around primitives

``````#define PI 3.1415926535897932384

int numCurves = 3;

float time = 0;
int pts [] = primpoints(0, @primnum);

for(int i=0; i<numCurves; ++i)
{
foreach(int pt; pts)
{

vector N = point(0, "N", pt);
vector tangentu = point(0, "tangentu", pt);
vector tangentv = point(0, "tangentv", pt);
vector P = point(0, "P", pt);
float u = point(0, "u", pt);
float uold = u;
uold = chramp("ends", uold);

randRev = randRev == 0 ? 1 : randRev;
u = fit01(u, -PI, PI) * ch("revolutions");
vector pos = set(sin(u-time+fit01(rand(i),0,360)), cos(u-time+fit01(rand(i+414),-360,360)), 0) * fit01(chramp("scaleDistrib", rand(i+979)), 0.3, 1.2);// *fit01(rand(i+@ptnum+979), 0.8, 1.2);
matrix3 t = set(tangentu, N, tangentv);
matrix3 tm = ident();
rotate(tm, 90, set(0,1,0));
vector p = P + (pos *tm*t);
p = lerp(p, P, uold);

setpointattrib(0, "curveId", ptn, @primnum+i+1);
setpointattrib(0, "originalPrim", ptn, @primnum);

setpointattrib(0, "start", ptn, @primnum);
setpointattrib(0, "end", ptn, @primnum);
}
}

removeprim(0, @primnum, 1);

//rotate around another curve run over points
#define PI 3.1415926535897932384

int numCurves = 3;

float time = 0;
int pts [] = primpoints(0, @primnum);

for(int i=0; i<numCurves; ++i)
{
foreach(int pt; pts)
{

vector N = point(0, "N", pt);
vector tangentu = point(0, "tangentu", pt);
vector tangentv = point(0, "tangentv", pt);
vector P = point(0, "P", pt);
float u = point(0, "u", pt);
float uold = u;
uold = chramp("ends", uold);

randRev = randRev == 0 ? 1 : randRev;
u = fit01(u, -PI, PI) * ch("revolutions");
vector pos = set(sin(u-time+fit01(rand(i),0,360)), cos(u-time+fit01(rand(i+414),-360,360)), 0) * fit01(chramp("scaleDistrib", rand(i+979)), 0.3, 1.2);// *fit01(rand(i+@ptnum+979), 0.8, 1.2);
matrix3 t = set(tangentu, N, tangentv);
matrix3 tm = ident();
rotate(tm, 90, set(0,1,0));
vector p = P + (pos *tm*t);
p = lerp(p, P, uold);