// 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 // 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 } // Create an infinite sphere around scene and allow any pigment on it sky_sphere { pigment { granite color_map { [0.0 color rgb 10] [0.05 color rgb 1] [0.1 color rgb 1] [0.2 color 0]} scale .015 } } #declare camloc = <0,0,-6>; #declare planetloc = <-120,40,300>; #declare planetscale = 80; #declare nebulaloc = <250,-65,500>; #declare nebulascale = 200; camera { location camloc 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> pigment { gradient y color_map { //My best guesses :) #declare PinColor = <.995,1,.8>; #declare StripeColor = <.65,0,0>; [0 rgb <.95,.8,.4>] [.015 rgb <.95,.8,.4>] [.015 rgb PinColor] [7.15/13 rgb PinColor] [7.15/13 rgb StripeColor] [8/13 rgb StripeColor] [8/13 rgb PinColor] [9/13 rgb PinColor] [9/13 rgb StripeColor] [9.85/13 rgb StripeColor] [9.85/13 rgb PinColor] } } finish { diffuse .75 ambient 0 phong 1 phong_size 120 brilliance .6 //specular .3 //roughness .0001 } normal { dents .25 scale .06 } } // balls + pins #declare pin_radius = 1.4; // radius of pin's orbit #declare base_torus_func = function(a,b) { select(a-.1,0,select(a-.9,(a-.1)/.8,select(a-.945,1-(a-.9)/.045,0)))*pow(b,1-a) } #macro puff_of_light(major_rad, minor_rad, light_color, rotamnt) torus { major_rad, minor_rad rotate <7.5,0,90> translate z*-pin_radius rotate y*rotamnt interior { media { emission light_color } } } #end #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 { union { merge { torus { 0.05, 0.007} cylinder { -.007*y, .007*y, .05 } rotate <15,0,90> translate z*-pin_radius rotate y*258.5 interior { media { emission 50*pin_streak_color } } } torus { 0.04, 0.006 rotate <12,0,90> translate z*-pin_radius rotate y*256.5 interior { media { emission 40*pin_streak_color } } } torus { 0.033, 0.005 rotate <9,0,90> translate z*-pin_radius rotate y*254.5 interior { media { emission 30*pin_streak_color } } } torus { 0.025, 0.0045 rotate <6,0,90> translate z*-pin_radius rotate y*252.5 interior { media { emission 15*pin_streak_color } } } torus { 0.02, 0.004 rotate <6,0,90> translate z*-pin_radius rotate y*250.5 interior { media { emission 7*pin_streak_color } } } /*sphere { 0.0, 0.005 //rotate <0,0,90> translate z*-pin_radius rotate y*250.5 interior { media { emission 5*pin_streak_color } } }*/ torus { pin_radius, pin_radius*0.01 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) ) } } } } } pigment {rgbt 1} 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 (vdot(vnormalize(pos-camloc),vnormalize(planetloc-camloc)) > .96) // .91 for old position #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>) // for old position ball_and_pin(<.3,.7,1>/(planetscale*1.4), .77,<63,-25,25>,<-5,-25,20>) // for new position scale planetscale translate planetloc } // nebula #declare nebulacolor = <1,.5,.25>; // make sure each component has at least a little color (not zero) and you get that nice fade-to-white oversaturation effect in the center sphere { 0,1.3 pigment {rgbt 1} interior { media { scattering { // ah, the joy of slow renders 5, nebulacolor / nebulascale * 10 eccentricity .4 //makes it brighter where the light is coming from (the center in this case); check documentation for details } density { spherical poly_wave 1.5 scale 2 // reduces distortion effect of turbulence warp { turbulence .6 octaves 3 omega .6 lambda 4 } scale 1/2 // undoes scaling } density { bozo color_map {[0 rgb 0][1 rgb 1]} poly_wave 1.5 warp { turbulence .65 octaves 2 omega .4 lambda 3 } scale .2 } } } hollow scale nebulascale translate nebulaloc } light_source { nebulaloc rgb nebulacolor }