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

#include "eixos.inc"

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

#declare tx_fosca2 =
  texture{
    pigment{ color rgb < 0.70, 0.20, 0.30 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_fosca3 =
  texture{
    pigment{ color rgb < 0.30, 0.50, 0.40 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_fosca4 =
  texture{
    pigment{ color rgb < 0.10, 0.10, 0.40 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare cadeira =
        union{
                box{<0,0,0>, <-0.2, 0.2, 0.1> texture{tx_fosca}}
                box{<-0.2,0,0>, <-0.3, 0.2, 0.3> texture{tx_fosca}}
        }

#declare roleta = seed(315);

#declare degrau =  box{<0,0,0>, <-0.3, 0.2, 0.2> texture{tx_fosca3}}

#declare cabeca = sphere { <0, 0, 0.2>, 0.08 }

#declare corpo = cone{ <0, 0, 0>, 0.1, <0, 0, 0.2>, 0.05 }

#macro pessoa(id)
        union{
                object{cabeca
                        texture{tx_fosca}
                }
                object{corpo
                        #if(id < 0.45)
                           texture{tx_fosca4}
                        #else
                           texture{tx_fosca2}
                        #end
                }
        }
#end

#macro fileira(n)
        #declare i=0;
        union{
        #while(i < n)
                union{
                        object{degrau translate<0, (0.2*i), 0> scale<1,1,1+j*1>}
                        #if(rand(roleta) < 0.80)
                                object{pessoa(rand(roleta)) translate<-0.1, 0.1+(0.2*i), 0.3+0.2*j>}
                        #end
                        object{cadeira translate<0, (0.2*i), 0.2+0.2*j>}
                }
                #declare i = i + 1;
        #end
        }
#end

#macro secao(l, c)
        arqui(l, c)
#end

#macro arqui(m, n)
        #declare j=0;
        union{
        #while(j < m)
                object{fileira(n) translate<-0.2*j, 0, 0> }
                #declare j = j+1;
        #end
        }
#end

plane {
    z, -0.01
    texture{tx_xadrez}
}

object{ eixos(3.00) }

union{
        object{secao(6,4)}
        object{secao(6,4) translate<0, 4*0.2+0.2,0>}
        object{secao(3,4) rotate <0,0,180> translate<1.4, 4*0.2+0.2,0>}
        object{secao(3,4) rotate <0,0,180> translate<1.4, 8*0.2+0.4,0>}
        object{secao(4,3) rotate <0,0,90> translate<3*0.2, 0, 0>}
        object{secao(4,3) rotate <0,0,90> translate<0.2 + 6*0.2, 0, 0>}
        object{secao(3,3) rotate <0,0,-90> translate<0, 0.15*6*2, 0>}
        object{secao(3,3) rotate <0,0,-90> translate<0.8, 0.15*6*2, 0>}
}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 6.0;
#declare dir_camera = < 1.00, 7.00, 4.00 >;
#declare dist_camera = 16.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)