#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 = 13.9335  // 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.5, 0.5, 0.5> }
light_source { 1000*< +1, -1, -4 >  color rgb <0.5, 0.5, 0.5> }
light_source { 1000*< -1, -2, -1 >  color rgb <0.5, 0.5, 0.5> }
light_source { 1000*< +1, +3, -1 >  color rgb <0.5, 0.5, 0.5> }

// Floor

#declare floor_texture = texture {
  pigment { 
    hexagon
      rgb <0.07, 0.33, 0.05> filter 0,
      rgb <0.12, 0.28, 0.05> filter 0,
      rgb <0.07, 0.28, 0.10> filter 0
  }
  finish { ambient 0.1 diffuse 0.9 }
  rotate <90,0,0>
  scale 5.0
}

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

// 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
//  }