// Persistence of Vision Ray Tracer Scene Description File
// File: .pov
// Desc:
// Date:
// Auth:

// ==== Standard POV-Ray Includes ====
#include "colors.inc"	  // Standard Color definitions
#include "textures.inc"	  // Standard Texture definitions
#include "functions.inc"  // internal functions usable in user defined functions
#include "math.inc"
#include "mrg_misc3.inc"

#declare rope_texture=     texture {
  pigment {          // (---surface color---)
    marble           // some pattern
    color_map {      // color map
      [0.1 color Sienna]
      [0.5 color Goldenrod]
      [0.7 color Tan]
      [0.95 color Goldenrod]
    }
    turbulence 0.75   // some turbulence
    scale <1,3,1>/15    // transformations
  }
  normal {           // (---surface bumpiness---)
    marble 0.8       // some pattern (and intensity)
    turbulence 0.75   // some turbulence
    scale <1,3,1>/15   // transformations
  }/* */
  finish {           // (---surface finish---)
    ambient 0.2
    specular 0.6     // shiny
  }
}

#declare camera_scale=10; 
//background{Blue}
camera {
    location camera_scale*<0,0, -12>+.3*y
    look_at  <-.0, .3, 0>
    angle 10/camera_scale
}
global_settings {
  assumed_gamma 1.0
  ambient_light rgb <1, 1, 1>
}
// wave specific delcarations
#declare vv=3.5;
#declare L=1;
#declare A=.2;
//pulse shape declarations

#declare lclock=clock+.0;
//#declare transitor=function(tt,tt0,dtt) { .5*(1-cos(min(max(tt-tt0,0),dtt)/dtt*pi))}
#declare pulse1 = function(xx){trans((-xx-1.5)/.2)-trans((-xx-1.9)/.2)}
#declare pulse2 = function(xx){trans((-xx-1.5)/.2)-trans((-xx-1.7)/.4)}

/**/

#declare x_function = function(xx) {xx }
#declare y_function = function(xx) {A*pulse1(xx-vv*lclock)}
#declare y_function2 = function(xx) {A*pulse2(-xx-vv*lclock)}
#declare y_function3 = function(xx) {y_function(xx)+y_function2(xx)}
#declare z_function = function(xx) {0 }

#declare s_start=-1.5;
#declare s_end=1.5;
#declare s_nseg=200;
#declare cyl_width=.01;

/* 
modified  parametric curve:
parm_curve(x_function,y_function,zfunction,s_start,s_end,s_nseg,cyl_width
y ( z assumed const) is ftn of x  and we want the texture to just move up and down
*/
                                                                       
#declare s_count=1;                                                  
#declare s_ds=(s_end-s_start)/(s_nseg);
#declare temp_v1=<x_function(s_start),y_function(s_start) ,z_function(s_start)>;
#declare lcurve=0;
#declare curve_obj= union{
        #while (s_count <= s_nseg)                                                  
                #declare s_this=s_start+s_count*s_ds;
                #declare temp_v2=<x_function(s_this),y_function(s_this) ,z_function(s_this)>;

                #declare dv=temp_v2-temp_v1;
                #declare dl=vlength(dv);
                 union{
                    cylinder{(temp_v1.x)*x,temp_v2.x*x, cyl_width}           
                    sphere{(temp_v1.x)*x, .99*cyl_width}           
                    texture {
                         rope_texture
                    }
                    translate -(temp_v1.x)*x
                    scale <dl/(dv.x),1,1> //stretch segment to neccessary length
                    rotate z*degrees(atan2(dv.y,dv.x))
                    translate +temp_v1.x
                }
                #declare temp_v1=temp_v2;
                #declare s_count=s_count+1;
        #end
}
object{curve_obj translate y*.6}


        //second string
        
                /* 
        generic parametric curve:
        parm_curve(x_function,y_function,zfunction,s_start,s_end,s_nseg,cyl_width
        */
                                                                       
