|
|
This macro allows attractors and/or repulsors to modify the positions of
points in space.
// Optional functions
#declare dfNum = 7;
#declare dfLoc = array[dfNum] // Position of deformation
#declare dfStr = array[dfNum] // Strength of deformation (positive if
attracting, negative if repelling)
#declare dfUni = array[dfNum] // Distance dependance, usually -2 (gravity)
#declare da = 0;
#while (da<5)
#declare dfLoc[da] = vrotate(x*9,y*da*72);
#declare dfStr[da] = 1;
#declare dfUni[da] = -2;
#declare da = da + 1;
#end
#declare dfLoc[5] = y*4;
#declare dfLoc[6] = -y*4;
#declare dfStr[5] = 3;
#declare dfStr[6] = -3;
#declare dfUni[5] = -2;
#declare dfUni[6] = -2;
#macro Deform1(trg,src,acc,uni)
#local frc = vnormalize(src-trg)*acc*pow(vlength(trg-src),uni);
frc
#end
#macro Deform(pos,tim,nstep)
#local _ans = pos;
#local _step = tim/nstep;
#local _dt = 0;
#while (_dt<tim)
#local _dn = 0;
#local _push = <0,0,0>;
#while (_dn<dfNum)
#local _push = _push +
Deform1(_ans,dfLoc[_dn],dfStr[_dn]*_step,dfUni[_dn]);
#local _dn = _dn + 1;
#end
#local _ans = _ans + _push;
#local _dt = _dt + _step;
#end
_ans
#end
I ran into some trouble when some of the points came too close to the
attractors and got flung too far in the other direction.
Post a reply to this message
|
|