// Last edited on DATE TIME by USER
// Processed by remove-cam-lights
#macro interpola(ta, va, tb, vb, tt)
  #local s = (tt-ta)/(tb-ta);
  ((1-s)*va+s+vb)
#end

#declare fase0 = 0.000;
#declare fase05 = 0.250;
#declare fase1 = 0.500;
#declare fase15 = 0.750;
#declare fase2 = 1.000;

#declare alfa0 = -30;
#declare alfa1 = 0;
#declare beta0 = 80;
#declare beta1 = 0;
#declare gama0 = -60;
#declare gama1 = 0;

#declare tx_fosca =
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tinta_A =
  texture {
    pigment { color rgb < 0.55, 0.80, 0.55 > }
    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()
  box{<0,0,0>,<0.2,0.1,0.05>}
#end

#macro anteperna(alfa)
union{
  box{<0,0,0>,<0.1,0.1,0.5>}
  object{ pe() translate<0,0,-0.025> rotate alfa*y}
}
#end

#macro perna(alfa, beta)
union{
  cone{<0.05,0.05,0>,0.05, <0.05,0.05,0.6>,0.07 texture{tinta_A}}
  object{anteperna(alfa) translate<0,0,-0.45> rotate beta*y texture{tinta_A}}
}
#end

#declare chassis =
union{
  box{ <0, 0, 0>, <1, 0.5, 0.3> }
  box{ <1,0,0>, <1.15,0.5, 0.15>}
  cylinder{<1,0,0.15>,<1,0.5,0.15>,0.15}
}

#macro saltopode(alfa, beta, gama)
union{
  object{chassis texture{tinta_B}}
  object{perna(alfa, beta) translate<0.3,0.05,-0.55> rotate gama*y}
  object{perna(alfa, beta) translate<0.3,0.40,-0.55> rotate gama*y}
}
#end

#declare escada=
  union{
    box{<-4,0,-6>, <-2,2,-2> texture{tx_fosca}}
    box{<-2,0,-6>, <-0,2,-1> texture{tx_fosca}}
    box{<-0,0,-6>, <2,2,1> texture{tx_fosca}}
    box{<2,0,-6>, <4,2,2> texture{tx_fosca}}
    box{<4,0,-6>, <6,2,4> texture{tx_fosca}}
    box{<6,0,-6>, <8,2,5> texture{tx_fosca}}
    box{<8,0,-6>, <12,2,7> texture{tx_fosca}}
    box{<10,0,-6>, <14,2,8> texture{tx_fosca}}
  }

#macro cena(alfa, beta, gama)//, pos_x, pos_z)

#include "eixos.inc"

union
{

  object{saltopode(alfa, beta, gama)}// translate<pos_x,0,pos_z>}

}
#end

#macro armacao(fase)
#if((fase>=fase0)&(fase<fase1))
  #declare alfa=interpola(fase0, alfa0, fase1, alfa1, fase);
  #declare beta=interpola(fase0, beta0, fase1, beta1, fase);
  #declare gama=interpola(fase0, gama0, fase1, gama1, fase);
#else
  #declare alfa=interpola(fase1, alfa1, fase2, alfa0, fase);
  #declare beta=interpola(fase1, beta1, fase2, beta0, fase);
  #declare gama=interpola(fase1, gama1, fase2, gama0, fase);
#end

object { cena(alfa, beta, gama)}
#end

#macro voo(fase)
union
{
  #if((fase>=fase0)&(fase<fase1))
    #declare h_escada=-4*fase;
    #declare fase_armacao = 2*fase;
    #if(fase<=fase05)
      #declare h_auto = fase*2;
    #else
      #declare h_auto = (fase1-fase)*2;
    #end
  #else
    #declare h_escada=-2-2*(fase-0.5);
    #declare fase_armacao = 2*(fase-0.5);
    #declare h_auto = 0;
  #end
  object{escada translate<fase*(-4),0, h_escada>}
  object{armacao(fase_armacao*2) translate<-2.5,1,-0.5+h_auto>}
}
#end

#macro quadro(tt)

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

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

#declare ctt4 = cos(6*pi*tt);

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

object{voo(tt)}

#end

quadro(clock)

// Original camera parameters:
// #local cam_ctr = <0,0,0>
// #local cam_loc = <0.00,10.00,0.00>
// #local cam_vec = <0.00,10.00,0.00>
// #local cam_sky = z

#include "camlight.inc"
camlight(<0,0,0>,5.500,<10,10,10>,10.000,z,1.2)