// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2010-03-04 15:44:01 by stolfi

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

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

#declare marrom = 
  texture{
    pigment{ color rgb < 1, 0.51, 0.23 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare verde = 
  texture{
    pigment{ color rgb < 0, 1, 0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare solo = 
  texture{
    pigment{ color rgb < 0, 0.8, 0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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


// ======================================================================
// DESCRICO DA CENA 

#include "eixos.inc"

#declare bola = 
  sphere {
    < 0, 0, 0 >,
    0.2
  }
  
#declare chao = 
  box{ 
		<-20,-20,-1>, <+20,+20,0> 
	}

#macro interpola_4 (t0, v0, v1, v2, v3, t1, tt)
	
	#local v01 = interpola(t0, v0, t1, v1, tt);
	
	#local v12 = interpola(t0, v1, t1, v2, tt);
	
	#local v23 = interpola(t0, v2, t1, v3, tt);
	
	#local v02 = interpola(t0, v01, t1, v12, tt);
	
	#local v13 = interpola(t0, v12, t1, v23, tt);
	
	#local v03 = interpola(t0, v02, t1, v13, tt);
	
	v03
#end

#macro interpola(f0, v0, f1, v1, f)
	#local ss = (f - f0)/(f1 - f0);
	#local rr = 1 - ss;
	(rr * v0 + ss * v1)
#end

#macro grafico(x0, y0, y1, y2, y3, x3, N)
	union {
		#local inc = (x3 - x0) / N;
		#local i = 0;
		#while(i < N)
			#local xx = x0 + inc * i;
			#local yy = interpola_4(x0, y0, y1, y2, y3, x3, xx);
			#local i = i + 1;
			object { bola translate <0, 0, xx> translate yy }
		#end
	}
#end


// ======================================================================

#local y00 = <4,2>;
#local y01 = <2,5>;
#local y02 = <6,2>;

#local y11 = <7,2>;
#local y12 = <2,5>;

#local y21 = <8,2>;
#local y22 = <2,2>;

#local y31 = <2,6>;
#local y32 = <7,2>;
#local y33 = <2,9>;

union {
	object { grafico(1,   y00, y01, y02, (y02+y11)/2,   3, 400) texture{ marrom }}
	object { grafico(3,   (y02+y11)/2, y11, y12, (y12+y21)/2,   5, 400) texture{ verde }}
	object { grafico(5,   (y12+y21)/2, y21, y22, (y22+y31)/2,   7, 400) texture{ marrom }}
	object { grafico(7,   (y22+y31)/2, y31, y32, y33,   9, 400) texture{ verde }}
	//object { chao texture { tx_xadrez }}
	object{ eixos(3.00) }
}

#include "camlight.inc"
#declare centro_cena = < 5.00, 0.00, 0.00 >;
#declare raio_cena = 20.0;
#declare dir_camera = < 0, -1, 0>;
#declare dist_camera = 80.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)