// MC930 A, S2 2003
// Autor: Leonel Aguilar Gayard
// RA 009103
// Data 04/09/2003
// Tema: Palacio de Cristal

#include "colors.inc"
#include "metals.inc"

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

camera {
  location  <0 , -13, 10>  // Posição do observador.
  // location  <0 , 0, 20>
  // location  <13, 0, 10>
  right     -1.0*x         // Largura RELATIVA da imagem.
  up        0.75*y         // Altura RELATIVA da imagem.      
  sky       z              // Qual direção é "para cima"?
  look_at   < 0, 0, 0 >    // Para onde a câmera está apontando.
} 
// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

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

light_source {
  0.5 * < +30.0, +10.0, +90.0 >                // Posição da lâmpada.
  color rgb 1.3 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  0.5 * < +10.0, -10.0, +10.0 >                // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

light_source {
  0.5 * < 0, -10, 10>                // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

/*
light_source {
  <0,0,-9>
  color rgb 1.0 * <1,1,1>
}

light_source {
  <0, -10, 6>
  color rgb 10 * <1,1,1>
  rotate 270 * z
}
*/
// ======================================================================
// DESCRIÇÃO DA CENA 

#declare raio = 2.000;

#declare tinta_A = 
  texture {
    pigment { color rgb < 0.10, 0.80, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
#declare tinta_B = 
  texture {
    pigment { color rgb < 0.10, 0.80, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_AZUL = 
  texture {
    pigment { color rgb < 0.00, 0.0, 1.00 > }
  }

#declare tinta_VERDE = 
  texture {
    pigment { color rgb < 0.00, 1.0, 0.00 > }
  }

#declare tinta_VERMELHA = 
  texture {
    pigment { color rgb < 1.00, 0.0, 0.00 > }
  }

#declare tinta_AMARELA = 
  texture {
    pigment { color rgb <1, 1, 0> }
  }
  
// ---------------------------------------------------------------------------------
// AQUI TERMINA O ARQUIVO DO PROFESSOR E COMECA O MEU EXERCICIO

#declare logotipo =
object {
    text {
        ttf "latinwd.ttf"
        "Fome Zero"
        0.4, 0
    }
}

#declare cockpit =
// o cockpit
difference {
    cylinder {
        <0,0,0>,
        <5,0,0>,
        1
        pigment { color Yellow }
        // texture { P_Copper1 }
    }
    object {
        box {
            <0,0,0>
            <1,1,1>
            pigment { color Yellow }
        }
        scale 10
        translate <-1,-2,-1>
        rotate -45 * y 
    }
}

#declare aerofolio =
object {
    difference {
        box {
            <0,0,0>
            <1,1,1>
            pigment { color Orange }
        }
        box {
            <0,0,0>
            <1,1,1>
            scale 10
            translate <-1,0,0>
            rotate 45 * x
            pigment { color Orange }
        }
        scale <3,2,1>
    }
}

#declare roda =
union {
    cylinder {
        <0,0,0>
        <0.5,0,0>
        0.75
        pigment { color Black }
    }
    cylinder {
        <-0.11,0,0>
        <0.61,0,0>
        0.50
        pigment { color Grey }
    }
}

#declare capacete = 
object {
    sphere {
        <0,0,0>,
        0.45
        pigment { color Blue }
    }
}
    

#declare carro = 
union {
    object { cockpit scale <1.5, 1, 1> }
    object { aerofolio  rotate -90 * z translate <5.65, 1.5, 1> }
    object { roda rotate 90 * z translate <1.75, -1.5, -0.5> }
    object { roda rotate 90 * z translate <6.75, -1.5, -0.5> }
    object { roda rotate 90 * z translate <1.75, 1, -0.5> }
    object { roda rotate 90 * z translate <6.75, 1, -0.5> }
    object { capacete translate <4.75,0,0.90> }
    translate <-4.85,0,0>
}

#declare podio =
    prism {
        linear_sweep
        linear_spline
        0,
        1,
        7,
        <3,5>, <-3,5>, <-5,0>, <-3,-5>, <3, -5>, <5,0>, <3,5>
        pigment { checker color Grey, color Black }
    }

    /* 
#declare pilastra =
lathe {
    linear_spline
    8,
    <0,14> <1, 12> <0.5, 10> <1, 8> <0.5, 6> <1,4> <0.5,2> <0,0>
    pigment { Blue }
}
     */

#declare OFFSET0 = 0;
#declare OFFSET1 = 6;
#declare OFFSET2 = 12;
#declare OFFSET3 = 18;

#declare pilastra =
object {
    lathe {
        bezier_spline
        28,
        // <0,14> <1, 12> <0.5, 10> <1, 8> <0.5, 6> <1,4> <0.5,2> <0,0>
        <1,0 + OFFSET0> <0,1 + OFFSET0> <0,2 + OFFSET0> <1,3 + OFFSET0>
        <1,3 + OFFSET0> <2,4 + OFFSET0> <2,5 + OFFSET0> <1,6 + OFFSET0>
        
        <1,0 + OFFSET1> <0,1 + OFFSET1> <0,2 + OFFSET1> <1,3 + OFFSET1>
        <1,3 + OFFSET1> <2,4 + OFFSET1> <2,5 + OFFSET1> <1,6 + OFFSET1>
    
        <1,0 + OFFSET2> <0,1 + OFFSET2> <0,2 + OFFSET2> <1,3 + OFFSET2>
        <1,3 + OFFSET2> <2,4 + OFFSET2> <2,5 + OFFSET2> <1,6 + OFFSET2>
    
        <1,0 + OFFSET3> <0,1 + OFFSET3> <0,2 + OFFSET3> <1,3 + OFFSET3>
        pigment { Blue }
    }
    scale <1, 0.6, 1>
}



  background{ color White }
    
  plane { <0, 0, 1>, -10
    pigment {
      color Green
    }
  }


  object { pilastra rotate 90 * x scale 0.5 translate <-5, -1, -1> }
  object { pilastra rotate 90 * x scale 0.5 translate <5, -1, -1> }

  object { podio rotate 90 * x translate <0,0,-2.5>  scale 1.1 }
  object { carro translate <0, 0, 0> rotate 360 * clock * z }
  
  object { logotipo pigment { color Red } scale <1,2,1> translate <0,-0.5,-0.2> rotate (90 + 360 * clock) * x translate <-4.75, 0, 5>  }