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

//global_settings{radiosity{}}
#declare MediaOn=false;

  #declare Clouds1 = pigment {
      bozo
      turbulence 1
      color_map {
        [0.0 color White filter 1]
        [0.5 color White]
        [1.0 color White filter 1]
      }
    }
  #declare Clouds2 = pigment {
    agate
    turbulence 1
    color_map {
      [0.0 color White filter 1]
      [0.5 color White]
      [1.0 color White filter 1]
      }
    }
  #declare Clouds3 = pigment {
    marble
    turbulence 1
    color_map {
      [0.0 color White filter 1]
      [0.5 color White]
      [1.0 color White filter 1]
    }
  }
  #declare Clouds4 = pigment {
    granite
    turbulence 1
    color_map {
      [0.0 color White filter 1]
      [0.5 color White]
      [1.0 color White filter 1]
    }
  }


  #declare LandArea = texture {
    pigment {
      agate
      turbulence 1
      lambda 1.5
      omega .8
      octaves 8
      color_map {
        [0.00 color rgb <.5, .25, .15>]
        [0.33 color rgb <.1, .5, .4>]
        [0.86 color rgb <.6, .3, .1>]
        [1.00 color rgb <.5, .25, .15>]
      }
    }
    normal {
      bozo
      turbulence .5
      lambda 2
      normal_map {
        [0.4 dents .15 scale .01]
        [0.6 agate turbulence 1]
        [1.0 dents .15 scale .01]
      }
    }
  }


  #declare OceanArea = texture {
      pigment {
        bozo
        turbulence .5
        lambda 2
        color_map {
          [0.00, 0.33 color rgb <0, 0, 1>
                      color rgb <0, 0, 1>]
          [0.33, 0.66 color rgbf <1, 1, 1, 1>
                      color rgbf <1, 1, 1, 1>]
          [0.66, 1.00 color rgb <0, 0, 1>
                      color rgb <0, 0, 1>]
        }
      }
    }

  #declare CloudArea = texture {
    pigment {
      gradient y
      pigment_map {
        [0.00 Clouds1]
        [0.25 Clouds2]
        [0.50 Clouds3]
        [0.75 Clouds4]
        [1.00 Clouds1]
      }
    }
  }
  
#declare UFO =
  lathe{
    bezier_spline
    8,
    <0,-.04>,<.02,-.04>,<.08,0>,<.1,0>,
    <.1,0>,<.08,0>,<.02,.04>,<0,.04>
    pigment {rgbf 1}
    finish{
      ambient 0
      diffuse 0
      reflection 1
    }
    interior{ ior .9 }
  };
#declare AttackerLaserTexture = 
  texture{
    pigment {rgbt <1.3,1.7,.5,.9>}
    finish {ambient rgb 10*<1.3,1.7,.5>}
  };
#declare DefenderLaserTexture = 
  texture{
    pigment {rgbt <2,0,2,.9>}
    finish {ambient rgb 10*<2,0,0>}
  };
#declare ExplosionColor = rgb<2,1.5,1>;
#declare ExplosionTexture = 
  texture{
    pigment{ExplosionColor}
    finish{ambient ExplosionColor}
  };




light_source{<1000,1000,-100>, rgb 2}

camera{
  location -3*z
  look_at 0
}
  
// The planet under attack
sphere { 0, .95
  texture { LandArea }
  texture { OceanArea }
  texture { CloudArea }
 rotate 30*y
}
// Its atmosphere
#if(MediaOn) 
sphere{ 0,1.05
  pigment { rgbt 1 } hollow
  interior{ 
    media{
      scattering { 1, 0.5 }
      density{
        spherical density_map{
        [0 rgb .25]
        [0.1 rgb 1]}
      }    
    }
  }
}
#end


 



object{UFO
  translate <-.55,-.45,-1.5>
}
cylinder{<-.55,-.45,-1.5>,<-0.467784,-0.610648,-0.557483>,.007
  texture{AttackerLaserTexture}
}
light_source{0, ExplosionColor
 looks_like{
  sphere{0,.05
    texture{ExplosionTexture}
    translate .05*x
  }
 }
 translate -x
 rotate 40*z
 rotate -50*y  
}

cylinder{<.16246,-.822724,-.446354>,<-.55,-.45,-1.5>,.005
  texture{DefenderLaserTexture}
}
light_source{<-.55,-.45,-1.5>,ExplosionColor*.5
 looks_like{
  sphere{<.05,-.015,0>,.02
    texture{ExplosionTexture}
  }
 }
}

object{UFO
  translate <.45,.4,-1.2>
}
cylinder{<.45,.4,-1.2>,<0,.610648,-.727742>,.007
  texture{AttackerLaserTexture}
}
light_source{0, ExplosionColor
 looks_like{
  sphere{0,.05
    texture{ExplosionTexture}
    translate -.05*y
  }
 }
 translate y
 rotate -50*x
}

object{UFO 
  translate <.2,-.2,-1.4>
}
cylinder{<.2,-.2,-1.4>,<.45,.4,-1.2>,.004
  texture{DefenderLaserTexture}
}
light_source{<.45,.38,-1.2>, ExplosionColor*.5
 looks_like{
  sphere{0,.03
    texture{ExplosionTexture}
  }
 }
}
cylinder{<.2,-.2,-1.4>,<-.55,-.45,-1.5>,.004
  texture{DefenderLaserTexture}
}
light_source{<-.55,-.45,-1.5>,ExplosionColor*.5
 looks_like{
  sphere{.02*y,.02
    texture{ExplosionTexture}
  }
 }
}