|
![](/i/fill.gif) |
"Thomas de Groot" <t.d### [at] inter nlDOTnet> wrote:
> Seems an interesting method. If you have time to port
> that out to the community, I (at least) would be very grateful. I can
> imagine a lot of applications.
Here you go. It should be quite self-explanatory. If you don't want a smooth
finish then use triangle instead of smooth_triangle.
// begin code
#macro ballpoint(vangle, rangle, rad)
#local yp = rad*cos(vangle);
#local locrad = rad*sin(vangle);
#local xp = locrad*sin(rangle);
#local zp = locrad*cos(rangle);
(<xp, yp, zp>)
#end
#macro meshball(obj, res)
mesh {
#local vang = 0;
#local ang = 0;
#local dvang = pi/res;
#local dang = 2*pi/res;
#local n1 = <0,0,0>;
#local n2 = <0,0,0>;
#local n3 = <0,0,0>;
#local n4 = <0,0,0>;
#while (vang < pi)
#while (ang < 2*pi)
#local v1 = trace(obj, <0,0,0>, ballpoint(vang, ang, 1), n1);
#local v2 = trace(obj, <0,0,0>, ballpoint(vang+dvang, ang, 1), n2);
#local v3 = trace(obj, <0,0,0>, ballpoint(vang, ang+dang, 1), n3);
#local v4 = trace(obj, <0,0,0>, ballpoint(vang+dvang, ang+dang, 1), n4);
smooth_triangle { v1, n1, v2, n2, v3, n3 }
smooth_triangle { v2, n2, v3, n3, v4, n4 }
#local ang = ang + dang;
#end
#local ang = 0;
#local vang = vang + dvang;
#end }
#end
// end code
Just call meshball(obj, res) where obj is your pre-declared object (centred on
the origin) and res is the triangle resolution (it's pretty fast with 100-200
and looks ok).
Bill
Post a reply to this message
|
![](/i/fill.gif) |