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

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 50.0;
#declare dir_camera = <40,0,15>;
#declare dist_camera = 50;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)

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

#declare tx_preto =
  texture{
    pigment{ color rgb < 0.00, 0.00, 0.00 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_rosa =
  texture{
    pigment{ color rgb < 1, 0.4, 0.8 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_vermelho =
  texture{
    pigment{ color rgb < 1, 0, 0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_pele =
  texture{
    pigment{ color rgb < 1, 0.72, 0.51 > }
    finish{ diffuse 0.9 ambient 0.1 }
}

#declare tx_verde =
 texture{
   pigment{ color rgb < 0.49, 0.99 , 0 > }
   finish{ diffuse 0.9 ambient 0.1 }
 }

#declare tx_escada =
  texture{
    pigment{ color rgb < .5,.6,.8 > }
    finish{ diffuse 0.9 ambient 0.1 }
 }

#declare tx_branco =
  texture{
    pigment{ color rgb < 1, 1, 1 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_azul =
  texture{
    pigment{ color rgb < 0, 0, 1 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_amarelo =
  texture{
    pigment{ color rgb <1,1,0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 0.20, 0.67, 0.20 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare tx_vidro =
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 }
  }

#macro pe()
        union{
                intersection{
                        cone { <0,0,0>,0.4,<0,1.5,0>,0.4 }
                        texture {tx_pele}
                }
        }
#end

#macro canela(gama)
        union{
                cone { <0,0,0>,0.4,<0,0,-3>,0.4 }
                sphere {<0,0,-3>,0.5 }
                object { pe() rotate gama*x translate <0,0,-3> }
                texture { tx_pele }
        }
#end

#macro coxa(beta,gama)
        union{
                cone { <0,0,0>,0.4,<0,0,-3>,0.4 }
                sphere {<0,0,-3>,0.5 }
                object { canela(gama) rotate beta*x translate <0,0,-3> }
                texture { tx_pele }
        }
#end

#macro bicho(alfa,beta,gama)
        union{
                union{
                        intersection{
                                        sphere{<0,0,7.2>,3 }
                                        box{<-10,-10,7.2>,<10,10,15>}
                                        texture { tx_vidro}
                                }
                        box{<-4,-4,6.2>,<4,4,7.2>}
                        texture {tx_azul}
                }
        object {coxa(beta,gama) rotate alfa*x translate <2,0,6.2>}
        object {coxa(beta,gama) rotate alfa*x translate <-2,0,6.2>}
        }
#end

#macro interpol(ta,va,tb,vb,tt)
        #local s = (tt-ta)/(tb-ta);
        ((1-s)*va+s*vb);
#end

#macro caixa(altura)
                box{
                <-2,-2,0>,
                <2,2,altura>
                }
                texture {tx_xadrez}
#end

#macro armacao(fase)
        #declare t0 = 0;
        #declare t1 = 0.5;
        #declare t2 = 1;
        #if ((fase>=t0) & (fase<=t1))
                #declare alfa = interpol(t0,15,t1,30,fase);
                #declare beta = interpol(t0,-30,t1,-60,fase);
                #declare gama = interpol(t0,15,t1,30,fase);
                #declare pos_carro = interpol(t0,0,t1,-0.75,fase);
        #end
        #if ((fase>t1) & (fase<=t2))
                #declare alfa = interpol(t1,30,t2,0,fase);
                #declare beta = interpol(t1,-60,t2,0,fase);
                #declare gama = interpol(t1,30,t2,-25,fase);
                #declare pos_carro = interpol(t1,-0.75,t2,0.5,fase);
        #end
        object { bicho(alfa,beta,gama) translate <0,0,pos_carro+0.5> }
#end

#macro voo(h,fase)
        #declare t0 = 0;
        #declare t1 = 0.5;
        #declare t2 = 1;
        #if ((fase>=t0) & (fase<=t1))
                #declare alfa = interpol(t0,0,t1,7,fase);
                #declare beta = interpol(t0,0,t1,-14,fase);
                #declare gama = interpol(t0,-25,t1,-50,fase);
                #declare pos_carro = interpol(t0,0.5,t1,h,fase);
        #end
        #if ((fase>t1) & (fase<=t2))
                #declare alfa = interpol(t1,7,t2,15,fase);
                #declare beta = interpol(t1,-14,t2,-30,fase);
                #declare gama = interpol(t1,-50,t2,15,fase);
                #declare pos_carro = interpol(t1,h,t2,0,fase);
        #end
        object { bicho(alfa,beta,gama) translate <0,0,pos_carro+0.5> }
#end

#macro voo_geral(h,p,q,fase,angulo)
        #local r = interpol (0,p,1,q,fase);
        object{
                voo(h,fase)
                rotate angulo*z
                translate r
        }
#end

#macro armacao_geral(p,fase,ai,af)
        #local g = interpol(0,ai,1,af,fase);
        object{

                armacao(fase)
                rotate g*z
                translate p
        }
#end

#declare chao =
        box{
                <-40,-40,-1>,<40,40,0>
                texture {tx_xadrez}
        }

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

#include "eixos.inc"

#macro quadro(tt)

union {
        object { chao }

        object { caixa(10) translate <0,-10,0>}
        object { caixa(6) translate <-10,0,0>}
        object { caixa(10) translate <0,10,0>}
        object { caixa(6) translate <10,0,0>}

        #local A = <0,-10,10>;
        #local B = <-10,0,6>;
        #local C = <0,10,10>;
        #local D = <10,0,6>;

        #if(tt<0.05 )
                #local fase=interpol(0,0,0.05,1,tt);
                object { armacao_geral(A,fase,135,45) }
        #end
        #if((tt>=0.05) & (tt<0.25))
                #local fase=interpol(0.05,0,0.25,1,tt);
                object { voo_geral(7,A,B,fase,45) }
        #end

        #if((tt>=0.25) & (tt<=0.3))
                #local fase=interpol(0.25,0,0.3,1,tt);
                object { armacao_geral(B,fase,45,-45) }
        #end
        #if((tt>=0.3) & (tt<0.5))
                #local fase=interpol(0.3,0,0.5,1,tt);
                object { voo_geral(7,B,C,fase,-45) }
        #end

        #if((tt>=0.5) & (tt<=0.55))
                #local fase=interpol(0.5,0,0.55,1,tt);
                object { armacao_geral(C,fase,-45,-135) }
        #end
        #if((tt>=0.55) & (tt<0.75))
                #local fase=interpol(0.55,0,0.75,1,tt);
                object { voo_geral(7,C,D,fase,-135) }
        #end

        #if((tt>=0.75) & (tt<=0.8))
                #local fase=interpol(0.75,0,0.8,1,tt);
                object { armacao_geral(D,fase,-135,-225) }
        #end
        #if((tt>=0.8) & (tt<=1))
                #local fase=interpol(0.8,0,1,1,tt);
                object { voo_geral(7,D,A,fase,-225) }
        #end

}

#end

quadro(clock)