// Ivan Francisco Coutinho Costa
// RA 001833
// MC930 - TP 10 - Rebimboca da parafuseta
// Last edited on 2003-06-28 03:23:15 by stolfi
// Data 24/04/2003


#include "colors.inc"

#declare andar_z = clock * -32;
#declare olhar_z = andar_z;

#declare ctr = <0,-5,0>;
camera {
    location ctr + 2.5 * <-5 ,1, -20>
    right 0.8*x  up 0.6*y  sky y
    look_at ctr
 }

light_source { 50*<-10, 20, -50> color 1.5*White }
light_source { 50*<+10, 20, -50> color 0.9*White  }
light_source { 50*<+2,   5, -50> color 0.4*Pink  }

background { color Gray80 }

#include "textures.inc"

plane {
  y, -20.0
  texture { White_Wood scale 5 } 
}

#declare cor_cristal= Gray;
#declare tx_cristal=
    texture {
       finish {
          ambient 0.1 diffuse 0.1
          reflection 0.25
          specular 1 roughness 0.001
       }
       pigment { color cor_cristal filter 0.95 }
    }


#declare combustor_piloto =
     union {
        cylinder { <0, 1, 0>, <0,6,0>, .2 
          pigment { checker color Yellow, color Orange 
            scale <0.5,50,0.5> translate 25*y
          }
        }
        cylinder { <0, 0, 0>, <0,1,0>, 1.3 
          pigment { checker color Blue, color Cyan 
            scale <0.5,50,0.5> translate 25*y
          }
        }
        // pigment { Brown  } // irrelevante --stolfi
    }
                
#declare bloco_rotativo = 
    union {
       difference {
          cylinder { <0, 0, 0>, <0,8,0>, 2  }
          cylinder { <0, 1, 0>, <0,8,0>, 1.5  }
          texture { tx_cristal }
          interior { ior 6.0 }
      }
      cylinder { <0,0,0>, <0,-5,0>, .4 
        pigment { 
          checker color Black, Orange
          scale <0.5,50,0.5> translate 25*y
        }
      }
      cylinder { <-2,1,0>, <-2.5,1,0>, .5 pigment { color Red } }    // a rebimboca eh um botao vermelho !!!!!
   }
    
                 
#declare mancal_inferior = 
    difference {
        box { <0,0,0>,<6,6,6>  }    
        cylinder { <3, 2, 3>, <3,7,3>, .5 }
        pigment { color Red } 
   }


//valores iniciais
#declare x_comb = 0;
#declare y_comb = 0;
#declare x_bloc = 10;
#declare y_bloc = -10;
#declare x_manc = -10;
#declare y_manc = -10;
#declare ang=0;

// movimentos

// encaixar combustor com bloco rotativo

#if (clock<=0.125)   // combustor vai para o x do bloco 
   #declare x_comb=clock*40;
#end
#if (clock>0.125 & clock<=0.250)  // combustor desce
   #declare x_comb=x_bloc;
   #declare y_comb=(clock)*-40;
#end 

//todas as pecas para o meio da tela
#if (clock>0.250 & clock<=0.5)
     #declare time = clock - 0.250;
     #declare x_comb= 10 - time*40;  // vai 0
     #declare x_bloc= 10 - time*40;  // vai 0
     #declare x_manc= -10 +time *20;      // vai 0 

     #declare y_comb= -10 + time*40;  // vai 0
     #declare y_bloc= -10 +time*40;   // vai 0
     #declare y_manc= -10 -time*20;    // vai -15
#end

//acoplamento
#if (clock>0.5) 
    #declare time=clock-0.5;
    #declare x_comb=0;
    #declare x_bloc=0;
    #declare x_manc=0;
    #declare y_comb=0-time*18;
    #declare y_bloc=0-time*18;
    #declare y_manc=-15; 
    #declare ang=time*720;
#end

// a cena 
object { combustor_piloto rotate <0,ang,0> translate <x_comb,y_comb,0>}
object { bloco_rotativo rotate <0,ang,0> translate <x_bloc,y_bloc,0>}
object { mancal_inferior translate <-3,0,-3> translate <x_manc,y_manc,0>}