IF tube #
NIL
AND tube.frames #
NIL
THEN {
uRange1: REAL ← uRange0*(0.5+0.5*(tube.r1/tube.r0)); -- a compromise
duRange: REAL ← (uRange1-uRange0)/(tube.frames.length-1.0);
circle: PairSequence ← Contours.CirclePairs[tube.circleRes];
tapered: BOOL ← tube.r1 # tube.r0;
vFactor:
REAL ←
IF tapered
THEN (tube.r0-tube.r1)/Vector3d.Distance[tube.p0, tube.p1]
ELSE 1.0;
pNow, pPrev: Triple ← tube.p0;
odd: BOOL ← tube.circleRes MOD 2 = 1;
FOR i:
NAT
IN[iStart..NFrames[tube])
DO
uRange: REAL ← uRange0+i*duRange;
u: REAL ← 0.0;
du: REAL ← 0.5*uRange/tube.circleRes;
m: Matrix ← tube.frames[i].matrix;
mm: Matrix ← IF view # NIL THEN Matrix3d.Mul[m, view] ELSE m;
pPrev ← pNow;
pNow ← [m[3][0], m[3][1], m[3][2]];
IF i # 0 THEN v ← v+Vector3d.Distance[pNow, pPrev];
FOR j:
NAT
IN[0..tube.circleRes)
DO
p: Triple ← Matrix3d.TransformPair[circle[j], mm];
n: Triple ← Matrix3d.TransformVec[[circle[j].x, circle[j].y, 0.0], mm];
IF tapered
THEN {
vv: Triple ← Spline3d.Velocity[tube.coeffs, tube.frames[i].t];
len: REAL ← Vector3d.Length[n];
n ← Vector3d.Add[n, Vector3d.Mul[vv, len*vFactor/Vector3d.Length[vv]]];
};
n ← Vector3d.Normalize[n];
[] ← pointProc[pointId, p, n, u, v];
pointId ← pointId+1;
u ← IF j < tube.circleRes/2 OR odd THEN u+du ELSE u-du; -- u radial symmetry
ENDLOOP;
ENDLOOP;
IF tube.next #
NIL
AND tube.next.circleRes = tube.circleRes
AND tube.next.r0 = tube.r1
THEN OneSpline[tube.next, 1, uRange1, v] -- skip first frame
ELSE OneSpline[tube.next, 0, uRange1, v]; -- do first frame
FOR n:
NAT
IN [0..NBranches[tube])
DO
OneSpline[tube.branches[n], 0, uRangeStart, v]; -- use 1st frame of 1st branch tube
ENDLOOP;
};