// Last edited on DATE TIME by USER
// Processed by remove-cam-lights

#macro quadro(tt)

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare raio = 2.000;

#declare ctt = cos(2*pi*tt);

#declare stt = sin(2*pi*tt);

#declare tinta_A =
  texture {
    pigment { color rgb < 0.55 + 0.45*ctt, 0.80, 0.55 - 0.5*ctt > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_B =
  texture {
    pigment { color rgb < 1.00, 0.80, 0.10 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#macro pe(gama)
   object{ box{ <-.7,-.5,0> <.7,2.5,.3> } rotate gama*x texture{ tinta_B } }#end

#macro anteperna(beta,gama)
   union{
      object{ cylinder{ <0,0,0> <0,0,-2.5> .5 } texture{ tinta_B } }
      object{ pe(gama) translate -2.5*z }
      rotate -beta*x
   }
#end

#macro perna(alfa,beta,gama)
   union{
      object{ cylinder{ <0,0,0> <0,0,-3> .7 } texture{ tinta_B } }
      object{ sphere{ <0,0,-3> .7 } texture{ tinta_B } }
      object{ anteperna(beta,gama) translate -3*z }
      rotate alfa*x
   }
#end

#macro veiculo(alfa,beta,gama)
   union{
         object{ sphere{ <0,0,0> 4 } texture{ tinta_B } }
         #declare i=0;
         #while(i<6)
            object{ perna(alfa,beta,gama) translate 3.5*y rotate 60*i*z }
            #declare i=i+1;
         #end
   }
#end

#macro interpolar(ta,va,tb,vb,ttt)
   (va+(vb-va)*(ttt-ta)/(tb-ta))
#end

#macro armacao(fase)// 0 <= fase <= 1
   #declare k=6*tt-3;
   #declare alfa=k*k*10;
   #declare beta=k*k*10;
   #declare gama=-90+k*k*10;

   object{ veiculo(alfa,beta,gama) }

   #declare w=8;
   #declare p=(2*tt-0.5)*pi;

#end

#macro voo(fase)
   #declare alfa=interpolar(0.0, 90, 1.0, 5, fase);
   #declare beta=interpolar(0.0, 0, 1.0, 30, fase);
   #declare gama=interpolar(0.0, 0, 1.0, 30, fase);

   object{ veiculo(alfa, beta, gama) }

#end

#macro voo_geral(fase)
   #declare r=28;
   #switch(tt)
      #range(0.0,0.25)
         object{ voo(4*tt) }
         rotate x*interpolar(0.0, 0, 0.25, 90, tt)
         translate interpolar(0.0,<0,0,-r>,0.25,<0,r,0>,tt)
      #break
      #range(0.25,0.50)
         object{ voo(4*(tt-0.25)) }
         rotate x*interpolar(0.25 ,90, 0.50, 180, tt)
         translate interpolar(0.25,<0,r,0>,0.50,<0,0,r>,tt)
      #break
      #range(0.50,0.75)
         object{ voo(4*(tt-0.50)) }
         rotate x*interpolar(0.50, 180, 0.75, 270, tt)
         translate interpolar(0.50,<0,0,r>,0.75,<0,-r,0>,tt)
      #break
      #range(0.75,1.00)
         object{ voo(4*(tt-0.75)) }
         rotate x*interpolar(0.75, 270, 1.00, 360, tt)
         translate interpolar(0.75,<0,-r,0>,1.00,<0,0,-r>,tt)
      #break
   #end
#end

#include "eixos.inc"

union{
   object{ eixos(3.00) }

   voo_geral(tt)

   scale .1

}

#end

quadro(clock)

// Original camera parameters:
// #local cam_ctr = <0,0,0>
// #local cam_loc = <8.00,4.00,2.00>
// #local cam_vec = <8.00,4.00,2.00>
// #local cam_sky = z

#include "camlight.inc"
camlight(<0,0,0>,5.041,<10,10,10>,9.165,z,1.2)