|
|
"Bill Pragnell" <bil### [at] hotmailcom> wrote:
> Hi everyone
Code for the curious:
#declare BrightFn = function { pigment {
wood color_map { [0 rgb 0] [1 rgb 1] } rotate x*90 scale 6
} }
#declare N = 250;
#declare Sd = seed(0);
#declare D = 10;
#declare Points = array[N];
#declare Cones = array[N];
#for (I, 0, N-1)
#declare Points[I] = <rand(Sd)*20-10, 0, rand(Sd)*20-10>;
#declare Cones[I] = cone { Points[I]-y*D, 10, Points[I], 0 }
#end
#declare OtherCones = array[N];
#for (I, 0, N-1)
#declare OtherCones[I] = union {
#for (J, 0, N-1)
#if (J != I) object { Cones[J] } #end
#end
plane { y, -D } // to catch misses
}
#end
#declare NS = 250;
#declare DA = 360/NS;
#declare MeshCells = array[N];
#for (I, 0, N-1)
#declare MeshCells[I] = mesh {
#for (IA, 0, NS-1)
#declare V1 = vrotate(<1,-1,0>, y*DA*IA);
#declare V2 = vrotate(<1,-1,0>, y*DA*(IA+1));
#declare P1 = trace(OtherCones[I], Points[I], V1);
#declare P2 = trace(OtherCones[I], Points[I], V2);
triangle { Points[I], P1, P2 }
triangle { P1, <P1.x, -D, P1.z>, <P2.x, -D, P2.z> }
triangle { P1, <P2.x, -D, P2.z>, P2 }
triangle { Points[I]-y*D, <P2.x, -D, P2.z>, <P1.x, -D, P1.z> }
#end
inside_vector y
}
#end
#declare Fns = array[N];
#for (I, 0, N-1)
#declare Fns[I] = function {
pigment {
object {
MeshCells[I]
rgb 0, rgb BrightFn(Points[I].x, -D+1e-4, Points[I].z).x
}
}
}
#end
#declare WholeFn = function {
max(
#for (I, 0, N-1)
Fns[I](x, -D+1e-4, z).x
#if (I < N-1) , #end
#end
)
}
box {
<-10, -0.01, -10>, <10, 0, 10>
pigment { function { WholeFn(x, y, z) } color_map { [0 rgb 0] [1 rgb 1] } }
finish { diffuse 0.8 ambient 0 }
}
Post a reply to this message
|
|