#include "colors.inc" #include "glass.inc" //------------------------------ settei #declare R=0.1; //-------------- radius of frames #declare N=5; //-------------- N of (K/N) #declare K=2; //-------------- K of (K/N) #declare loops=3; //----------- number of loops (incomplete) //its value must be 1,3,4,6 or 12. try. //------------------------------ camera camera{ location <8,8,-12>*0.95 look_at <0,0,0> angle 30 } //------------------------------ light light_source{ <50,50,-50> color White } light_source{ <30,50,-60> color White } light_source{ <-20,50,50> color White*0.3 } //-------------------------------- glass box object{ box{<-2,-2,-2>,<2,2,2>} texture{T_Old_Glass} // texture{pigment{color White}} } //-------------------------------- floor object{ plane{y,-3} texture{pigment{color White}} /* texture{ T_Silver_3A }*/ } //------------------------------------------------------------------ #declare nor=y; #declare dir=x; #declare vir=z; #declare num=1; #declare pos=2*nor+(-2)*dir+(-2)*vir+(2*num-1)*2/N*dir; #declare nxt=pos+4*vir+4*K/N*dir; #if(vdot(nxt,dir)<=2) #declare OneLoop = object{ union{ object{ cylinder{ pos,nxt,R } } object{ sphere{nxt,R} } } } #declare dum=nor; #declare nor=vir; #declare vir=-dum; #declare num=num+K; #else #declare tt=(2*N+1-2*num)/(2*K); #declare mid=(1-tt)*pos+tt*nxt; #declare OneLoop = object{ union{ object{ cylinder{ pos,mid,R } } object{ sphere{mid,R} } } } #declare nxt=mid+vaxix_rotate((nxt-mid),vir,-90); #declare OneLoop = object{ union{ object{ OneLoop } object{ cylinder{ mid,nxt,R } } object{ sphere{nxt,R} } } } #declare dum=vir; #declare vir=-dir; #declare dir=-nor; #declare nor=dum; #declare num=num+K-N; #end #while (!((vlength(nor-y)=0)&(vlength(dir-x)=0)&(vlength(vir-z)=0)&(num=1))) #declare pos=2*nor+(-2)*dir+(-2)*vir+(2*num-1)*2/N*dir; #declare nxt=pos+4*vir+4*K/N*dir; #if(vdot(nxt,dir)<=2) #declare OneLoop = object{ union{ object{ OneLoop } object{ cylinder{ pos,nxt,R } } object{ sphere{nxt,R} } } } #declare dum=nor; #declare nor=vir; #declare vir=-dum; #declare num=num+K; #else #declare tt=(2*N+1-2*num)/(2*K); #declare mid=(1-tt)*pos+tt*nxt; #declare OneLoop = object{ union{ object{ OneLoop } object{ cylinder{ pos,mid,R } } object{ sphere{mid,R} } } } #declare nxt=mid+vaxis_rotate((nxt-mid),vir,-90); #declare OneLoop = object{ union{ object{ OneLoop } object{ cylinder{ mid,nxt,R } } object{ sphere{nxt,R} } } } #declare dum=vir; #declare vir=-dir; #declare dir=-nor; #declare nor=dum; #declare num=num+K-N; #end #end #if (loops=1) object{ OneLoop texture{pigment{color Red }} } #else #if (loops=3) //----------------------------3loop object{ OneLoop texture{pigment{color Red }} } object{ OneLoop texture{pigment{color Blue }} rotate<0,90,0> } object{ OneLoop texture{pigment{color Yellow }} rotate<0,0,90> } #else #if (loops=4) //---------------------------4loop object{ OneLoop texture{pigment{color Red }} } object{ OneLoop texture{pigment{color Blue }} rotate<0,90,0> } object{ OneLoop texture{pigment{color Yellow }} rotate<0,180,0> } object{ OneLoop texture{pigment{color Green }} rotate<0,270,0> } //----------------------------6loop #else #if(loops=6) object{ OneLoop texture{pigment{color Red }} // texture{pigment{color LightBlue }} } object{ OneLoop texture{pigment{color Blue }} // texture{pigment{color LightBlue }} rotate<0,90,0> } object{ OneLoop texture{pigment{color Green }} // texture{pigment{color LightBlue }} rotate<0,180,0> } object{ OneLoop texture{pigment{color Cyan }} // texture{pigment{color LightBlue }} rotate<0,-90,0> } object{ OneLoop texture{pigment{color Magenta }} // texture{pigment{color LightBlue }} rotate<0,0,-90> } object{ OneLoop texture{pigment{color Yellow }} // texture{pigment{color LightBlue }} rotate<0,0,90> } #else //--------------------------------loops=12 object{ OneLoop texture{pigment{color Red }} // texture{pigment{color LightBlue }} } object{ OneLoop texture{pigment{color Blue }} // texture{pigment{color LightBlue }} rotate<0,90,0> } object{ OneLoop texture{pigment{color Green }} // texture{pigment{color LightBlue }} rotate<0,180,0> } object{ OneLoop texture{pigment{color Violet }} // texture{pigment{color LightBlue }} rotate<0,180,0> rotate<0,0,-90> } object{ OneLoop texture{pigment{color Cyan }} // texture{pigment{color LightBlue }} rotate<0,-90,0> } object{ OneLoop texture{pigment{color Magenta }} // texture{pigment{color LightBlue }} rotate<0,0,-90> } object{ OneLoop texture{pigment{color Brown }} // texture{pigment{color LightBlue }} rotate<0,0,-90> rotate<0,90,0> } object{ OneLoop texture{pigment{color Orange }} // texture{pigment{color LightBlue }} rotate<0,0,-90> rotate<0,-90,0> } object{ OneLoop texture{pigment{color Gray }} // texture{pigment{color LightBlue }} rotate<0,0,-90> rotate<0,180,0> } object{ OneLoop texture{pigment{color Yellow }} // texture{pigment{color LightBlue }} rotate<0,0,90> } object{ OneLoop texture{pigment{color White }} // texture{pigment{color LightBlue }} rotate<0,0,90> rotate<0,90,0> } object{ OneLoop texture{pigment{color RichBlue }} // texture{pigment{color LightBlue }} rotate<0,0,90> rotate<0,-90,0> } #end #end #end #end