#include "colors.inc" // This macro makes individual crystals... // Each pair of opposite sides is equidistant from a point c; their // distance from c is a random value within a certain range; point c // is a random point within a certain distance from the center // // /-------\ MinW = minimum radius edge to c // / \ MaxW = maximum radius edge to c // / \ MaxI = maximum offset of c from center // / .c \ MinH = minimum height to peak // \ | / MaxH = maximum height to peak // \ |r / MaxO = maximum offset of peak from center // \ | / MinA = minimum angle of taper // \-------/ MaxA = maximum angle of taper // RSeed = random number seed // #macro crystal(MinW,MaxW,MaxI,MinH,MaxH,MaxO,MinA,MaxA,RSeed) #local Rnd = seed(RSeed); #local ROff = rand(Rnd)*60; intersection { plane { -y,0 } #local ctr = 0; #while (ctr < 3) #local P = vrotate(,<0,rand(Rnd)*360,0>); #local W = MinW + (MaxW - MinW) * rand(Rnd); plane { x,W rotate (ctr*60+ROff)*y translate P } plane { -x,W rotate (ctr*60+ROff)*y translate P } #local P = vrotate(,<0,rand(Rnd)*360,0>); #local A = MinA + (MaxA - MinA) * rand(Rnd); plane { y,0 rotate translate P } plane { y,0 rotate <-A,ctr*60+ROff,0> translate P } #local ctr = ctr + 1; #end } #end // This macro makes clusters... // MinC = minimum number of crystals // MaxC = maximum number of crystals // MaxR = maximum number of degrees from vertical // the macro redistributes random rotations // to evenly space the crystals // CData[0] = crystal.MinW // CData[1] = crystal.MaxW // CData[2] = crystal.MaxI // CData[3] = minimum for crystal.MinH // CData[4] = maximum for crystal.MinH // CData[5] = maximum for crystal.MaxH-crystal.MinH // CData[6] = crystal.MaxO // CData[7] = crystal.MinA // CData[8] = crystal.MaxA // RSeed = random number seed #macro cluster(MinC,MaxC,MaxR,CData,RSeed) #local Rnd = seed(RSeed); #local MaxR = MaxR * ((MaxR/90) / cos(3*pi/2+pi/2*(MaxR/90))); #local NumC = MinC + (MaxC - MinC) * rand(Rnd); merge { #local ctr = 0; #while (ctr < NumC) #local H = CData[3] + (CData[4] - CData[3])*rand(Rnd); object { crystal( CData[0], CData[1], CData[2], H, H + CData[5] * rand(Rnd), CData[6], CData[7], CData[8], rand(Rnd)*65535 ) rotate <90*cos(3*pi/2+(MaxR*rand(Rnd)/90)*pi/2),360*rand(Rnd),0> } #local ctr = ctr + 1; #end bounded_by { sphere { 0,sqrt(pow((CData[1]+CData[2])*(2*sqrt(3)/3),2)+pow(CData[4]+CData[5],2)) } } } #end global_settings { max_trace_level 15 } camera { location <0,3,-2> look_at <0,1,0> } light_source { <150,200,-100> color Gray70 } light_source { <-100,100,-250> color Gray50 } plane { y,.0001 pigment { checker color SteelBlue color ForestGreen } } object { cluster(15,20,60,array[9]{.1,.2,.04,1,2,1,.15,45,65},55410) hollow pigment { color rgbt<.7,.7,.7,.8> } finish { specular 3 roughness .002 } interior { ior 1.5 media { scattering { 1, color rgb<1,1,1>*.4 extinction 1 } } } }