// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2010-03-04 15:44:01 by stolfi

// ======================================================================
// CORES E TEXTURAS

#declare TEXT="POV-Ray"

#declare FONT="arial.ttf"


#include "colors.inc"
#include "woods.inc"
#include "metals.inc"
#include "golds.inc"

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

#declare tx_vidro = 
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish{ diffuse 0.3 reflection 0.5 ambient 0.4 specular 0.25 roughness 0.05 }
  }

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.80 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_verde = 
  texture{
    pigment{ color rgb < 0.10, 0.90, 0.10 > }
    finish{ diffuse 0.9 ambient 0.5 }
  }

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

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

#declare tx_frente = texture
{
  pigment { color rgb <0.0, 1, 0> }
  finish { diffuse 0.9 ambient 0.1 }
}

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

// ======================================================================
// DESCRI��O DA CENA 

#declare raio = 2.000;

// Partes da cena:


#declare chao = 
  box{ <-20,-20,-1>, <+20,+20,0> }

#include "eixos.inc"
#declare roleta = seed(200);

#macro boneco (a, b)
  #declare i = a;
  #declare j = b;
  union {
      sphere { <-j, i + 0.5, j * 0.5 + 2>, 0.3 texture {pigment {color rgb<0.3, 0.9, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-j, i + 0.5, j * 0.5 + 2>, 0, <-j, i + 0.5, -0.6 + j * 0.5 + 2>, 0.3 texture { pigment {color rgb<0.3, 0.3, 0.9>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-j, i + 0.3, j * 0.5 - 0.3 + 2>, 0, <-j, i + 0.3, -0.6 + j * 0.5 - 0.3 + 2>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-j, i + 0.5, j * 0.5 - 0.3 + 2>, 0, <-j, i + 0.5, -0.6 + j * 0.5 - 0.3 + 2>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
      cylinder { <-j, i + 0.1, -0.4 + j * 0.5 + 2>, <-j, (i+1) - 0.1, -0.4 + j * 0.5 + 2>, 0.08 texture { pigment {color rgb <1.00,
 0.80, 0.10>} finish{ diffuse 0.9 ambient 0.5 }} }
  }
#end

#macro boneco2 (k, l)
  #declare m = k;
  #declare n = l;
  union {
      sphere { <-n, m + 0.5, n * 0.5 + 2>, 0.3 texture {pigment {color rgb<0.8, 0.3, 0.1>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-n, m + 0.5, n * 0.5 + 2>, 0, <-n, m + 0.5, -0.6 + n * 0.5 + 2>, 0.3 texture { pigment {color rgb<0.9, 0.7, 0.2>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-n, m + 0.3, n * 0.5 - 0.3 + 2>, 0, <-n, m + 0.3, -0.6 + n * 0.5 - 0.3 + 2>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
      cone { <-n, m + 0.5, n * 0.5 - 0.3 + 2>, 0, <-n, m + 0.5, -0.6 + n * 0.5 - 0.3 + 2>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
      cylinder { <-n, m + 0.1, -0.4 + n * 0.5 + 2>, <-n, (m+1) - 0.1, -0.4 + n * 0.5 + 2>, 0.08 texture { pigment {color rgb <0.00,
 0.80, 0.10>} finish{ diffuse 0.9 ambient 0.5 }} }
  }
#end

#macro Torcedor(a, b)
  #declare i = a;

  union {
  #if (rand(roleta) < 0.33)
    #if (rand(roleta) < 0.7)
      boneco(a, b)
    #else
      boneco2(a, b)
    #end
  #end
  }
#end

#macro Arquibancada(larg, alt)
  union
  {
  #declare i = 0;
  #while (i < larg)
    #declare j = 0;
    #while (j < alt)
      #if (j <= i)
        box { <1.5 - i, 0, j*0.5>, <-0.5 - i, larg, (j+1)*0.5> texture { tx_escada } }
      #end
      object { Torcedor(i, j) translate <1.3, 0.3, 0> }
      object { box { <-j, i + 0, j * 0.5 - 0.2>, <-j+0.3, i + 0.3, -0.6 + j * 0.5 - 0.2> texture { pigment {color rgb<0.0, 1.0, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}} translate <1.2, 0.6, 1.30> }
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
  }
#end

#macro Escada(larg, alt)
  union
  {
  #declare i = 0;
  #while (i < larg)
    #declare j = 0;
    #while (j < alt)
      #if (j <= i)
        box { <2 - i, 0, j*0.5>, <0 - i, 1, (j+1)*0.5> texture { tx_arquibancada } }
      #end
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
  }
#end

#macro Campo(larg, alt, prof)
  union
  {
    box{ <0, 0, 0>, <larg, prof, alt> texture { tx_verde } }
  }
#end

#macro Chao (larg, alt, prof)
  union
  {
    box{ <0, 0, 0>, <larg, prof, alt> texture { tx_marrom } }
  }
#end




//#macro Campo

// Aqui est� a cena, finalmente:



plane { z, 0
   pigment {
      checker color White color Gray90
      scale 1
   }
}
//plane { z, 0.05
//   pigment {
//      checker color White color Gray90 scale .05
//   }
//}


#macro Wall(tx, ty, tz)
  object {
    box { <-0.5, -0.05, -.5>, <.5, 0.05, .5> translate <tx, ty, tz> texture {tx_marrom}}
  }
#end

#macro GreatWall(tx, ty, tz, rx, ry, rz)
  union {
    object { Wall(0, 0, 0) }
    object { Wall(1, 0, 0) }
    object { Wall(2, 0, 0) }
    object { Wall(3, 0, 0) }
    translate <tx, ty, tz>
    rotate <rx, ry, rz>
  }
#end

#macro ParedesExternas()
  union {
    GreatWall(0.5, 0, 0, 0, 0, 0)
    GreatWall(0.5 3.95, 0, 0, 0, 0)
    GreatWall(0.5, 0, 0, 0, 0, 90)
    object {
      GreatWall(0.5, 0, 0, 0, 0, 90)
      translate <3.95, 0, 0>
    }
  }
#end

#macro BaseTexto(tx, ty)
  union {
    object { cone { <0, 0, 0>, 0.07, <0, 0, 0.4>, 0 texture { tx_verde } } }
    scale 1.5
    translate <tx, ty, 0>
  }
#end


#macro Texto (txt, dx, sc)
  union {
    text{
       ttf FONT txt, .1, 0
       texture { pigment { ForestGreen } finish { reflection 0.1 ambient 0.5 }  }
       translate <0, 0, 0.05>
       scale 0.5
    }
    box { <0, 0, -.05>, <dx, 0.5, .05> translate <0, 0, 0> texture {tx_escada}}
    scale sc
  }
#end

#macro TextAux (txt, dx, sc, sc2)
  union {
    object {Texto(txt, dx, sc)}
    rotate <90, 0, 90>
    translate <0.05, 0, 0>
    scale sc2
  }
#end

#macro TextoEBase(btx, bty, txt, dx, sc, tx, ty, tz, sc2)
  union {
    object { TextAux(txt, dx, sc, sc2) translate <tx, ty, tz> }
    object { BaseTexto(btx, bty) }
  }
#end

#macro Cilindro(altura, raio)
  union {
    object { cylinder { <0, 0, 0>, <0, 0, altura>, raio } texture {tx_vidro} }
  }
#end

#macro Coralx()
  union{
  #declare j = 0;

  #while (j < 5)
    #declare i = 0;
    #while (i < 5)
      #if (j <= i)
        box {<0.6 - i, -0.3, -1.5 + j*0.5>, <-0.6 - i, 3.9, -0.9 + j*0.5> texture { tx_vidro } }
      #end
      #if ((i = 1 & j = 1) | (i = 3 & j = 2))
        sphere { <-j, i*0.9, j*0.5>, 0.3 texture {pigment {color rgb<0.5, 0.5, 0.5>}}}
        cone { <-j, i*0.9, j*0.5>, 0, <-j, i*0.9, -0.6 + j*0.5>, 0.3 texture { pigment {color rgb<0.5, 0.5, 0.5>} }}
        cone { <-j, i * 0.9 - 0.2, j * 0.5 - 0.3>, 0, <-j, i * 0.9 - 0.2, -0.6 + j * 0.5 - 0.3>, 0.1 texture { pigment {color rgb<0.5, 0.5, 0.5>}}}
        cone { <-j, i * 0.9 + 0.2, j * 0.5 - 0.3>, 0, <-j, i * 0.9 + 0.2, -0.6 + j * 0.5 - 0.3>, 0.1 texture { pigment {color rgb<0.5, 0.5, 0.5>}}}
        cylinder { <-j, i * 0.9 - 0.3, -0.4 + j * 0.5>, <-j, (i+1)*0.9 - 0.6, -0.4 + j * 0.5>, 0.08 texture { pigment {color rgb <0.5 0.5, 0.5>}} }
      #else
        sphere { <-j, i * 0.9, j * 0.5>, 0.3 texture {pigment {color rgb<0.3, 0.9, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
        cone { <-j, i * 0.9, j * 0.5>, 0, <-j, i * 0.9, -0.6 + j * 0.5>, 0.3 texture { pigment {color rgb<0.3, 0.3, 0.9>} finish{ diffuse 0.9 ambient 0.5 }}}
        cone { <-j, i * 0.9 - 0.2, j * 0.5 - 0.3>, 0, <-j, i * 0.9 - 0.2, -0.6 + j * 0.5 - 0.3>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
        cone { <-j, i * 0.9 + 0.2, j * 0.5 - 0.3>, 0, <-j, i * 0.9 + 0.2, -0.6 + j * 0.5 - 0.3>, 0.1 texture { pigment {color rgb<0.9, 0.3, 0.3>} finish{ diffuse 0.9 ambient 0.5 }}}
        cylinder { <-j, i * 0.9 - 0.3, -0.4 + j * 0.5>, <-j, (i+1)*0.9 - 0.6, -0.4 + j * 0.5>, 0.08 texture { pigment {color rgb <1.00, 0.80, 0.10>} finish{ diffuse 0.9 ambient 0.5 }} }
      #end
      #declare i = i+1;
    #end
    #declare j = j + 1;
  #end
  translate <0, 0, 1.8>
  }
  
#end

union{
  object{ eixos(3.00) }
  union {
    object {
      Coralx() scale 0.15 rotate <0, 0, -45> translate <1, 2.8, 1>
    }
    object {BaseTexto(0.5, 2.2) scale 1.5}
    object {TextoEBase(0, 0, "O Coral", 1.9, 1, 0, -0.5, 0.5, 0.5) rotate <0, 0, -45> translate <1, 2.5, 0> }
  }
  union {
    object {Cilindro(1.5, 0.5) translate <0.5, 0.5, 0> scale 0.9}
    object { TextoEBase(0, 0, "A Cupula", 2.1, 1, 0, -0.6, 0.5, 0.5) rotate <0, 0, 45> translate <1, 1, 0>  }
  }
  union {
    object { ParedesExternas() }
    object { ParedesExternas() translate <0, 0, 1>}
  }
  //object{ chao texture{ tx_verde } }
}


#include "camlight.inc"
#declare centro_cena = < 2.0, 2.00, 0.00 >;
#declare raio_cena = 6.0;
#declare dir_camera = < 1.50, .25, 1.50 >;
#declare dist_camera = 6.0;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)