The main thing is that all your normals are pointing in the wrong direction.
They're all pointing away from the origin but they should all be pointing
away from the corresponding point on the spline.
The attached "spheresweepA.jpg" has cylinders added along your normals, and
"spheresweepB.jpg" shows where they should be pointing (I've reduced the
number of polygons and switched off reflection to make the normal cylinders
clearer).
To fix this, remove the "p0+" and "p1+" bits from the definitions of the
normal vectors, i.e.
cos(m/numrotes*2*pi)*drx1 +sin(m/numrotes*2*pi)*dry1,
cos((m+1)/numrotes*2*pi)*drx1+sin((m+1)/numrotes*2*pi)*dry1,
cos((m+1)/numrotes*2*pi)*drx2+sin((m+1)/numrotes*2*pi)*dry2,
cos(m/numrotes*2*pi)*drx1 +sin(m/numrotes*2*pi)*dry1,
cos((m+0)/numrotes*2*pi)*drx2+sin((m+0)/numrotes*2*pi)*dry2,
cos((m+1)/numrotes*2*pi)*drx2+sin((m+1)/numrotes*2*pi)*dry2
This nearly fixes things, but there's also a typo in the lines that say
#declare drx2=arr1*vnormalize(vcross(vrotate(dr1,40),dr2));
They should say "vrotate(dr2,40)" not dr1.
You recalculate the position and normal of each point 6 times, and this typo
means that 3 of the 6 recalculations are slightly misplaced.
Post a reply to this message
Attachments:
Download 'spheresweepA.jpg' (74 KB)
Download 'spheresweepB.jpg' (77 KB)
Download 'spheresweep.jpg' (65 KB)
Preview of image 'spheresweepA.jpg'
Preview of image 'spheresweepB.jpg'
Preview of image 'spheresweep.jpg'
|