// Last edited on 2009-07-23 14:06:35 by stolfilocal
// Processed by remove-cam-lights

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

#declare raio = 2.000;

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

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

#declare cinza = 
  texture {
    pigment {color rgb < 0.80, 0.80, 0.80 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare marrom =
  texture {
    pigment {color rgb < 0.90, 0.65, 0.20 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 } 
  }

#declare azul = 
  texture {
    pigment { color rgb < 0.10, 0.00, 0.90 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

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

#declare verde = 
  texture {
    pigment { color rgb < 0.10, 0.85, 0.10 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare vermelho = 
  texture {
    pigment { color rgb < 0.90, 0.05, 0.05 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare o = 1/4;

#declare azeitona =
  difference {
    box {
      < 1, -1, -1 >, <-1, 1, 1> 
      texture { amarelo }
    }
    box {
      < 1.1,-0.9,-0.9>, <-1.1,0.9,0.9>
      texture { vermelho }
    }
  }

#declare muro =
  box {
    <1,2,-1> <-1,10,1>
    texture { azul }
  }

#macro recursivo (n)

  #if(n = 0)
    object {
      azeitona       
    }
 
  #else
    union {
      object {
        recursivo (n-1)
        rotate < 45, 0, 0>
        scale <o, o, o>
      }
      object {
        azeitona       
        rotate < 45,0,0 >
      }
    }
  #end
#end

#macro castelo (q)

  #if(q = 0)

    #declare m = 4;

    union{

      #while(m > 0)

        union{
          object { azeitona scale <2,2,2> }
          object { recursivo(5) }
          object { muro scale <0,0,2> }
          translate <0,0,4*m>

        }

        #declare m = m - 1;
      #end
    }

  #else
    union{
      object {
        castelo (q-1)
        translate <7,-5,0>
        scale <2*o, 2*o, 2*o>
      }

      object {
        castelo (q-1)
        rotate < 0, 0, 180>
        translate <-5,7,0>
        scale <2*o, 2*o, 2*o>
      }
    
      object {
        castelo (q-1)
        rotate < 0, 0, 90>
        translate <7,7,0>
        scale <2*o, 2*o, 2*o>
      }
      object {
        castelo (q-1)
        rotate < 0, 0, -90>
        translate <-5,-5,0>
        scale <2*o, 2*o, 2*o>
      }
    }
  #end
#end

object { castelo(1) scale <3,3,0> translate <-1,-0.8,0> }

#declare N = 3;

object { castelo(N) scale<0,0,5> }

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

#include "camlight.inc"
camlight(<0.00,0.00,10.00>,<10,7,5>,40.0,z,1.0)