// use these command line parameters to set the width/height // (right click on them and select "open include file/insert command line") // +w640 +h320 +AM2 +A0.2 // in any case, use a width that's twice the height. // good preview settings: // +w320 +h160 +sp4 // we gotta get a background going eventually // this is going to need more sophisticated lighting too // I figure we can add black areas at the top and bottom to make a good desktop image out of it when we're done. #include "colors.inc" #include "woods.inc" #include "functions.inc" global_settings { max_trace_level 10 } camera { location <0,0,-6> up y right 2*x look_at 0 } light_source { <-5,3,-6>*100 rgb 1.3 } // bowling ball //Layered Texture #declare Ball_Tex = texture { pigment { bozo color_map { [0 rgb <.8,.3,1>][1 rgb <.3,1,.8>] } warp { turbulence 1 lambda 4 omega .4 octaves 3 } scale .3 } } texture { pigment { crackle color_map { [.5 rgbt <.8,.3,.28,1>] [.7 rgbt <.8,.3,.28,0>] } scale .06 } } #declare ball_hole = union { cylinder { .5*1.7*y, y, .075} sphere {.5*1.7*y,.075 scale <1,.5,1>} difference { #declare roundedness = .008; #declare roundedness_error = .0038; cylinder { (1-roundedness-roundedness_error)*y,y,0.075+roundedness } torus { .075+roundedness,roundedness translate (1-roundedness-roundedness_error)*y } } rotate -45*x //pigment {rgb 1} } #declare ball = difference { sphere {0,1} object {ball_hole rotate <9,12.5,0>} object {ball_hole rotate <9,-12.5,0>} object {ball_hole rotate <-9,0,0>} texture { Ball_Tex finish { diffuse 1 ambient 0 //brilliance 2 specular .4 roughness .01 //metallic } normal { dents .15 scale .05 } } hollow rotate x*-45 } // bowling pins // images.google.com + graph paper = helpful #declare numpinpoints = 12; #declare pinpoints = array[numpinpoints] {<0,-2>,<1,0>,<1.7,2>,<1.8,4>,<1.3,6>,<1,7>,<.75,8.3>,<.8,9.95>,<1,11.5>,<.8,12.5>,<.1,13>,<0,13>}; #declare pin = sor { numpinpoints, #declare pointnum=0; #while (pointnum < numpinpoints) pinpoints[pointnum] #if (pointnum < numpinpoints-1) , #end #declare pointnum = pointnum + 1; #end sturm scale 1/13 // goes from <0,0,0> to <0,1,0> // needs more interesting texture pigment { rgb 1 } } // balls + pins #declare pin_radius = 1.4; // radius of pin's orbit #declare base_torus_func = function(a,b) { select(a-.1,0,(a-.1)/.9)*pow(b,1-a) } #macro ball_and_pin(pin_streak_color, pinaroundamnt,pinrot,sphererot) /* arguments: pin_streak_color is the color of the orbit of the pin pinaroundamnt is a number from 0 to 1 that specifies how far around the pin should be in its orbit pinrot and sphererot are vectors that the pin's orbit and the bowling ball will be rotated by */ union { torus { pin_radius, pin_radius*0.02 pigment {rgbt 1} interior { media { emission 30*pin_streak_color//* density { function { base_torus_func( (f_th(z,y,-x)+pi)/(2*pi), // amount around the orbit (1-sqrt(y*y+pow(sqrt(x*x+z*z)-pin_radius,2))/(pin_radius*0.02)) // distance from nearest point of orbit circle (torus function) ) } } } } hollow on rotate 90*x rotate -3*z } object { pin translate -.5*y scale pin_radius*.5 translate } rotate z*pinaroundamnt*360 rotate pinrot } object { ball rotate sphererot } #end // place the "planets" #declare rnd = seed(6); #declare numballs = 150; #declare minballpos = <-50,-25,0>; #declare maxballpos = <50,25,50>; #declare ballrad = pin_radius*1.2; #declare ballposs = array[numballs]; //box {minballpos,maxballpos pigment {rgbt .5}} #declare ballnum = 0; #while (ballnum < numballs) union { ball_and_pin(, 0,*360, *360) // collision detection! don't let planets touch each other #declare posisok = false; #while (!posisok) #declare posisok = true; #declare pos = *(maxballpos-minballpos)+minballpos; // test against vision cone of the big planet #if (vlength(pos-pos*z) < (pos.z+6)*.45) #declare posisok = false; #else // test against other balls #declare testballnum = 0; #while (testballnum < ballnum) #if (vlength(pos-ballposs[testballnum]) < ballrad) #declare posisok = false; #declare testballnum = ballnum; // break #end #declare testballnum = testballnum + 1; #end #end #end #declare ballposs[ballnum] = pos; // fake illusion of distance for farther spheres by shrinking them scale 1-pow(pos.z/maxballpos.z,1.7)*.9 translate pos } #declare ballnum = ballnum + 1; #end // the big'un union { ball_and_pin(1/140*<.3,.7,1>, .8,<75,0,20>,<0,-10,5>) scale 100 translate <0,0,300> }