// Packing test scene // Hohum 7/4/04 // Variable or fixed size circles #declare variation=off; // Number of poinbts to try for #declare points=200; // size of bounding box #declare boxx=8; #declare boxy=6; // Diameter of circle #declare pointsize=.5; // Number of bails while trying to place a single point before totally bailing out. #declare bailout=1000;//(boxx*boxy)/(pointsize*pointsize); #declare xy=array[points][3] #declare bails=0; #declare tries=0; #declare checks=0; #declare R1 = seed(0); #declare c=0; // Place the first point non randomly due to bad coding ;) #declare xy[0][0]=0.5*boxx; #declare xy[0][1]=0.5*boxy; // You can change the amount of size variation by altering this bit. (rand(R1)+.5) #if (variation) #declare xy[0][2]=(rand(R1)+.5)*pointsize; #else declare xy[0][2]=pointsize; #end // Main loop #while(cboxx | px-ps/2<0 | py+ps/2>boxy | py-ps/2<0) #declare fail=1; #end // Clearance test. x^2 + y^2 = z^2 #if( (px-xy[test][0])*(px-xy[test][0])+(py-xy[test][1])*(py-xy[test][1]) < ((ps/2)+(xy[test][2]/2))*((ps/2)+(xy[test][2]/2)) ) #declare fail=1; #declare bails=bails+1; #end #declare checks=checks+1; #declare test=test+1; #end #if(fail=0) #declare xy[c][0]=px; #declare xy[c][1]=py; #declare xy[c][2]=ps; #declare c=c+1; #declare bails=0; #end #end // write the position information. // count number first, then boxx & boxy, then all the coordinates with their object sizes #declare co=0; #fopen MyFile "positions.txt" write #write(MyFile,c,",",boxx,",",boxy",\n") #while(co} } } global_settings{ #if(0) radiosity{ pretrace_start 16/image_width // start pretrace at this size pretrace_end 2/image_width // end pretrace at this size count 500 // higher -> higher quality (1..1600) [35] nearest_count 5 // higher -> higher quality (1..10) [5] error_bound .3//1.8 // higher -> smoother, less accurate [1.8] recursion_limit 1 // how much interreflections are calculated (1..5+) [3] low_error_factor .5 // reduce error_bound during last pretrace step gray_threshold 0.0 // increase for weakening colors (0..1) [0] minimum_reuse 0.001 // reuse of old radiosity samples [0.015] brightness 1 // brightness of radiosity effects (0..1) [1] max_sample 3 adc_bailout 0.01/20 normal off // take surface normals into account [off] } #end } camera { angle 60 location look_at } // create a regular point light source light_source { 0*x // light's position (translated below) color rgb <1,1,1> // light's color area_light , <0, 0, boxy>, 2, 2 translate <15, 40, 20>*boxx*boxy } // Create an infinite sphere around scene and allow any pigment on it sky_sphere { pigment { gradient <0,1,0> color_map { [0.00 rgb 0] [0.35 rgb 1] [0.65 rgb 1] [1.00 rgb 0] } scale 2 } // end of pigment } //end of skysphere ------------------------------------- plane { y, 0 pigment{rgb <1,1,1>} finish {ambient 0.0 diffuse 1} } #declare co=0; #while(co xy[co][2]/2 pigment{rgb } finish{ambient 0 diffuse 1 phong 1} scale <1,.4,1>} #declare co=co+1; #end #debug concat("Points asked ",str(points,1,0),"\nPoints got ",str(c,1,0),"\nTries ",str(tries,1,0),"\n")