// LAB 08 - Algoritmos dão em Árvore
// ======================================================================
// CÂMERA 

// ======================================================================
// CÂMERA 



camera {
  location  <  35.00, -15.00, 8.00 >  // Posição do observador.
  right     -0.75*x                // Largura RELATIVA da imagem.
  up        1.00*y                 // Altura RELATIVA da imagem.      
  sky       z                   // Qual direção é "para cima"?
  look_at   <  -3.00, 0.00, 0.00 >  // Para onde a câmera está apontando.
} 
// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

// ======================================================================
// FONTES DE LUZ

light_source {
  10 * < +50.0, -30.0, +50.0 >              // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < +50.0, 10.0, +10.0 >             // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

light_source {
  10 * < -50.0, 0.0, 0.0 >             // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

// ======================================================================
// DESCRIÇÃO DA CENA 

background{ color rgb < 0.8, 0.85, 0.9 > }

#include "colors.inc"
#include "woods.inc"
#include "stones.inc"
#include "metals.inc"
#include "textures.inc"

#declare eixos =
   union {
      cylinder {
        <-100,0,0>,
	<100,0,0>,
	0.3
	pigment {Blue}
	}
       cylinder {
        <0,-100,0>,
	<0,100,0>,
	0.3
	pigment {Red}
	}
      cylinder {
        <0,0,-100>,
	<0,0,100>,
	0.3
	pigment {Green}
	}
}

//object { eixos }

#declare aco =
  texture {
    pigment { Gray }
    finish {
      ambient 0.05 diffuse 0.25
      reflection Gray
      specular 0.2 roughness 0.05
      }
    }

#declare ouro =
  texture {
    pigment { Yellow }
    finish {
      ambient 0.05 diffuse 0.3
      reflection Gold
      specular 0.2 roughness 0.05
      }
    }

#declare cristal =
  texture{
    finish{
      ambient 0.1 diffuse 0.1 reflection 0.25
      specular 1 roughness 0.001
    }
    pigment {color Blue filter 1}
  }


#macro arvore(n,xx,yy,zz)

#local i = 0;
  #if(n>0)
    union{
      sphere{
        <xx,yy,zz>,
        1
        texture { Tinny_Brass }
	//pigment { Blue }
      }
      #if (n>1)
        //#declare i = i + 1;
        cylinder{
          <xx,yy,zz>,
	  <xx+0.5*n*n,yy,zz-4>,
	  0.2
          texture { T_Wood16 }
        }
        cylinder{
          <xx,yy,zz>,
	  <xx-0.5*n*n,yy,zz-4>,
	  0.2
          texture { T_Wood16 }
        }
        cylinder{
          <xx,yy,zz>,
	  <xx,yy+0.5*n*n,zz-4>,
	  0.2
	  texture { T_Wood16 }
        }
        cylinder{
          <xx,yy,zz>,
	  <xx,yy-0.5*n*n,zz-4>,
	  0.2
	  texture { T_Wood16 }
        }
      #end
      arvore(n-1,xx+0.5*n*n,yy,zz-4)
      arvore(n-1,xx-0.5*n*n,yy,zz-4)
      arvore(n-1,xx,yy+0.5*n*n,zz-4)
      arvore(n-1,xx,yy-0.5*n*n,zz-4)
          }
  #end
     
#end

arvore(4,0,0,10)

plane { z, -10
  texture { T_Grnt9 }
}