// Snakey Mass with 3-Way Rotational Symmetry // (C) Fergus C. Murray, June 2000 #version 3.0 global_settings { assumed_gamma 1.0 } camera { location < 0, 0, -30> direction 1*z look_at < 0, 0, 0> } // ------------------------------------------------------------------ // Simple background for a simple scene background { color rgb <0.0, 0.0, 0.0> } // ------------------------------------------------------------------ // A light source light_source { <50, 20, -50> color rgb 1 } light_source { <0, 0, -40> color rgb <1,0.7,0.4> } // ------------------------------------------------------------------ #declare BasicShape = // create a three-sphere shape union{ sphere { x*2, 0.25 rotate (z) } sphere { x*2, 0.25 rotate (z)*120 } sphere { x*2, 0.25 rotate (z)*240 } } // ------------------------------------------------------------------ // Set up the loop variables: // the Counter variable will go from 0.0 to 1.0 // in NumIterations loops. #declare NumIterations = 720 // try different numbers of objects (20,40,80...) // probably best not change these #declare Counter = 0.0 #declare Increment = 1.0/NumIterations #declare Arm = 1 #declare armangle = 0.0 #declare NumTwists = 360*4 // full twists // ------------------------------------------------------------------ // Create an iterated object built from our basic shape union{ #declare Flipper = 1 // Flipper will switch between 1 and -1 each loop #while (Counter<1.0) object { BasicShape scale 1+Flipper*(Counter-0.5) //rotate y*Counter*2 rotate x*(Flipper*clock-Counter*2)*360 //rotate z*Counter*360-clock*360 translate z*2 rotate 18*cos((Counter*2+Flipper*clock)*pi*2)*x // rotate 30*cos((Counter*2*Flipper-clock)*pi*2)*y //rotate x*(NumTwists*Counter) translate <12*(Counter), 0, 0> rotate armangle*z #declare armangle=armangle+60 // put down the texture texture { pigment { // colors change as we stack them up color rgb <0, (Flipper+1)*sqrt(Counter)*0.2, 0.5-0.5*cos(Counter*1440)> } finish { ambient 0.01 specular 0.5 diffuse 0.5 roughness 0.1 } } } #declare Flipper = - Flipper // flip its value (1->-1 or -1->1) // manually increment our counter inside the loop #declare Counter=Counter+Increment #end }