// Ivan Francisco Coutinho Costa
// RA 001833
// MC930 - TP 8 - Instrumento Musical
// Data 15/05/2003


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

background { color HuntersGreen }

camera {
    location <20, 0, -55>
    look_at <20,0,0>
 }

light_source { <0, 20, -40> color White }

plane {
  y, -5
  pigment { color Grey } 
}
  

#declare tick_corpo = 4
#declare corpo=
   prism {
    cubic_spline
    0, // z inf
    tick_corpo, // z sup
    7, // num pontos
    < 0,16 >,  //1  controle
    < 20,  8>,  //2 
    <0,  16>,  //3
    <6,8>
    < 0,  0>,  //4
    < 20,  8>,  //5  # fecha
    <0,  0>   //6  controle
    pigment { color Red }
  }


#declare braco=
   lathe {
      quadratic_spline
      7,
      <0,0>, <3,0>, <5,19>, <8,20>, <5,21>, <1,40>, <0,40>
      pigment { Blue }
      finish {
        ambient .3
        phong .75
      }
   }


#declare tarracha= 
 lathe {
      linear_spline
      7,
      <0,0>, <2.5, 2.5>, <1.0, 3.5>, <2.0, 5.0>, <0.7, 6.5>, <1.8, 7.5>, <0.0, 10>
      pigment { Green }
      finish {
        ambient .3
        phong .75
      }
   }

#declare sc_braco = 1/3
#declare sc_tarr = 1/1.5
#declare xbra = 19.5
#declare len_bra = 40 * sc_braco
#declare xtar = xbra+ len_bra

#declare instrumento=
    difference {
      union {
        object { corpo rotate <90,0,0>  translate <0,8,0> translate <0,0,-tick_corpo/2>}
        object { braco rotate <0,0,-90> scale <sc_braco, sc_braco, sc_braco> translate <xbra,0,0> }
        object { tarracha  rotate <0,0,-90> scale <sc_tarr, sc_tarr, sc_tarr> scale <1/2,0,0> translate <xtar,0,0> }
     }
     cylinder { <0,0,-10>, <0,0,10>, 2.5 translate <10,0,0> } 
    }

// a cena
object { instrumento translate <0, 0, 0> translate <0, 10, 0> }