/*

Physics at Play
Designed by: Draugnar

*/

#version 3.0
global_settings { assumed_gamma 2.2 }
global_settings { max_intersections 64 }
global_settings { max_trace_level 100 }

//#include "debug.inc"
//#include "atmos.inc"
//#include "chars.inc"
#include "colors.inc"
#include "finish.inc"
#include "glass.inc"
#include "metals.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "shapesq.inc"
#include "skies.inc"
//#include "stars.inc"
#include "stones.inc"
#include "stones2.inc"
#include "textures.inc"

//#default { finish { specular 0.15 roughness 0.025 ambient 0.25 } }
#default { finish {Glossy} }

//#include "woods.inc"

// Camera Placement
camera {
   location  <0, 0,  -10>
   direction <0, 0, 2.25>
   right x*4/3
//   right x*2.35
   look_at   <0, 0,    1>
}

// Lighting Placement
light_source {
  0*x
  color rgb < .65, .65,1.00>
  area_light x*40,z*10,5,2
  translate <1000, 1000, -1250>
  jitter
}

background {SummerSky}

sky_sphere {
  S_Cloud5
  rotate <0,35,0>
}

sphere {
  <0,-50000,4>
  49998
  texture {
    pigment {
      image_map {
        png "woodparq.png"
      }
    }
    finish {
      roughness .001
      phong 0.8
      brilliance 0.9
    }
    rotate x*90
    rotate y*30
    scale <12,12,12>
  }
}

#declare EquationTexture=texture{Vicks_Bottle_Glass}

#declare HangerTexture=texture {T_Gold_5E}

#declare Hangers=
union {
  cylinder {
    <-0.5,-1.5,5.5>
    <-0.5,-1.8,5.5>
    .0625
    texture {HangerTexture}
  }
  sphere {<-0.5,-1.5,5.5>,.0625 texture {HangerTexture}}
  cylinder {
    <-0.5,-1.5,5.5>
    < 0.0, 2.0,5.0>
    .0625
    texture {HangerTexture}
  }
  sphere {< 0.0, 2.0,5.0>,.0625 texture {HangerTexture}}
  difference {
    cylinder {
      < 0.0, 2.0,5.0>
      < 0.0, 2.0,3.0>
      .0625
      texture {HangerTexture}
    }
    cylinder {<0.0,2.0,4.8>,<0.0,2.05,4.8>,.03125 texture {pigment{Black} finish{Dull}}}
    cylinder {<0.0,2.0,3.2>,<0.0,2.05,3.2>,.03125 texture {pigment{Black} finish{Dull}}}
  }
  sphere {<0.0, 2.0,3.0>,.0625 texture {HangerTexture}}
  cylinder {
    < 0.0, 2.0,3.0>
    < 0.5,-1.5,2.5>
    .0625
    texture {HangerTexture}
  }
  sphere {< 0.5,-1.5,2.5>,.0625 texture {HangerTexture}}
  cylinder {
    < 0.5,-1.5,2.5>
    < 0.5,-1.8,2.5>
    .0625
    texture {HangerTexture}
  }
}

#declare BallAndString =
object {
  union {
    difference {
      sphere {
        <0,-2.5,4.0>
        .5
        texture {T_Chrome_5E}
//        texture {Glass3}
      }
      cylinder {
        <0,-2.5,5.0>
        <0,-2.5,3.0>
        .04
        texture {pigment{Black} finish{Dull}}
//        texture {Glass3}
      }
    }
    union {
      cylinder {
        <0,-2.48,3.48>
        <0, 0.00,3.20>
        .02
      }
      cylinder {
        <0,-2.48,4.52>
        <0, 0.00,4.80>
        .02
      }
      cylinder {
        <0,-2.48,3.48>
        <0,-2.48,4.52>
        .02
      }
      sphere {<0,-2.48,3.48>,.02}
      sphere {<0,-2.48,4.52>,.02}
      texture {pigment{color rgbf <1,1,1,.7>} finish{Glossy}}
    }
  }
}

