// José Renato Paulon ra 970904
// Exercicio 7

#include "colors.inc"
#include "textures.inc"
#include "stones.inc"
#include "finish.inc"

  background{White}
  camera {
    angle 10
    location <1, 9, -200>
    look_at <0, 2, 0>
  }
 light_source {<30,30,30> color 1.2*White}
 light_source {<30,30,-30> color 1.2*White}
 light_source {<10,3,-10> color 0.5*White}

  #declare tx_madeira =
  texture {
	pigment {
       	DMFWood4
       	scale 4
        }
      	finish { Shiny } // pre-defined in finish.inc
	}
  #declare cor_metal = <0.2,0.2,0.2>;
  #declare tx_metal=
  texture{
	pigment{ rgb cor_metal}
    	finish{
		ambient 0.05 diffuse 0.05
		reflection cor_metal
		specular 0.20 roughness 0.05
	}

  }

  plane {
	y, -6
    	texture {T_Stone15}
  }

#declare corpo = 
	difference {
          lathe {
	    bezier_spline
	    4,
	    <0,0>,<1,4>,<6,7>,<4,11>
	    pigment { Blue }
	    finish {
	      ambient .3
	      phong .75
	    }
	  }
	  box {
    		<-6, 0,6>,  // Near lower left corner
    		< 0, 12,-6>   // Far upper right corner
	  }
}

#declare cabeca =
	prism {
 	   linear_sweep
 	   cubic_spline
 	   0,  
 	   1,  
 	   18, 
	    <3,-5>, <3,5>, <-5,0>, <3, -5>, <3,5>, <-5,0>, 
 	   <2,-4>, <2,4>, <-4,0>, <2,-4>, <2,4>, <-4,0>,  
	    <1,-3>, <1,3>, <-3,0>, <1, -3>, <1,3>, <-3,0>  
	    pigment { Green }
	    rotate x*90
	    rotate z*180
	    scale <0.3,0.3,0.3>	
 	}
#declare box_aux = 
box {
	<-6, 0,6>,  // Near lower left corner
	< 0, 12,-6>   // Far upper right corner
	texture {tx_madeira}
}

#declare cabo =
  union { 
	difference {
		lathe {
		    bezier_spline
		    8, // the number of points making up the shape ...
		    < 0,0 >, // point#1 (control point... not on curve)
		    < 1,4 >, // point#2  ... THIS POINT ...
		    < 6,7 >, // point#3
		    < 4,11>, // point#4
		    < 0,0 >, // point#5 ... MUST MATCH THIS POINT
		    < 3,4 >  // point#6 (control point... not on curve)
		    < 8,7 >
	 	   < 4,11 >  		  
 	           pigment { Yellow }
	 	 }
		 union {
	 	 	object {box_aux}
		 	object {box_aux translate <7,0,0>}
		 }

	}
	cylinder {<0,1,0> <0,17,0> .5 texture {tx_madeira}}
  }
	
#declare corda = cylinder {<0,0,0> <-3,0,0> .2 pigment {Yellow}}
#declare corda2 = cylinder {<0,1,0> <-4,1,0> .2 pigment {Yellow}}
#declare corda3 = cylinder {<0,2,0> <-5,2,0> .2 pigment {Yellow}}
#declare corda4 = cylinder {<0,3,0> <-5,3,0> .2 pigment {Yellow}}
difference { 
	object{corpo}
	object{corpo translate <-1,0,0>}
	translate <0,-5,0>
	scale <1.2,1.2,1.2>
}
object {corda}
object {corda2}
object {corda3}
object {corda4}
object {cabeca translate <0,13,0>}
object {cabo  rotate y*90 translate <0,-5,0>}