#include "colors.inc"

// ======================================================================
// CÂMERA 

camera {
   sky z
   location  < -12.00, 22.50, 2.50 > // Posição do observador.
   look_at < 0.00, 5.00, 06.00 >     // Para onde a câmera está apontando.
//   location  < 6.00, 22.50, 6.00 > // Posição do observador.
//   look_at < 6.00, 0.00, 06.00 >     // Para onde a câmera está apontando.
} 


// ======================================================================
// FONTES DE LUZ

light_source {
   < 0.00, 12.00, 10.00 >               // Posição da lâmpada.
   color rgb < 1.00, 1.00, 1.00 > // Intensidade e cor da luz.
} 

light_source {
   < 0.00, -12.00, 10.00 >               // Posição da lâmpada.
   color rgb < 1.00, 1.00, 1.00 > // Intensidade e cor da luz.
} 

// ======================================================================
// DESCRIÇÃO DA CENA 

background { color rgb < 0.88, 0.96, 1.00 > }

#declare plano_xy =
    plane {
        < 0, 0, 1 >,
        0
      pigment { checker rgb < 1.00, 1.00, 0.80 >, < 0.10, 0.30, 0.30 > }
    }

#declare bandeira =
   union {
      cylinder {
         < 0.00, 0.00, 0.00 >
         < 0.00, 0.00, 15.00 >
         0.30
         pigment { color rgb < 0.80, 0.80, 0.80 > }
      }

      box {
         < 0.30, -0.05, 10.50 >,
         < 7.80,  0.05, 15.00 >
	 pigment { checker rgb < 0.00, 1.00, 0.00 >, rgb < 1.00, 1.00, 0.00 > }
      }
   }

#declare fome =
   text {
      ttf "arial.ttf"
      "Fome Zero"
      0.15, 0
   }

#declare placa =
   difference {
      box {
         < 0.0, -0.10, 0.00 >,
         < 7.0, -0.20, 5.00 >
      }

      text {
         ttf "arial.ttf"
         "Brasil"
         1.00, 0
         scale < 2.4, 2.3, 2.3 >
         rotate < 90, 0, 0 >
         translate < 0.70, 0, 1.65 >
      }
   }

#declare mastro =
   lathe {
      linear_spline
      22,
      < 0.00, 00.0 >, < 0.30, 00.0 >,
      < 0.30, 04.0 >, < 0.60, 04.0 >,
      < 0.30, 06.0 >, < 0.60, 06.0 >,
      < 0.30, 08.0 >, < 0.60, 08.0 >,
      < 0.30, 10.0 >, < 0.30, 12.0 >,
      < 0.30, 10.0 >, < 0.30, 12.0 >,
      < 0.15, 12.0 >, < 0.15, 13.0 >,
      < 0.30, 13.0 >, < 0.30, 16.0 >,
      < 0.15, 16.0 >, < 0.15, 17.0 >,
      < 0.30, 17.0 >, < 0.30, 19.0 >,
      < 0.00, 19.0 >, < 0.00, 00.0 >
      rotate < 90, 0, 0 >
   }

#declare linhas =
   union {
      box {
         < 0.15, -0.05, 16.25 >,
         < 3.15,  0.05, 16.75 >
      }

      box {
         < 0.15, -0.05, 12.25 >,
         < 3.15,  0.05, 12.75 >
      }
      pigment { color rgb < 1.00, 1.00, 0.00 > }
   }

#declare chegada =
   union {
      object { 
         mastro
         pigment { color rgb < 0.00, 1.00, 0.00 > }
      }

      object { 
         placa
         pigment { color rgb < 0.00, 0.00, 1.00 > }
         translate < 3.15, 0.00, 12.00 >
      }

      object { 
         mastro
         pigment { color rgb < 0.00, 1.00, 0.00 > }
         translate < 13.00, 0.00, 0.00 >
      }

      object { linhas }
      object { linhas translate < 10.00, 0, 0 >}

   }

#declare bandeirabrasil =
    prism {
        2, 3, 10,
        <1.0, 1.0>, <6.0, 1.0>, <6.0, 4.0>, <1.0, 4.0>, <1.0, 1.0 >
        <3.5, 1.5>, <5.5, 2.5>, <3.5, 3.5>, <1.5, 2.5>, <3.5, 1.5>
    }

union {
   object { plano_xy }

   object { 
      bandeira
      scale < 0.60, 0.60, 0.60 >
      rotate < 0, 25, 0>
      rotate < 0, 0, sin(3 * pi * clock) * 30>
   }

   object { chegada }

   object {
      bandeirabrasil
      rotate < 0, 0, 45>
      translate < 14, 0, -1 >
      pigment { color rgb < clock, 1.00, 0.00 > }
   }

   #if (clock > 0.60)

      #declare clk = (clock - 0.60) / (1 - 0.60);

      object { 
         fome
         pigment { color rgb < 1.00, 0.00, 0.00 > }
         scale < 2.3, 2.3, 2.3 >
         rotate < 90, 0, 0 >

         rotate < 0, 0, (1 - clk) * 30 + clk * 5 >
         translate < (1 - clk) * (-12) + clk * 3,
                     (1 - clk) * 13.5 + clk * (-6),
                     0 >
      }
   #end
}