//Rubik's Cube animation system //Lucas Garron; www.garron.us //Begun November 20, 2005, finished November 23, 2005 //Refined for release November 26, 2006 //String parser added December 9, 2006 //created for POV-Ray 3.6 //Command line //For animation, use -kc (~2-10 frames per turn is recommended) //Without floor, use +ua #declare include_floor=1;//Render using +ua if include_floor!=1 #declare focal_blur=0; //For optional artistic effect #declare sine=1; //A gentle sinusoidal rotation through the animation #declare ang=20; //The angle of maximum rotation #declare time1=0.0; //Time to start twisting #declare time2=0.98; //Time to end twisting #declare thick=0.05; //Thickness of the tiles #declare space=0.2; //Space around the rim of of each tile //***************Algorithm*************** //Automatically parse the algorithm as a string to generate the appropriate array #declare alg="RUR'U'R'FR2U'R'U'RUR'F' . R2U'R2' L'URU'LU2R'URU2R UR2'" //Same Sample alg; "." indicates a rest #declare ind=0; #declare num=0; #declare arr=array[strlen(alg)] #while (ind right look_at <0,-1,0> #if (focal_blur=1) aperture 0.7 blur_samples 50 focal_point <2.8,2.8,-2.8> #end } //***************************************************************************** //Natural light light_source {<20,100,60>, rgb 0.3} light_source {<-20,100,-20>, rgb 0.3} light_source {<-10,100,15>, rgb 0.3} light_source {<7,5,-8>*10, rgb 2} //Main light //Floor #if (include_floor=1) plane {y,-5 pigment{rgb <0.8,0.7,0.3>} normal{quilted 0.05} finish{reflection 1 metallic}} #end //Sticker/Tile colors #declare color1= pigment{rgb <1,1,0>} //U face #declare color2= pigment{rgb <0,0.6,0>} //R face #declare color3= pigment{rgb <0.7,0,0>} //F face #declare color4= pigment{rgb <0,0,0.7>} //L face #declare color5= pigment{rgb <1,0.4,0>} //B face #declare color6= pigment{rgb <1,1,1>} //D face #declare sticker1= box{<-1+space,1,-1+space>,<1-space,1.+thick,1-space> pigment{color1}} #declare sticker2= object{sticker1 pigment{color2} rotate z*-90} #declare sticker3= object{sticker1 pigment{color3} rotate x*-90} #declare sticker4= object{sticker1 pigment{color4} rotate z*90 } #declare sticker5= object{sticker1 pigment{color5} rotate x*90 } #declare sticker6= object{sticker1 pigment{color6} rotate x*180} #declare unitcube= superellipsoid { <0.1, 0.1> pigment{color 0} finish {specular 3 roughness 0.001}} //cubie shape //#declare unitcube= box { -1,1 pigment{color 0} finish {specular 0.1 roughness 0.0003}} //alternate cubie shape #declare cubes= array[27] #declare pos_index= array[27] #declare c1=-4; #while (c1<2) #declare c1=c1+2; #declare c2=-4; #while (c2<2) #declare c2=c2+2; #declare c3=-4; #while (c3<2) #declare c3=c3+2; #declare cubes[9*(c1/2+1)+3*(c2/2+1)+(c3/2+1)]= union { object{unitcube} #if (c2= 2) object{sticker1} #end #if (c1= 2) object{sticker2} #end #if (c3=-2) object{sticker3} #end #if (c1=-2) object{sticker4} #end #if (c3= 2) object{sticker5} #end #if (c2=-2) object{sticker6} #end translate } #declare pos_index[9*(c1/2+1)+3*(c2/2+1)+(c3/2+1)]= 9*(c1/2+1)+3*(c2/2+1)+(c3/2+1); #end #end #end #if ((time15) #declare cubes[pos_index[c4]]=object{cubes[pos_index[c4]] #if (((mc)/(dimension_size(moves,1))*(time2-time1)+time1)5) #declare cubes[pos_index[c4]]=object{cubes[pos_index[c4]] #if (((mc)/(dimension_size(moves,1))*(time2-time1)+time1)