/*
  Antialias=on

Antialias_Threshold=0.1
Antialias_Depth=3
Input_File_Name=resolver.pov
Output_File_Name=d2

Initial_Frame=1
Final_Frame=200
Initial_Clock=0
Final_Clock=1

Cyclic_Animation=off
Pause_when_Done=off
*/

#version 3.5;

#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"

global_settings {
  assumed_gamma 1.0
  ambient_light 1
}

// ----------------------------------------
background{color rgb <0,0,.00>}
camera {
  location  <3, 2.5, -5>*5.3
//  direction 1.5*z
//  right     x*image_width/image_height
  look_at   <1, 1.5,  -4>
  angle 16
}
#declare myfn= frame_number+0148;   //local frame count 
#declare lclock=myfn/200;

#declare fname=concat("b_hf",str(myfn,-4,0), ".tga");
#declare screen_dist=4;

//#declare fname="b_hf0000.tga";
union{
     height_field {
       tga    fname     
       smooth         
       texture {
         pigment {
          gradient y
           color_map {
             [0.00 color rgb <0.01,0.01,0.01> ]
             [0.33 color rgb <0.33,0.33,.33> ]
             [0.66 color rgb <0.66,.66,0.66> ]
             [1.00 color rgb <1.0,1,1> ]
           }
         scale 1.2
         translate -.001*y
         }
         finish{
           specular 0.0 ambient .9
         }
       }
          translate -(x+z)/2 -.05*y-.05*z
          scale <2,1,2>
          no_shadow no_reflection
     }
     //#declare f2name="b_gs0000.tga";
     #declare f2name=concat("b_gs",str(myfn,-4,0), ".tga");
     
     box{0,1
          texture{
            pigment{   
               image_pattern {tga f2name}
            }
            finish{
                specular 0.0 ambient 1.2
            }

          }     
          scale <2,2,.0125>
          translate -x+z
     }
     translate -1*z
     translate screen_dist*z
}
#declare source_dist=2.0*screen_dist;
#declare screen_dx0=.4;
#declare source_dx0=screen_dx0*source_dist/screen_dist;
cylinder{-source_dist*z-source_dx0*x,screen_dist*z+screen_dx0*x,.015
     translate y
          texture{
               pigment{color rgbt <.125,.0,.0,.8>}
               finish{specular 0.0 ambient 1.2}
     }
               no_shadow

}

cylinder{-source_dist*z+source_dx0*x,screen_dist*z-screen_dx0*x,.015
     translate y
          texture{
               pigment{color rgbt <.125,.0,.0,.8>}
               finish{specular 0.0 ambient 1.2}
     }
               no_shadow

}

sphere{-source_dist*z+source_dx0*x+y,.025
          texture{
               pigment{color rgb 1}
               finish{specular 0.0 ambient 2}
     }
}
sphere{-source_dist*z-source_dx0*x+y,.025
          texture{
               pigment{color rgb 1}
               finish{specular 0.0 ambient 2}
     }
}
#declare rangle=2*degrees(atan2(source_dx0,source_dist));
/*
intersection{
     torus{1.,.0125}
     object{Wedge(rangle)}
     texture{
               pigment{color rgb <.0,.0,.4>}
               finish{specular 0.0 ambient 1.2}
     }
     translate y
     rotate -y*rangle/2
}
intersection{
     torus{3,.0125}
     object{Wedge(rangle)}
     texture{
               pigment{color rgb <.0,.0,.4>}
               finish{specular 0.0 ambient 1.2}
     }
     translate y
     rotate -y*rangle/2
     scale <1,1,-1>
               no_shadow

}
*/
light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-50, 40, -10>
}

intersection{
     sphere{.9*z,1}
     sphere{-.9*z,1}
     pigment{color rgbt <.3,.3,1,.8>}
     finish{specular .5 diffuse .3}
     translate y
}

#declare lmda=(.2+.4*lclock)*1.25;
union{
     #declare amp=.2;
     #declare dwx=.01;
     #declare xnow=-1;
     #declare wavepold=<xnow,amp*sin(2*pi*xnow/lmda),0>;
     #while(xnow<1)
          #declare xnow=xnow+dwx;
          #declare wavepnew=<xnow,amp*sin(2*pi*xnow/lmda),0>;
          cylinder{wavepold,wavepnew,.0125}
          #declare  wavepold=wavepnew;
          
     #end
     pigment{color rgb <.3,.3,.3>*3}
     finish{specular .5 diffuse .6}
     translate (screen_dist-2.2)*z
}
// ----------------------------------------
/*
    #declare iris_rad=.5-.4*lclock; //decreasing aperture

#declare y_pannel_offset=1.5;
#declare irisangle=degrees(asin(iris_rad/y_pannel_offset));
//#declare iris_rad=sin(radians(irisangle));
#declare ipart=box { 0,<14,-18,.05> 
       texture {
          //pigment{color rgb <.1,.1,.1>*2}
          //  finish {  ambient 0.1  diffuse 0.6  specular 0.25 roughness 0.05  metallic .25  }  
         Brushed_Aluminum 
         finish{ambient .05  diffuse .125}
         rotate z*90
       }
       rotate -y*3
       rotate -x*3
       rotate z*irisangle
       translate y_pannel_offset*y
}

union{
     #declare boxextent =1.5*x+1.5*y+.15*z; 
     intersection{
          union{
               #declare icount =0;
               #declare imax=8;
               #declare idang=360/imax;
               #while (icount < imax)
                    object{ipart rotate z*(icount*idang)}
                     
                    #declare icount=icount+1;
               #end      
          }
          box{boxextent*.95,-boxextent*.95}
          scale <1,1,.5>
     }
     
     
     
     
     
     
     difference{
          box{boxextent,-boxextent}
          cylinder{-2*z,2*z,1.25}
          pigment{color rgb <.1,.1,.1,0>*.5}
          finish {  ambient 0.1  diffuse 0.6  specular 0.25 roughness 0.05  metallic .25  }  
          no_shadow
     }
     scale <.5,.5,.3>
translate y-.2*z
}
*/