#declare StringAttachment =
object {
  union {
    sphere {<0,0,4.8>,.02}
    sphere {<0,0,3.2>,.02}
    cylinder {<0,0,4.8>,<0,-.05,4.8>,.02}
    cylinder {<0,0,3.2>,<0,-.05,3.2>,.02}
    texture {pigment{color rgbf <1,1,1,.7>} finish{Glossy}}
  }
}

#declare BallAndStringNoTexture =
object {
  union {
    difference {
      sphere {
        <0,-2.5,4.0>
        .5
      }
      cylinder {
        <0,-2.5,5.0>
        <0,-2.5,3.0>
        .000004
      }
      texture{pigment{Clear} finish{Dull roughness .05}}
    }
    union {
      cylinder {
        <0,-2.48,3.48>
        <0, 0.00,3.20>
        .0000005
      }
      cylinder {
        <0,-2.48,4.52>
        <0, 0.00,4.80>
        .0000005
      }
      texture{pigment{Clear}}
    }
  }
}

union {

  difference {
    box {
      <-3.2,-1.6,1.8>
      < 3.2,-2.0,6.2>
    }
    cylinder {
      <-3.3,-1.6,1.8>
      < 3.3,-1.6,1.8>
      .2
    }
    cylinder {
      <-3.3,-1.6,6.2>
      < 3.3,-1.6,6.2>
      .2
    }
    cylinder {
      <-3.2,-1.6,1.7>
      <-3.2,-1.6,6.3>
      .2
    }
    cylinder {
      < 3.2,-1.6,1.7>
      < 3.2,-1.6,6.3>
      .2
    }

    #declare XOff = -2.5
    #while (XOff < 2.0)
      cylinder {
        <XOff,-1.59,5.5>
        <XOff,-1.80,5.5>
        .075
        texture {pigment{Black} finish{Dull}}
      }
      #declare XOff=XOff+1.0
    #end

    #declare XOff = -1.5
    #while (XOff < 3.0)
      cylinder {
        <XOff,-1.59,2.5>
        <XOff,-1.80,2.5>
        .075
        texture {pigment{Black} finish{Dull}}
      }
      #declare XOff=XOff+1.0
    #end

    texture {
      T_Stone15
      scale 5
    }
  }

  union {
    #declare XOff = -2.0
    #while (XOff < 2.5)
      object {Hangers translate x*XOff}
      #declare XOff=XOff+1
    #end
  }

  #declare XOff= -2.0
  #while (XOff < 1.5)
    object {
      BallAndString
      translate <XOff,1.9375,0>
    }
    object {
      StringAttachment
      translate <XOff,1.9375,0>
    }
    #declare XOff=XOff+1
  #end

  object {
    BallAndString
    rotate z*15
    translate < 2.0,1.9375,0>
  }
  object {
    StringAttachment
    rotate z*15
    translate < 2.0,1.9375,0>
  }
  object {
    BallAndStringNoTexture
    rotate z*25
    translate < 2.0,1.9375,0>
  }

  object {
    BallAndStringNoTexture
    rotate z*35
    translate < 2.0,1.9375,0>
  }

// Rotates the whole toy
  rotate -y*20
}

text {
  ttf "mod20.TTF",
  "T, the period of a pendulum.",
  1, 0
  texture {EquationTexture}
  translate -x*19.5
  scale <.15,.15,.025>
  translate y*2
//  translate x*2.5
}

text {
  ttf "mod20.TTF",
  "R, the arc radius of a simple pendulum.",
  1, 0
  texture {EquationTexture}
  translate -x*19.5
  scale <.15,.15,.025>
  translate y*1.85
//  translate x*2.5
}

text {
  ttf "mod20.TTF",
  "d, the distance from the knife point",
  1, 0
  texture {EquationTexture}
  translate -x*19.5
  scale <.15,.15,.025>
  translate y*1.7
//  translate x*2.5
}

text {
  ttf "mod20.TTF",
  "to the center of the sphere.",
  1, 0
  texture {EquationTexture}
  translate -x*18.5
  scale <.15,.15,.025>
  translate y*1.55
//  translate x*2.5
}

