// Tubular Bells
// )C( 8/1994 Christian Perle
// changes 9/1994 by Joerg-Ch. Knochen

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

camera {
  location  <0, 0, -4>
  direction <0, 0, 2.5>
  up        <0, 1, 0>
  right     <4/3, 0, 0>
  look_at   <0, 0, 2>
}

light_source { <30, 30, -30> color White }
light_source { <-20, 40, -5> color White }

// ingenious cloud texture by Jussi Kantola
#declare Sky_Top = 100

#declare JKClouds = texture {
  pigment {
    bozo
    turbulence 0.5
    octaves 3
    lambda 6
    color_map {
      [0.0 0.1 color SkyBlue color SkyBlue]
      [0.70 color rgb <4/5, 4/5, 5/6>]
      [1.0 color White]
    }
  }
  finish { ambient 1 diffuse 0 }
  scale 1/6
}

// clouds...
sphere {
  <0, 0, 0>, 1
  texture { JKClouds }
  rotate 90*y  // different part of the sky
  scale <Sky_Top*10, Sky_Top, Sky_Top*10>
}

#declare Radius = .3 // tube radius
#declare Winkel = 5  // bending angle

#declare Wedge1 = intersection {
  plane { z, 0 }
  plane { z, 0 rotate (180+145)*y }
}

#declare Wedge2 = intersection {
  plane { z, 0 rotate 79.8*y}
  plane { z, 0 rotate (-100+20.2)*y }
}

// torus segment (small)
#declare Torusseg = intersection {
  torus { 1, Radius }
  object { Wedge1 }
  bounded_by { cylinder { <0, -Radius, 0>, <0, Radius, 0>, 1+Radius } }
}

#declare Bigradius = 4.7587705

// torus segment (big)
#declare BigTorusseg = intersection {
  torus { Bigradius, Radius }
  object { Wedge2 }
  texture { Silver3 }
  bounded_by { cylinder { <0, -Radius, 0>, <0, Radius, 0>, Bigradius+Radius } }
  translate <0,0,4.6712818>
}

// tube piece
#declare Tube = difference {
  cylinder {
    <-.5, 0, 0>, <.5, 0, 0>, Radius
    texture { Silver3 }
  }
  cylinder {
    <-.51, 0, 0>, <.51, 0, 0>, Radius*.8
    pigment { Gray05 }
    finish { SilverFinish }
  }
}

// Tubular Bells (Mike Oldfield)

#declare Leftarm = union {
  object {
    Torusseg
    rotate -225*y
    texture { Silver3 }
  }
  object {
    Tube
    scale <4.5,1,1>
    translate <-2.25, 0, 1>
    rotate -135*y
  }
  translate <-1,0,-1>
  rotate x*-Winkel
}

#declare Rightarm = object {
  Leftarm
  translate <1,0,1>
  rotate z*180
  translate <1,0,-1>
}

#declare TBells = union {
  object { BigTorusseg }
  object { Leftarm }
  object { Rightarm }
  translate <0, 0, 2.45>
}

object {
  TBells
  scale .38
  rotate -23*x
  translate 1*z
}

// green meadow...
plane {
  y, -6
  pigment {
    bozo
    color_map {
      [0 color red .3 green .7 blue .1]
      [1 color red .4 green .6 blue .2]
    }
  }
  finish { ambient .25 }
}