|
|
I've tried everything that's been suggested, so far, but nothing - aside from
decreasing the number of control points - had any effect. And decreasing the
number of control points messed up my uv_mapping.
I'm posting the code for the bulb, if anyone can help me, I'd be grateful.
#macro ChristmasBulb(bulbMaterial, capMaterial, isMapped, Transform)
// These parameters control the size of the bulb.
// The cap is not linked to these parameters
#local r = 1.25;
#local r2 = 0.5;
#local T = 0.03125;
/* !--- DO NOT CHANGE THESE EQUATIONS. ---! */
#local h = sqrt(pow(r,2) - pow(r2,2));
#local s = degrees(atan(h/r2));
/*
intersection {
box { -r, <r, (r*sin(radians(s)))+(r2*sin(radians(s))), r> }
difference {
union {
sphere { 0.0, r }
cylinder { 0.0, ((r*sin(radians(s)))+(r2*sin(radians(s))))*y r2 }
}
torus { (r2+(r2*cos(radians(s)))), r2 translate
((r*sin(radians(s)))+(r2*sin(radians(s))))*y }
difference {
merge {
sphere { 0.0, r-T }
cylinder { 0.0, ((r*sin(radians(s)))+(r2*sin(radians(s))))*y r2 }
}
torus { (((r-T)*cos(radians(s)))+((r2+T)*cos(radians(s)))), r2+T
translate ((r*sin(radians(s)))+(r2*sin(radians(s))))*y }
}
cylinder { 0.0, ((r*sin(radians(s)))+(r2*sin(radians(s)))+0.03125)*y
(((r-T)*cos(radians(s)))+((r2+T)*cos(radians(s))))-(r2+T) }
#if(isMapped)
uv_mapping
#end
}
hollow on
material { bulbMaterial }
transform { Transform }
}
*/
// Bulb object.
// Constructed out of a single lathe-object.
// Uses loops to determine the positions of the control points.
/* Note: There is a descernable visual flaw, when bulb is viewed straight-on: It
manifests
as a dark line around the equator of the bulb. At present, I do not know if this
is a design flaw,
or a program bug, but I have checked the coordinates of the control points, as y
approaches zero,
for both inner and outer surfaces, and I have not found any errors. - A.D.B. */
merge {
lathe {
linear_spline
3338,
#local a = 0;
#while(a < s+90)
#local P = vrotate(-r*y, a*z);
<P.x, P.y>
#local a = a + (s+90)/1500;
#end
#local b = s ;
#while(b > 0)
#local P = vrotate(-r2*x, b*z);
<(r2+(r2*cos(radians(s))))+P.x,
(r*sin(radians(s)))+(r2*sin(radians(s)))+P.y>
#local b = b - s/169;
#end
#local c = 0;
#while(c < s)
#local P = vrotate(-(r2+T)*x, c*z);
<(((r-T)*cos(radians(s)))+((r2+T)*cos(radians(s))))+P.x,
((r-T)*sin(radians(s)))+((r2+T)*sin(radians(s)))+P.y>
#local c = c + s/169;
#end
#local d = s+90;
#while(d > 0)
#local P = vrotate(-(r-T)*y, d*z);
<P.x, P.y>
#local d = d - (s+90)/1500;
#end
#if(isMapped)
uv_mapping
#end
}
bounded_by { box { -(r+0.015625),
<(r+0.015625), ((r*sin(radians(s)))+(r2*sin(radians(s))))+0.3125,
(r+0.015625)> } }
hollow on
material { bulbMaterial }
transform { Transform }
}
// A plain, silver Bulb cap. Not parameterized.
difference {
union {
cylinder { -0.15625*y, 0.0 0.25 }
cylinder { -0.15625*y, 0.03125*y 0.21875 }
torus { 0.21875, 0.03125 }
torus { 0.21875, 0.03125 translate -0.15625*y }
torus { 0.125, 0.0078125 rotate 90.0*x translate 0.109375*y }
}
cylinder { -0.21875*y, 0.0 0.21875 }
material { capMaterial }
photons { target reflection on refraction off }
transform {
translate ((r*sin(radians(s)))+(r2*sin(radians(s))))*y
Transform
}
}
#debug concat("Max Height: " str((r*sin(radians(s)))+(r2*sin(radians(s))), 0, 6)
"\n")
#end
Cheers,
A.D.B.
Post a reply to this message
|
|