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

#macro quadro(tt)

#declare tx_violet =
  texture{
    pigment{ color rgb < 0.54, 0.17, 0.88 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_yellow =
  texture{
    pigment{ color rgb < 1.0, 1.0, 0.0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_green =
  texture{
    pigment{ color rgb < 0.0, 1.0, 0.0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

#declare tx_blue =
  texture{
    pigment{ color rgb < 0.0, 0.0, 1.0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

#declare raio = 5.000;

#macro interpola2(ta, a, tb, b, tt)
 #local r = (tt-ta)/(tb-ta);
 ((1-r)*a+r*b)
#end

#macro interpola4(ta,a,b,c,d,td,tt)
 #local ab = interpola2(ta, a, td, b, tt);
 #local bc = interpola2(ta, b, td, c, tt);
 #local cd = interpola2(ta, c, td, d, tt);

 #local abc = interpola2(ta, ab, td, bc, tt);
 #local bcd = interpola2(ta, bc, td, cd, tt);
 #local abcd = interpola2(ta, abc, td, bcd, tt);

 abcd
#end

#declare asa1 =
        box{ <0,0,0>, <4,2,0.5> texture {tx_grey} }

#local p1 = <0,0,0>;
#local p2 = <0,0,0>;
#local p3 = <0,0,0>;
#local p4 = <0,0,0>;

#local p5 = <0, 0.75,   0.5>;
#local p6 = <0.5,       0.75,   0.25>;
#local p7 = <0.5,       0.75,   -0.25>;
#local p8 = <0, 0.75,   -0.5>;

#local p9 = <0, 1.5,    1>;
#local p10 = <1,        1.5,    0.5>;
#local p11 = <1,        1.5,    -0.5>;
#local p12 = <0,        1.5,    -1>;

#local c5 = <0, 5.25,   1.5>;
#local c6 = <1.5,       5.25,   1>;
#local c7 = <1.5,       5.25,   -1>;
#local c8 = <0, 5.25,   -1.5>;

#local c9 = <0, 8.25,   1.5>;
#local c10 = <1.5,      8.25,   1>;
#local c11 = <1.5,      8.25,   -1>;
#local c12 = <0,        8.25,   -1.5>;

#local p13 = (p9 + c5)/2;
#local p14 = (p10 + c6)/2;
#local p15 = (p11 + c7)/2;
#local p16 = (p12 + c8)/2;

#local c1 = p13;
#local c2 = p14;
#local c3 = p15;
#local c4 = p16;

#local b5 = <0, 11.0,   0.75>;
#local b6 = <1.5,       11.0,   0.25>;
#local b7 = <1.5,       11.0,   -1>;
#local b8 = <0, 11.0,   -1.5>;

#local b9 = <0, 11.75,  0.75>;
#local b10 = <1.5,      11.75,  0.25>;
#local b11 = <1.5,      11.75,  -0.25>;
#local b12 = <0,        11.75,  -0.5>;

#local b13 = <0,        12.5,   0>;
#local b14 = <1.5,      12.5,   0>;
#local b15 = <1.5,      12.5,   0>;
#local b16 = <0,        12.5, 0>;

#local c13 = (c9 + b5)/2;
#local c14 = (c10 + b6)/2;
#local c15 = (c11 + b7)/2;
#local c16 = (c12 + b8)/2;

#local b1 = c13;
#local b2 = c14;
#local b3 = c15;
#local b4 = c16;

#declare aviao1 =
 union{

object{
        retalho(p1,p2,p3,p4,
                                        p5,p6,p7,p8,
                                        p9,p10,p11,p12,
                                        p13,p14,p15,p16,
                                        0.01, tx_yellow, tx_grey) scale 0.5 translate -3*y}

object{
        retalho(c1,c2,c3,c4,
                                        c5,c6,c7,c8,
                                        c9,c10,c11,c12,
                                        c13,c14,c15,c16,
                                        0.01, tx_yellow, tx_grey) scale 0.5 translate -3*y}

object{
        retalho(b1,b2,b3,b4,
                                        b5,b6,b7,b8,
                                        b9,b10,b11,b12,
                                        b13,b14,b15,b16,
                                        0.01, tx_yellow, tx_grey) scale 0.5 translate -3*y}

object{
        retalho(p1,p2,p3,p4,
                                        p5,p6,p7,p8,
                                        p9,p10,p11,p12,
                                        p13,p14,p15,p16,
                                        0.01, tx_yellow, tx_grey) scale -0.5 translate 3*y rotate 180*x}

object{
        retalho(c1,c2,c3,c4,
                                        c5,c6,c7,c8,
                                        c9,c10,c11,c12,
                                        c13,c14,c15,c16,
                                        0.01, tx_yellow, tx_grey) scale -0.5 translate 3*y rotate 180*x}

object{
        retalho(b1,b2,b3,b4,
                                        b5,b6,b7,b8,
                                        b9,b10,b11,b12,
                                        b13,b14,b15,b16,
                                        0.01, tx_yellow, tx_grey) scale -0.5 translate 3*y rotate 180*x}

object{ asa1 scale 0.5 translate <0.5, 0, 0> }
object{ asa1 scale 0.5 translate <-2.5, 0, 0> }
}

#macro rota_aviao1()

        #if((tt>=0)&(tt<=0.5))

                #local a = <0,5,3>;
                #local b = <3,3,3>;
                #local c = <3,2,3>;
                #local d = <0,0,3>;

                #local r = interpola4(0, a, b, c, d, 0.5, tt);

        #end

        #if((tt>=0.5)&(tt<=1))

                #local a = <0,0,3>;
                #local b = <-3,-2,3>;
                #local c = <-3,-3,3>;
                #local d = <0,-4,3>;

                #local r = interpola4(0, a, b, c, d, 0.5, tt);

        #end

        object{ aviao1 translate r }

#end

#macro rota_aviao2()

        #if((tt>=0)&(tt<=0.5))

                #local a = <0,-5,-3>;
                #local b = <3,-3,-3>;
                #local c = <3,-2,-3>;
                #local d = <0,0,-3>;

                #local r = interpola4(0, a, b, c, d, 0.5, tt);

        #end

        #if((tt>=0.5)&(tt<=1))

                #local a = <0,0,-3>;
                #local b = <-3,2,-3>;
                #local c = <-3,3,-3>;
                #local d = <0,4,-3>;

                #local r = interpola4(0, a, b, c, d, 0.5, tt);

        #end

        object{ aviao1 translate r }

#end

rota_aviao1()
rota_aviao2()

#end

#include "retalho.inc"
#include "eixos.inc"

quadro(clock)

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

#include "camlight.inc"
camlight(<0,0,0>,9.605,<10,10,10>,17.464,z,1.2)