#declare s_count=1;                                                  
#declare s_ds=(s_end-s_start)/(s_nseg);
#declare temp_v1=<x_function(s_start),y_function2(s_start) ,z_function(s_start)>;
#declare lcurve=0;
#declare curve_obj= union{
        #while (s_count <= s_nseg)                                                  
                #declare s_this=s_start+s_count*s_ds;
                #declare temp_v2=<x_function(s_this),y_function2(s_this) ,z_function(s_this)>;
                #declare dv=temp_v2-temp_v1;
                #declare dl=vlength(dv);
                #declare lcurve=lcurve+dl;
                 union{
                    cylinder{(temp_v1.x)*x,temp_v2.x*x, cyl_width}           
                    sphere{(temp_v1.x)*x, .99*cyl_width}           
                    texture {
                         rope_texture
                         translate x*1+z
                    }
                    translate -(temp_v1.x)*x
                    scale <dl/(dv.x),1,1> //stretch segment to neccessary length
                    rotate z*degrees(atan2(dv.y,dv.x))
                    translate +temp_v1.x
                }
                #declare temp_v1=temp_v2;
                #declare s_count=s_count+1;
        #end
}
object{curve_obj translate y*.3}
        //third string
        
                /* 
        generic parametric curve:
        parm_curve(x_function,y_function,zfunction,s_start,s_end,s_nseg,cyl_width
        */
                                                                       
#declare s_count=1;                                                  
#declare s_ds=(s_end-s_start)/(s_nseg);
#declare temp_v1=<x_function(s_start),y_function3(s_start) ,z_function(s_start)>;
#declare lcurve=0;
#declare curve_obj= union{
        #while (s_count <= s_nseg)                                                  
                #declare s_this=s_start+s_count*s_ds;
                #declare temp_v2=<x_function(s_this),y_function3(s_this) ,z_function(s_this)>;
                #declare dv=temp_v2-temp_v1;
                #declare dl=vlength(dv);
                 union{
                    cylinder{(temp_v1.x)*x,temp_v2.x*x, cyl_width}           
                    sphere{(temp_v1.x)*x, .99*cyl_width}           
                    texture {
                         rope_texture
                         translate -x*1-z
                    }
                    translate -(temp_v1.x)*x
                    scale <dl/(dv.x),1,1> //stretch segment to neccessary length
                    rotate z*degrees(atan2(dv.y,dv.x))
                    translate +temp_v1.x
                }
                #declare temp_v1=temp_v2;
                #declare s_count=s_count+1;
        #end
}
object{curve_obj translate -y*.2}





// create a regular point light source
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate <-20, 40, -20>
}

// An area light (creates soft shadows)
// WARNING: This special light can significantly slow down rendering times!
/*light_source {
  0*x                 // light's position (translated below)
  color rgb 1.0       // light's color
  area_light
  <2.5, 0, 0> <0, 2.5, 0> // lights spread out across this distance (x * z)
  8, 8                // total number of lights in grid (4x*4z = 16 lights)
  adaptive 0          // 0,1,2,3...
  jitter              // adds random softening of light
  circular            // make the shape of the light circular
  orient              // orient light
  translate <40, 80, -40>   // <x y z> position of light
}

plane {   //grassy plane
     y, -3*A
     texture {
     pigment { color rgbt Green }
     finish { phong 600  ambient .1 diffuse .2}
     }    
}

background{color rgb <.15,.15,.3>*1.5}
*/

box { -.0025*y+.50*(x+z)+.3*z, +0*y-.51*(x+z)     
     pigment {
          brick color rgbt <.1,.5,.1,.25> , color rgbt <.0,.0,.0,1>  
          brick_size <1,1,1>
          mortar .05  
          translate -1*x-.5*z-.04*y
          scale .1
     }
     finish{ambient 1}
     no_shadow no_reflection 
     rotate x*90
     translate .4*y+.01*z
}
