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

// Camera position

#declare campos = < +440, -280, -080 >  // location
#declare camaim = < 0000, 0000, -003 >  // initial aim point

// Critical times for camera motion:

#declare camt0 =  0.0000  // start of animation
#declare camt1 =  7.9335  // camera focus starts moving
#declare camt2 =  9.4335  // camera focus gets to linear speed
#declare camt3 = 14.0000  // end of animation

#if (simt < camt1)
  #declare camlook = camaim
#else
#if (simt < camt2)
  #declare theta = (simt - camt1)/(camt2 - camt1)
  #declare ateht = 1 - theta
  #declare b0 = ateht*ateht*ateht
  #declare b1 = 3*ateht*ateht*theta
  #declare b2 = 3*ateht*theta*theta
  #declare b3 = theta*theta*theta
  #declare camlook = 
     b0 * camaim + 
     b1 * camaim + 
     b2 * camaim + 
     b3 * ( camaim + < +001, +040, -018 > )
#else
  #declare theta = (simt - camt2)/(camt3 - camt2)
  #declare ateht = 1 - theta
  #declare b0 = ateht*ateht*ateht
  #declare b1 = 3*ateht*ateht*theta
  #declare b2 = 3*ateht*theta*theta
  #declare b3 = theta*theta*theta
  #declare camlook = 
     b0 * ( camaim + < +001, +040, -018 > ) + 
     b1 * ( camaim + < +002, +080, -036 > ) + 
     b2 * ( camaim + < +003, +120, -054 > ) + 
     b3 * ( camaim + < +004, +160, -072 > )
#end
#end

camera {
  location  campos
  direction < -2.00,  00.00, 00.00 >
  up        < 00.00,  00.00, -0.18 >
  right     < 00.00,  +0.24, 00.00 >
  sky       < 00.00,  00.00, -1.00 >
  look_at   camlook
}

// Lights

light_source { 1000*< +1, -2, -1 >  color rgb <0.4, 0.4, 0.4> }
light_source { 1000*< +1, -1, -3 >  color rgb <0.5, 0.5, 0.5> }
light_source { 1000*< +1, +2, -2 >  color rgb <0.6, 0.6, 0.6> }
light_source { 1000*< +1, +3, -1 >  color rgb <0.5, 0.5, 0.5> }

// Floor

#declare floor_texture = texture {
  pigment { 
    hexagon
      rgb <0.27, 0.25, 0.22> + < 0.50, 0.60, 0.55 >,
      rgb <0.30, 0.28, 0.25> + < 0.50, 0.60, 0.55 >,
      rgb <0.26, 0.24, 0.21> + < 0.50, 0.60, 0.55 >
  }
  finish { ambient 0.1 diffuse 0.9 }
  rotate <90,0,0>
  scale 5.0
}

#declare post_texture = texture {
  pigment { rgb <0.26, 0.24, 0.21> + < 0.40, 0.50, 0.45 > }
  finish { ambient 0.1 diffuse 0.9 }
}

plane{<0,0,-1>, -14 texture { floor_texture } }

#declare post = 
  cylinder {
    < 0, 0, -025>, < 0, 0, +025>, 1
    texture{ post_texture }
  }

#declare dome =
  sphere {
    < 0, 0, +17 >, 15
    texture{ post_texture }
  }

object{ post translate < -250, +100, +05> }
object{ post translate < -250, +160, -03> }
object{ post translate < -250, +200, -04> }
object{ post translate < -270, +250, -03> }
object{ post translate < -250, +300, +02> }
object{ post translate < -370, +250, +03> }

object{ post translate < -255, +120, +01> }
object{ post translate < -250, +170, -08> }
object{ post translate < -247, +225, +04> }
object{ post translate < -250, +260, +02> }
object{ post translate < -250, +290, -05> }
object{ post translate < -347, +225, +04> }

object{ dome translate < -270, +150, 0> }
object{ dome translate < -210, +180, 0> }
object{ dome translate < -240, +220, 0> }

// Background

sky_sphere {
  pigment {
    gradient z
    color_map {
      [ 0.5  color SkyBlue ]
      [ 1.0  color MidnightBlue ]
    }
    scale 2
    translate -1*z
  }
}

//  sphere {
//    <0, 0, 0>, 100000
//    pigment {SkyBlue}
//    finish {Luminous}
//    hollow
//  }