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

background { color Black }

camera {
    //location 1.4*<-25, 5, -22>
    //right 0.60*x up 0.60*y
    //look_at <0,0.5,-6>
    #if (clock=1)
    location<10,3,-40>
    look_at <10,3,3.2>
    #else
    //location <20*clock,12*clock+10,-(25*clock+50)>
    location <20*0.5,-2,-(25*0.5+80)>
    //location<0,9,-15>
    look_at <0,18,0>
    #end
  
 }

light_source { 5*<10,5,-15> color White }
light_source { 5*<10,5,-15> color White }
//light_source { 10*<50,75,75> color 0.5*White }
//light_source { <0,60,-10> color White }
//light_source { 10*<-15, 8, 12> color 1.4*Pink }
//light_source { 10*<-10, 10, -20> color 1.4*White  }

#declare cor_espelho = Grey;
#declare MetalT = 
	texture {
		finish {
			ambient 0.05 diffuse 0.9
			//reflection cor_espelho
			specular 0.20 roughness 0.05
			}
		pigment {rgb cor_espelho}
		}	

#declare laranja =
          union {
	  	sphere { <0,0.6,0> 0.3}
		pigment{Yellow}
	  
	  }

#declare carne =
          union {
	  	cylinder { <0,0,0.4>, <0,0.5,0.4> 0.5}
		pigment{Yellow}
	  
	  }
#declare prato =
union {
difference{
	cone { <0,0,0>,
     		2,
     	      <0,0.7,0>,
	        2.2
        }
	cone {<0,0,0>,
     		1.8,
     	      <0,0.7,0>,
	        2.0}
	}
	cylinder{<0,0,0>, <0,0.3,0>,2}
	difference{
		cylinder{<0,0.7,0>, <0,0.9,0>,2.4}
		cylinder{<0,0,0>, <0,6,0>,2.2}
	}
	texture{MetalT}

}


#declare corMacacao = 
  texture {
    pigment { Blue }
    finish { diffuse 0.7 specular 0.1 roughness 0.015 ambient 0.1 }
  }
#declare corPele = 
  texture {
    pigment {Flesh }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tenis = 
  texture {
    pigment {White }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }    
  
#declare tablado =
union{
   box{
      <-5,-10,-3>
      <5,-3,3>      
   }  
   box{
      <-10,-10,-3>
      <-5,-6,3>      
   }  
   box{
      <5,-10,-3>
      <10,-6,3>      
   }  
   pigment{White}
   }

plane {
  y, -10.0
  texture { White_Wood } 
}

#declare vidro =
union{
difference {
difference {
	difference {
        
	 sphere { <0, 9.6, 0> 2.05 }
         box {<-2,7.2,-2> <2,9,2>  }         
	
	}
	box {<-2,9.8,-2> <2,12,2>  }         
	}
	box {<-2,7.2,0.5> <2,12,5>  } 
	}
	pigment{White}
}
#declare capacete =
union{
	difference {
        sphere { <0, 9.6, 0> 2 }        
        box {<-2,7.2,-2> <2,8.5,2>  }	
	}
	object{vidro}
	pigment{Yellow}
}

#declare pescoco =
union{
        sphere { <0, 7, 0> 0.7 }
        sphere { <0, 8, 0> 0.7 }
        cylinder { <0,7,0>, <0,8,0>,0.7 }
	texture{corPele}
}

#declare tronco =
     union {
        sphere { <0, 6, 0> 2.0 }
        sphere { <0, 0, 0> 2.0 }
        cylinder { <0,0,0>, <0,6,0>,2 }
	
	object{pescoco}
	
        texture { corMacacao  }
    }
                

#declare braco =
     union { 
        sphere { <0,0,0>, 1.0 }          
        cylinder { <0,0,0>, <0,-3, 0>, 1.0}
        cylinder { <0,-3,0>, < 2, -6, 4>, 0.8}
        sphere { <0,-3,0>, 1.0 }    
        // a mao
        union {
           sphere { <2,-6,4>, 0.8 pigment {Flesh } }
        }
        
        texture {corMacacao}
     }
   

          
#declare canela=
    union {
       cylinder { <0,0,0>, <0,-5,0>, 1.0 }  // canela

       union {                              // o pe
         sphere { <0,-5,0> 1 }
         cylinder {<0,-5,0>, <0,-5, -1>, 1.0 }
         sphere { <0,-5,-1>, 1 }
         texture {tenis}
       }
       texture {corMacacao}	
    }




#declare perna_esquerda =
    union {                               
       sphere { <0,0,0>, 1.3 }
       cylinder { <0,0,0>, <0,-4,0>, 1.3 }  // coxa
       sphere { <0,-4,0>, 1.3 }
       object { canela translate <0,-4,0>}     
       texture { corMacacao }
    } 


#declare perna_direita =
    union {                               
       sphere { <0,0,0>, 1.3 }
       cylinder { <0,0,0>, <0,-4,0>, 1.3 }  // coxa
       sphere { <0,-4,0>, 1.3 }
       object { canela  translate <0,-4,0>}     
       texture { corMacacao }
    }

    
     

#declare macaco =
  union {
     object{capacete}
     object { tronco }
     object { perna_esquerda  translate <1.5,0,0> }   // perna  
     object { perna_direita translate <1.5,0,0> scale <-1,1,1> }  // perna  
     object {
     	object { braco rotate <0,100,0> rotate <0,0,-25>   rotate 100*x*clock translate <-2, 6, 0> }  
	
	}              // braco direito
     object { braco rotate <0,100,0> rotate <0,0,-25> scale <-1,1,1>  rotate 100*x*clock translate <2,6,0> }  // braco esquerdo                 
  }
  #declare imgname = "logo.gif";
  #declare logo =  
object {
  
  box {<0,-10,-3><20,10,-3.5>}
  pigment {
              image_map{gif imgname }
	   
              scale<14,14,14> 
            //  translate<0,-1.4,0> 
	    
               }
	       //translate<105,20,0> 
        }        

	
	#declare fome =
	text {
	ttf "latinwd.ttf"
	"CHEGADA"
	0.15,0
	pigment{White}
	}
	
#declare oq =	
	 lathe {

    linear_spline

    6,

    <0,0>, <1,1>, <3,2>, <2,3>, <2,4>, <0,5.5>

    pigment { Gold }

    finish {

      ambient .3

      phong .75

    }
     scale <3,3,3>

  } 

  
#declare ladoFora =
    prism {

    conic_sweep

    linear_spline

    0, // height 1

    1, // height 2

    5, // the number of points making up the shape...

    <4,4>,<-4,4>,<-4,-4>,<4,-4>,<4,4>

    rotate <180, 0, 0>

    translate <0, 1, 0>
    scale <20, 80, 1>
    translate -10*y
    translate -10*x

    //pigment { gradient y scale .2 }
pigment {DMFWood4 scale 2}
  }    
#declare ladoDentro=
//box {<-30,-10,-10><10,40,10>}
sphere { <-10,-10,0> 40}

#declare chegada = 
  difference {
  object{ladoFora}
  
 	object{ladoDentro}
	
  
  }

  
    
    
  
  
// a cena 
union {
	#if (clock=1)
	object{logo}	
	#else
	object {macaco translate 7*y}
	object{prato translate <0,5,-6> translate<0,12*clock,0>}
	object{tablado}
	object{oq translate <0,40,-4>}
	object{chegada translate 10*x}
	object{fome scale <6,8,6> translate<0,0,0>  translate <-30,32,-2> }
	#end
}