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

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 }
  }

#include "eixos.inc"

#local A22 = <5,3,7>;
#local A23 = <5,5,0>;
#local A32 = <10,3,7>;
#local A33 = <10,5,0>;

#local B12 = <-6,2,6>;
#local B13 = <-6,2,4>;
#local B22 = <-4,3.5,6>;
#local B23 = <-4,3.5,3>;
#local B32 = <-2,3,7>;
#local B33 = <-2,5,0>;

#local C22 = <18,3,7>;
#local C23 = <18,5,0>;
#local C32 = <23,2,5>;
#local C33 = <23,2,2>;
#local C42 = <23,0,3.5>;
#local C43 = <23,0,3.5>;

#declare asa =
        intersection{
                sphere{<0,0,0>,10}
                box{<2,0,0.5>,<12,12,-0.5>}
                translate <-2,0,0>
                scale <0.8,-2,1>
                texture{tx_amarelo}

        }

#macro corpo(P11,P12,P13,P14,P21,P22,P23,P24,P31,P32,P33,P34,P41,P42,P43,P44)
        union{
                object{
                    retalho(P11,P12,P13,P14,P21,P22,P23,P24,P31,P32,P33,P34,P41,P42,P43,P44,0.0001,tx_verde,tx_amarelo)
                }
        }
#end

#macro aviao(A22,A23,A32,A33,B12,B13,B22,B23,B32,B33,C22,C23,C32,C33,C42,C43)
        union{

        #local A21=<A22.x,0,A22.z>;
        #local A24=<A23.x,0,A23.z>;
        #local A31=<A32.x,0,A32.z>;
        #local A34=<A33.x,0,A33.z>;

        #local B21=<B22.x,0,B22.z>;
        #local B24=<B23.x,0,B23.z>;
        #local B31=<B32.x,0,B32.z>;
        #local B34=<B33.x,0,B33.z>;
        #local B11=<B12.x,0,B12.z>;
        #local B14=<B13.x,0,B13.z>;

        #local C41=<C42.x,0,C42.z>;
        #local C44=<C43.x,0,C43.z>;
        #local C21=<C22.x,0,C22.z>;
        #local C24=<C23.x,0,C23.z>;
        #local C31=<C32.x,0,C32.z>;
        #local C34=<C33.x,0,C33.z>;

        #local A41=(A31+C21)/2;
        #local A42=(A32+C22)/2;
        #local A43=(A33+C23)/2;
        #local A44=(A34+C24)/2;
        #local C11=A41;
        #local C12=A42;
        #local C13=A43;
        #local C14=A44;

                object{corpo(C11,C12,C13,C14,C21,C22,C23,C24,C31,C32,C33,C34,C41,C42,C43,C44)}
                object{corpo(C11,C12,C13,C14,C21,C22,C23,C24,C31,C32,C33,C34,C41,C42,C43,C44) scale <1,-1,1>}

        #local A11=(A21+B31)/2;
        #local A12=(A22+B32)/2;
        #local A13=(A23+B33)/2;
        #local A14=(A24+B34)/2;
        #local B41=A11;
        #local B42=A12;
        #local B43=A13;
        #local B44=A14;

                object{corpo(B11,B12,B13,B14,B21,B22,B23,B24,B31,B32,B33,B34,B41,B42,B43,B44) }
                object{corpo(B11,B12,B13,B14,B21,B22,B23,B24,B31,B32,B33,B34,B41,B42,B43,B44) scale -1*y}

                object{corpo(A11,A12,A13,A14,A21,A22,A23,A24,A31,A32,A33,A34,A41,A42,A43,A44)}
                object{corpo(A11,A12,A13,A14,A21,A22,A23,A24,A31,A32,A33,A34,A41,A42,A43,A44) scale -1*y}

        object { asa translate <4,-2,3.5>  }
        object { asa translate <4,-2,3.5> scale <1,-1,1> }
        object { asa scale <0.3,0.3,0.3> translate <-5.7,-1,5.5>}
        object { asa scale <0.3,0.3,0.3> translate <-5.7,-1,5.5> scale <1,-1,1> }
        object { asa scale <0.3,0.3,0.3> rotate -90*x  translate <-5.7,0,6> }

        }

#end

#macro deformar(P)

        #local cons = -0.2*sin(pi*P.y/29);
        <P.x*2,
         P.y*0.5,
         P.z*cons
        >
#end

#macro deformar2(P)

        #local cons = 0.8*sin(pi*P.y/29);
        <P.x*cons,
         P.y*0.5,
         P.z*2
        >

#end

#macro aviao_deformado(A22,A23,A32,A33,B12,B13,B22,B23,B32,B33,C22,C23,C32,C33,C42,C43,d1,d2)
        union{

        #local D22 = A22 + deformar(A22)*d1 +deformar2(A22)*d2;
        #local D23 = A23 + deformar(A23)*d1 +deformar2(A23)*d2;
        #local D32 = A32 + deformar(A32)*d1 +deformar2(A32)*d2;
        #local D33 = A33 + deformar(A33)*d1 +deformar2(A33)*d2;

        #local E12 = B12 + deformar(B12)*d1 +deformar2(B12)*d2;
        #local E13 = B13 + deformar(B13)*d1 +deformar2(B13)*d2;
        #local E22 = B22 + deformar(B22)*d1 +deformar2(B22)*d2;
        #local E23 = B23 + deformar(B23)*d1 +deformar2(B23)*d2;
        #local E32 = B32 + deformar(B32)*d1 +deformar2(B32)*d2;
        #local E33 = B33 + deformar(B33)*d1 +deformar2(B33)*d2;

        #local F22 = C22 + deformar(C22)*d1 +deformar2(C22)*d2;
        #local F23 = C23 + deformar(C23)*d1 +deformar2(C23)*d2;
        #local F32 = C32 + deformar(C32)*d1 +deformar2(C32)*d2;
        #local F33 = C33 + deformar(C33)*d1 +deformar2(C33)*d2;
        #local F42 = C42 + deformar(C42)*d1 +deformar2(C42)*d2;
        #local F43 = C43 + deformar(C43)*d1 +deformar2(C43)*d2;

        object {
                 aviao(D22,D23,D32,D33,E12,E13,E22,E23,E32,E33,F22,F23,F32,F33,F42,F43)
        }

        }
#end

#include "retalho.inc"

union{

        object { aviao_deformado(A22,A23,A32,A33,B12,B13,B22,B23,B32,B33,C22,C23,C32,C33,C42,C43,0.6,0) translate <0,-10,-8> }

        object { aviao_deformado(A22,A23,A32,A33,B12,B13,B22,B23,B32,B33,C22,C23,C32,C33,C42,C43,0,0.3) translate <0,10,8>}

}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 80.0;
#declare dir_camera = <10,0,5>;
#declare dist_camera = 80.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)