#version 3.0 global_settings { assumed_gamma 1.0 } // ------------------------------------------------------------------ // Look down at an angle at our creation 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, 80, -80> color rgb 1 } light_source { <-25, 50, -90> color rgb <1,0.2,0> } // ------------------------------------------------------------------ #declare BasicShape = // create a sphere shape union{ difference{ sphere { 0,0.5 scale < 1,1,0.25> } sphere { 0.3*x,0.5 } } cylinder { -x*0.5,x*0.05,0.025 } } #declare EyeBalls = union{ sphere { -0.5*z+x*0.05,0.125} sphere { 0.5*z+x*0.05,0.125} } // ------------------------------------------------------------------ // Set up the loop variables: // the Counter variable will go from 0.0 to 1.0 // in NumIterations loops. #declare NumIterations = 16 // try different numbers of boxes (20,40,80...) #declare Counter = 0.0 #declare Increment = 1.0/NumIterations #declare Arm = 1 #declare armangle = 60.0 #declare NumTwists = 360*4 // full twists #declare fish = 1; // ------------------------------------------------------------------ // Create an iterated object built from our basic shape union{ #declare Flipper = 1 // Flipper will switch between 1 and -1 each loop #while (fish<7.0) #while (Counter<1) object { #if (Counter>0.05) BasicShape #else EyeBalls #end scale 2+1.5*sin(Counter*2.5*pi)+y #if (Counter>0.3 & Counter<0.335) scale (y*2+z/2) #end //rotate y*(Flipper+clock-Counter*2)*360 rotate cos((Counter-clock)*pi*2)*y //rotate z*Counter*360-clock*360 translate x*6 //rotate 15*cos((Counter*2-clock)*pi*2)*x rotate 6*sin((Counter-clock)*pi*2)*y rotate armangle*x //rotate x*(NumTwists*Counter) translate <10*(Counter), 0, 0> rotate armangle*z // put down the texture texture { pigment { // colors change as we stack them up color rgb } finish { ambient 0.01 specular 0.5 diffuse 0.5 roughness 0.1 } } } // manually increment our counter inside the loop #declare Counter=Counter+Increment #end #declare Flipper = - Flipper // flip its value (1->-1 or -1->1) #declare Counter=0.0 #declare armangle=armangle+60 #declare fish=fish+1 #end }