// Last edited on 2007-07-22 23:38:25 by stolfi
// Processed by remove-cam-lights

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

#declare tinta_red = 
  texture {
    pigment { color rgb < 0.85, 0.0, 0.0 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.2 }
  }

#declare tinta_green = 
  texture {
    pigment { color rgb < 0.00, 0.85, 0.0 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.2 }
  }

#declare tinta_blue = 
  texture {
    pigment { color rgb < 0.00, 0.0, 0.85 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.2 }
  }

#declare tinta_black = 
  texture {
    pigment { color rgb < 0.00, 0.00, 0.00 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.2 }
  }

#declare tinta_white = 
  texture {
    pigment { color rgb < 1.00, 1.00, 1.00 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.2 }
  }
  

#declare peao =
  union {
    cone {
      < 0.125, 0.125, 0.1 >, 0.10,
      < 0.125, 0.125, 0.4 >, 0
      texture { tinta_red }
    }
    sphere {
      < 0.125, 0.125, 0.4 >, 0.05
      texture { tinta_red }
    }
  }

#declare rei =
  difference {
    union {
      cylinder {
        < 0.125, 0.125, 0.1 >,
        < 0.125, 0.125, 0.3 >,
        0.07
        texture { tinta_blue }
      } 
      cylinder {
        < 0.125, 0.125, 0.3 >,
        < 0.125, 0.125, 0.4 >,
        0.10
        texture { tinta_blue }
      }
      cylinder {
        < 0.125, 0.125, 0.1 >,
        < 0.125, 0.125, 0.15 >,
        0.10
        texture { tinta_blue }
      }
    }
  
    cylinder {
      < 0.125, 0.125, 0.32 >,
      < 0.125, 0.125, 0.42 >,
      0.05
      texture { tinta_blue }
    }
  }

  
#declare torre =
  union{ 
    box {
      < 0.166, 0.083, 0.1 >,
      < 0.083, 0.166, 0.35 >
      texture { tinta_green }
    }

    box {
      < 0.166, 0.083, 0.35 >,
      < 0.138, 0.111, 0.4 >
      texture { tinta_green }
    }

    box {
      < 0.166, 0.138, 0.35 >,
      < 0.138, 0.166, 0.4 >
      texture { tinta_green }
    }

  }

#declare tab_preto = 
  box {
    < 0.25, 0.00, 0.00 >,
    < 0.00, 0.25, 0.10 >
    texture { tinta_black }
  }

#declare tab_branco = 
  box {
    < 0.25, 0.00, 0.00 >,
    < 0.00, 0.25, 0.10 >
    texture { tinta_white }
  }
  

#declare j = 0;
#declare shift_y = 0;
#declare roleta = seed(12345);

union {

  
  #while (j<20)

    #declare i = 0;
    #declare shift_x = 0;

    #while (i<20)

      #if (mod(j,2)=0)
        #if (mod(i,2)=0)
            object { tab_preto 
            translate <shift_x,shift_y ,0>
        }
        #else
            object { tab_branco
            translate <shift_x,shift_y ,0>
        }
        #end
      #else
        #if (mod(i,2)=0)
            object { tab_branco 
            translate <shift_x,shift_y ,0>
        }
        #else
            object { tab_preto
            translate <shift_x,shift_y ,0>
        }
        #end
      #end

      #declare shift_x = shift_x+0.25;
      #declare i = i+1;
    #end

    #declare j = j+1;
    #declare shift_y = shift_y+0.25;

  #end

  #declare j = 0;
  #declare shift_y = 0;
  
  #while (j<20)
    
    #declare i = 0;
    #declare shift_x = 0;
    #while (i<20)
      #declare chance = rand(roleta);

      
      #if( chance < 0.1 )
        object{peao 
          translate <shift_x,shift_y,0>
        }
      #end

      
      #if(( chance > 0.4) & (chance < 0.5 ))
        object{torre 
          translate <shift_x,shift_y,0>
        }
      #end

      
      #if( chance > 0.97 )
        object{rei 
          translate <shift_x,shift_y,0>
        }
      #end
  
      #declare i = i+1;
      #declare shift_x = shift_x+0.25;
    #end

    #declare j = j+1;
    #declare shift_y = shift_y+0.25;
  #end
}

// Original camera parameters:
// #local cam_ctr = <7.00,7.00,-10.00>
// #local cam_vec = (<0.00,0.00,4.00>-<7.00,7.00,-10.00>)
// #local cam_sky = z

#include "camlight.inc"
#local RR = (20 * 0.25)/2;
camlight(<RR,RR,0>,<10,10,10>,7.0,z,1.0)