// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2003-09-04 15:25:26 by stolfi

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

camera {
  location  <  35.00, 10.00, 20.00 >  // Posição do observador.
//  location  <  0.00, 50.00, 8.00 >  // Posição do observador.
  right     -1.00*x                // Largura RELATIVA da imagem.
  up        0.75*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual direção é "para cima"?
  look_at   <  0.00, 0.00, -2.00 >  // 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 {
  10 * < +50.0, +30.0, +50.0 >              // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e cor da luz.
} 

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

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

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

#declare cor_coroa = < 1.0, 1.0, 0.0>;



  #declare tinta_A = 
  texture {
    pigment { color rgb < 0.70, 0.80, 0.90 > }
    finish { diffuse 0.5 specular 0.6 roughness 0.05 ambient 0.2 reflection 0.2 }
  }

  #declare tinta_B = 
  texture {
    pigment { color rgb <0, 0.5, 0.9> }
    finish { diffuse 0.1 specular 1 reflection 0.25 
             roughness 0.001 ambient 0.3 }
  }
  
  #declare tinta_C = 
  texture {
    pigment { color rgb <0.6, 0.6, 0.6> }
    finish { diffuse 0.1 specular 0.3  
             roughness 0.001 ambient 0.4 }
  }

  #declare tinta_D = 
  texture {
    pigment { color rgb <0.9, 0.4, 0.0> }
    finish { diffuse 0.1 specular 1 reflection 0.25 
             roughness 0.001 ambient 0.1 }
  }

  #declare tinta_E = 
  texture {
    pigment { color rgb <0.4, 0.9, 0.0> }
    finish { diffuse 0.1 specular 1 reflection 0.25 
             roughness 0.001 ambient 0.1 }
  }

plane { z, -3.6
  texture {
    pigment { checker <.7,.6,0>, <.8,.7,0> }
    finish { ambient 0.1 diffuse 0.9 }
    scale 2.0 
  }
}
 
  #declare caixa_ext =
  box {
    < 4.00,-2.00, -2.50 >, 
    < -4.00, 2.00, 2.50  > 
    texture { tinta_A }
  }

 #declare caixa_int =
  box {
    < 3.70, -1.70, -2.20 >, 
    < -3.70, 1.70, 2.20  > 
    texture { tinta_A }
  }
  

  #declare janelas_laterais = 
    union {
      #declare i = 0;
      #while (i < 3)
	  box { <(2.2*i-3.2), -3, 0> , 
	      <(2.2*i-1.3), 3, 2> 
	      texture { tinta_A }
          }
	  
	  #declare i = i+1;
      #end
    }


  #declare corte = 
     box {
     <1.9, -.3, -.2>,
     <-1.9, .3, .2>
  }

  #declare cortes = 
  union {
    #declare i = 0;
    #while (i < 36)
      #if (mod(i,2) = 0)
        object { corte
            texture { tinta_E }
	    translate<15,0,-3.4>
            rotate 10*i*z
        }
      #else
        object { corte
            texture { tinta_D }
	    translate<15,0,-3.4>
            rotate 10*i*z
        }

      #end
      #declare i = i+1;
    #end
  } 

  #declare rodas = 
    union {
      #declare i = 0;
      #while (i < 4)
	difference{
	  cylinder { <2*i-2.7, -2.2, -2.3>,
		<2*i-2.7, 2.2, -2.3>, 0.7
		texture { tinta_B }
		
  	  }
	  box { <(2*i-3.5), -2.0, -3.1> , 
	      <(2*i-1.9), 2.0, -1.5> 
	      texture { tinta_B }
          }
	
	}  
 	#declare i = i+1;
      #end
    }

#declare engate = 
union {
  cylinder {
    <4, 0, -1.5>,
    <6, 0, -1.5>, .5
    texture {tinta_C}
  }
}

#declare vagao = 
union {
  difference {
    object { caixa_ext }
    object { caixa_int }
    object { janelas_laterais }
    
  }
  object { rodas }
  //object { engate }
}

#declare vagoes = 
union {
  #declare i = 0;
  #while (i < 5)
    #if (i = 0)
      object { vagao
	  translate<0, 15, 0>
	  rotate 35*i*z 
           }
    #else
      union {
      object { vagao
	  translate<0, 15, 0>
	  rotate 35*i*z 
           }
      object { engate
          translate<0, 15, 0>
	  rotate 35*i*z
      }
    }
    #end
    #declare i = i+1;
  #end
}

#declare trilhos =
union {
  lathe {
    linear_spline
    8,
    <16.6,-3>, <16.8,-3>, <17,-3.2>, <17.2,-3.2>, 
    <17.4,-3>, <17.6,-3>, <17.6,-3.5>, <16.6,-3.5>
    texture { tinta_C }
    rotate 90*x
  }
  lathe {
    linear_spline
    8,
    <12.4,-3>, <12.6,-3>, <12.8,-3.2>, <13,-3.2>, 
    <13.2,-3>, <13.4,-3>, <13.4,-3.5>, <12.4,-3.5>
    texture { tinta_C }
    rotate 90*x
  }
}
// Aqui está a cena, finalmente:
union {
  object {cortes}
  object { vagoes }
  object { trilhos }
}