// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2017-05-07 20:10:09 by stolfilocal

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

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

#declare brown_soft_149_111_82 = color rgb < 149/255, 111/255, 82/255 >; 
#declare brown_darker_86_47_31 = color rgb < 86/255, 47/255, 31/255 >;

#declare tx_woodfloor =
  texture{
    pigment{ brown_soft_149_111_82 }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_assento_blocked =
  texture{
    pigment{ color rgb < 255/255, 0/255, 0/255 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_assento_free =
  texture{
    pigment{ color rgb < 0/255, 255/255, 0/255 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

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

#declare chair_height = 5;
#declare chair_width = 3;

#macro assento(is_free)
  // blocked: is_free != 1
  // free:    is_free == 1

  #if (is_free = 1)
    #local which_tx = tx_assento_free;
  #else
    #local which_tx = tx_assento_blocked;
  #end
  
  union{
    //back
    box{<0, 0, chair_height*0.33 - chair_height*0.066>,
        <chair_width, chair_width*0.1, chair_height>
        texture{ which_tx }
    }
    //assento
    box{<0, 0, chair_height*0.33>, 
        <chair_width, chair_width, chair_height*0.33 - chair_height*0.066 >
        texture{ which_tx }
    }
    //left side fill
    box{<0, 0, 0>, 
        <chair_width*0.066, chair_width, chair_height*0.33 - chair_height*0.066>
        texture{ which_tx }
    }
    //right side fill
    box{<chair_width, 0, 0>, 
        <chair_width - chair_width*0.066, chair_width, chair_height*0.33 - chair_height*0.066>
        texture{ which_tx }
    }
  }
#end

#macro auditorio(m, n)
  // m: rows
  // n: seats

  #local at_row = 0;
  #local at_seat = 0;
  #local is_free = 1;

  union{
    #while(at_row < m)
      #local is_free = 1;
      #local at_seat = 0;
      #while(at_seat < n)
        object{ assento(is_free) 
                translate <at_seat*2*chair_width, 
                          at_row*2*chair_height, 
                          0>
        }

        #if (is_free = 1)
          #local is_free = 0;
        #else
          #local is_free = 1;
        #end

        #local at_seat = at_seat + 1;
      #end
      #local at_row = at_row + 1;
    #end
  }
#end

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

#include "eixos.inc"

// Aqui est� a cena, finalmente:

union{
  //object{ eixos(4.00) translate <-6, 0, 0>}

  object{ chao  translate < 0,0,-5 > texture{ tx_woodfloor } }
  object{ auditorio(4,4) translate <-10,-20,-5>}
}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, -1.00 >;
#declare raio_cena = 20.0;
#declare dir_camera = < -3.00, 7.00, 2.00 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)