// MC930 - Trabalho prĂ¡tico 7 - 2s2003
// Fernando Kenji Iwai

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


background{ SummerSky }

camera {
  location  <  0, 100, 0+40*clock >
  right     <  1.0, 0.00, 0.00 >
  up        <  0.00, 0.00, 1.00 >
  sky       <  0.00, 1.00, 0.00 >
  look_at   <  0, 0,50+40*clock>
} 

light_source {
  1*< 30.00, 50.00, 50.00 >
  color rgb 0.5*< 1,1,1 >
}


light_source {
  1*< 0.00, 0.00, 50.00 >
  color rgb 0.5*< 1,1,1 >
}


light_source {
  1*< 100.00, 100.00, 50.00 >
  color rgb 0.5*< 1,1,1 >
}


light_source {
  1*< 0, 100.00, 50.00 >
  color rgb 0.5*< 1,1,1 >
}


light_source {
  1*< 100.00, 0.00, 50.00 >
  color rgb 0.5*< 1,1,1 >
}

light_source {
  100*< 5.00, 15.00, -15.00 >
  color rgb 1.3*< 1,1,1 >
}

light_source {
  100*< -5.00, 15.00, -20.00 >
  color rgb 1.1*< 1,1,1 >
}

#declare tx1 =
  texture {
    pigment { Pink }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.2 }
  }

#declare i = 1;         //Gera os nos

#declare gerador = seed(1234517);

#declare PI = 3.1415;

#declare deltax = 45*cos(2*PI*clock);
#declare deltaz = 0.0;
	
 #while (i < 7) 
#declare j =1;
#while (j <3)

 #if(j=1)
 #declare clockp = clock;
 #else
 #declare clockp = mod(clock+0.5,1);
 #end

#if(mod(i,2)=0)
#declare  clockp = clock;
#else
#declare  clockp = mod(clock+0.5,1);
#end


#declare segmento_4 = union {
sphere { <0,0,0> , 0.5 }
cone { <0,0,0>, 0.5,<2,0,0>,0.01 }
}

#declare segmento_3 = union {
sphere { <0,0,0> , 0.7 }
cone { <0,0,0>, 0.7,<3,0,0>,0.5 }
object{ segmento_4 
	rotate z*(15*cos(2*PI*clockp)-15)	
        translate <3,0,0>
}
}


#declare segmento_2 = union {
sphere { <0,0,0> , 1 }
cone { <0,0,0>, 1,<5,0,0>,0.7 }
object{ segmento_3 
	rotate z*(17.5*cos(2*PI*clockp)-27.5)
       	translate <5,0,0>
}
}


#declare segmento_1 = union {
sphere { <0,0,0> , 1.5 }
cone { <0,0,0>, 1.5,<8,0,0>,1 }
object{ segmento_2 
	rotate z*(30*cos(2*PI*clockp)-40)
	rotate y*(30*cos(2*PI*clock))
	translate <8,0,0>
	
}
}


#if(j=1)
object{ 
segmento_1

rotate z*(15*cos(2*PI*clockp)+20)

#if(clockp<0.4)
rotate -30*y
#else
#if(clockp<0.6)
rotate y*(-30+(clockp-0.4)*60/0.2)
#else
rotate 30*y
#end 
#end

translate <6,0,6*i+40*clock>
#if(mod(i,2)=0)
pigment{ color Black}
#else
pigment{color Red}
#end

}

#else

object{ 
segmento_1

rotate z*(15*cos(2*PI*clockp)+20)


#if(clockp<0.4)
rotate -30*y
#else
#if(clockp<0.6)
rotate y*(-30+(clockp-0.4)*60/0.2)
#else
rotate 30*y
#end 
#end

translate <6,0,6*i+40*clock>
scale <-1,1,1>
#if(mod(i,2)=0)
pigment{ color Black}
#else
pigment{color Red}
#end

}
#end


#declare j = j + 1;

#end
object{ sphere {<0,0,6*i+40*clock>, 6
#if(mod(i,2)=0)
pigment{ color Black}
#else
pigment{color Red}
#end
}}

  #declare i=i+1;
#end



plane {
 y, -10
pigment { checker color White, color Blue , scale 20 }
 }