text {
  ttf "mod20.TTF",
  "r, the radius of the sphere.",
  1, 0
  texture {EquationTexture}
  translate -x*19.5
  scale <.15,.15,.025>
  translate y*1.4
//  translate x*2.5
}

text {
  ttf "mod20.TTF",
  "g, acceleration of gravity.",
  1, 0
  texture {EquationTexture}
  translate -x*19.5
  scale <.15,.15,.025>
  translate y*1.25
//  translate x*2.5
}

union {
  text {
    ttf "mod20.TTF",
    "T",
    1, 0
    translate -y*.5
  }

  text {
    ttf "mod20.TTF",
    "=",
    1, 0
    scale y*1.5
    translate x*.9
    translate -y*.5
  }

  text {
    ttf "mod20.TTF",
    "2",
    1, 0
    translate x*1.5
    translate -y*.5
  }

  text {
    ttf "greek.TTF",
    "B",
    1, 0
    translate x*2.25
    translate -y*.5
  }

  text {
    ttf "math.TTF",
    "r",
    1, 0
    translate x*3
    translate -y*1.145
  }

  text {
    ttf "mod20.TTF",
    "R",
    1, 0
    translate x*3.875
  }

  text {
    ttf "mod20.TTF",
    "g",
    1, 0
    translate x*4.000
    translate -y*1
  }

  text {
    ttf "mod20.TTF",
    "__",
    1, 0
    translate x*3.625
  }

  text {
    ttf "mod20.TTF",
    "_",
    1, 0
    translate x*3.75
  }

  text {
    ttf "mod20.TTF",
    "__",
    1, 0
    translate x*3.5
    translate y*1
  }

  text {
    ttf "mod20.TTF",
    "__",
    1, 0
    translate x*3.625
    translate y*1
  }

  scale <.15,.15,.025>
  translate y*2
  translate x*2
  texture {EquationTexture}
}

union {

  text {
    ttf "mod20.TTF",
    "For a spherical pendulum suspended",
    1, 0
    translate -x*10.5
    translate y*2
  }

  text {
    ttf "mod20.TTF",
    "on a line of negligible mass:",
    1, 0
    translate -x*7
    translate y*1
  }

  text {
    ttf "mod20.TTF",
    "R",
    1, 0
    translate -y*.5
  }

  text {
    ttf "mod20.TTF",
    "=",
    1, 0
    scale y*1.5
    translate -y*.5
    translate x*.975
  }

  text {
    ttf "mod20.TTF",
    "d+",
    1, 0
    translate -y*.5
    translate x*1.675
  }

  text {
    ttf "mod20.TTF",
    "2r",
    1, 0
    translate x*2.875
  }

  text {
    ttf "mod20.TTF",
    "2",
    1, 0
    scale x*1/2
    scale y*1/2
    translate x*3.75
    translate y*1/3
  }

  text {
    ttf "mod20.TTF",
    "__",
    1, 0
    translate x*2.75
  }

  text {
    ttf "mod20.TTF",
    "_",
    1, 0
    translate x*2.875
  }

  text {
    ttf "mod20.TTF",
    "5d",
    1, 0
    translate x*3
    translate -y*1
  }

  scale <.15,.15,.025>
  translate y*1.25
  translate x*2.125
  texture {EquationTexture}
}

union {
  text {
    ttf "mod20.TTF",
    "g",
    1, 0
  }

  text {
    ttf "mod20.TTF",
    "=",
    1, 0
    scale y*1.5
    translate x*.65
  }

  text {
    ttf "mod20.TTF",
    "32 ft/sec",
    1, 0
    translate x*1.250
  }

  text {
    ttf "mod20.TTF",
    "2",
    1, 0
    scale x*1/2
    scale y*1/2
    translate x*4.625
    translate y*1/3
  }

  scale <.15,.15,.025>
  translate y*.875
  translate x*2
  texture {EquationTexture}
}


text {
  ttf "c:\windows\fonts\Quenya.TTF",
  "26Es5#6",
  1, 0
  texture {
    T_Gold_5E
  }
  translate -x*2
  scale <.15,.15,.10>
  translate -y*1.875
  translate x*2.5
}
