//  Mill Image
//  Image Created by Matthew L. Ziegler
//  For July-August 1998 IRTC Competition

#include "colors.inc"
#include "textures.inc"
#include "skies.inc"
#include "stones.inc"
#include "glass.inc"
#include "metals.inc"
#include "woods.inc"

// *********************************************************************
//  Scene Declarations
// *********************************************************************

#declare Window=
union {
difference {
box {<-1.5,5,0>,<1.5,7.5,-12.25>}
box {<-3,0,0>,<3,8,-11.75>}
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
union {
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
translate .38*y}
union {
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
translate 1.14*y}
union {
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
translate .76*y}
union {
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
translate 1.14*y}
union {
box {<-1.4,5.1,0>,<-.75,5.43,-13>}
box {<1.4,5.1,0>,<.75,5.43,-13>}
box {<-.7,5.1,0>,<-.05,5.43,-13>}
box {<.7,5.1,0>,<.05,5.43,-13>}
translate 1.52*y}


texture {
        pigment {color Gray90}}}
box {<-1.49,5.01,-12>,<1.49,7.49,-12.05>
    texture {T_Glass3}}}

#declare T_Bricks =
texture {
normal {bumps
       scale <5,1,5>
       turbulence 6}
pigment
 {granite
  turbulence 0.75
  color_map
   {[0.000, 0.153   color rgbf <0.545, 0.380, 0.345, 0.000>
                    color rgbf <0.588, 0.475, 0.333, 0.000>]
    [0.153, 0.398   color rgbf <0.588, 0.475, 0.333, 0.000>
                    color rgbf <0.675, 0.478, 0.404, 0.000>]
    [0.398, 0.559   color rgbf <0.675, 0.478, 0.404, 0.000>
                    color rgbf <0.757, 0.635, 0.522, 0.000>]
    [0.559, 0.729   color rgbf <0.757, 0.635, 0.522, 0.000>
                    color rgbf <0.659, 0.549, 0.443, 0.000>]
    [0.729, 1.001   color rgbf <0.659, 0.549, 0.443, 0.000>
                    color rgbf <0.545, 0.380, 0.345, 0.000>]
   }
 }
 }

// *********************************************************************
// Camera Identifiers
// *********************************************************************


camera {location <0,6,-100>
        look_at <0,40,0>
        blur_samples 30
        aperture .105
        focal_point <0,40,0>}


// *********************************************************************
// Global Identifiers (lights, sky, ground)
// *********************************************************************
/*
light_source {<1000,1000,-1000>, color White}
*/

  light_source {
    <100, 500, -500>
    color White
    area_light <50, 0, 0>, <0, 0, 50>, 5, 5
    adaptive 1
    jitter
  }

sky_sphere {S_Cloud2
  rotate 15*x}


box {<-600000,0,-600000>,<600000,-500000,600000>
       texture {
       normal {bumps
              scale 1.5}
       pigment {bozo
               frequency 4
               color_map{
                          [.2 color DarkGreen]
                          [.3 color Brown]
                          [.4 color ForestGreen]
                          [.9 color MediumForestGreen]
                          [.95 color Gray15]
                          [.99 color DarkGreen]}
               turbulence .5}}}


height_field {
     gif "example.ghf"
     scale <2500,200,1000>
     texture {
       pigment {
         image_map {
           gif "example.ghf"
         }
         rotate x*90
         scale <2500,250,1000>
       }
 //    finish {crand 0.05 reflection 0.1 diffuse 0.7 ambient 0.2}
     }
     smooth                            // comment out this line to speed rendering
rotate -10*x
translate <-1060,-90,950>
}



// *********************************************************************
// Windmill Body
// *********************************************************************

difference {
cone {<0,0,0>,15,<0,60,0>,12.5
      texture {T_Bricks
              scale <5,1,5>}}
box {<-1.5,5,0>,<1.5,7.5,-16>
     rotate -20*y}
box {<-1.5,5,0>,<1.5,7.5,-16>
     rotate -15*y
     translate <0,10,0>}
box {<-1.5,5,0>,<1.5,7.5,-16>
     rotate -15*y
     translate <0,20,0>}
box {<-1.5,5,0>,<1.5,7.5,-16>
     rotate -45*y
     translate <0,30,0>}
box {<-1.5,5,0>,<1.5,7.5,-16>
     rotate -45*y
     translate <0,40,0>}
     }
object {Window
       translate <0,0,-2>
       rotate -20*y}
object {Window
       translate <0,10,-1.75>
       rotate -15*y}
object {Window
       translate <0,20,-1.25>
       rotate -15*y}
object {Window
       translate <0,30,-.5>
       rotate -45*y}
object {Window
       translate <0,40,-.25>
       rotate -45*y}

torus {12.5,.25
       translate <0,60,0>
       texture {
               pigment {color Gray20}}}
difference {
union {
sphere {<0,65,0>,13}
cone {<0,70,0>,10,<0,75,0>,7}
cone {<0,75,0>,7,<0,80,0>,3}
cone {<0,80,0>,3,<0,83,0>.5}
cone {<0,82,0>,2,<0,84,0>,.25}
texture {
normal {wrinkles
       scale <1,6,1>}
pigment {color White}}

}

box {<-20,60,-20>,<20,40,20>}}


torus {.5,.2
      texture {T_Brass_2B}
      translate <0,85,0>}
sphere {<0,86,0>,.5
       texture {T_Brass_2B}}
cylinder {<0,86,0>,<0,1,0>,.25
         pigment {color Gray90}}


cylinder {<0,14,0>,<0,14.25,0>,20
         texture {T_Wood12}}
#declare circleit=0
#while (circleit < 20)
box {<0,-.25,-.25>,<-20,.25,.25>
    rotate 35*z
    translate <19.25,14,0>
    texture {T_Wood12}
    rotate (circleit*18)*y}
#declare circleit=circleit+1
#end

#declare circleitb=0
#while (circleitb<20)
box {<19.75,14.1,-.1>,<20.1,17,.1>
    texture {T_Wood12}
    rotate (circleitb*18)*y}
#declare circleitb=circleitb+1
#end

#declare circleitc=0
#while (circleitc < 20 )
union {
box {<-.1,.1,0>,<.1,-.15,7>
     rotate -9*y
     translate 16.9*y}
box {<-.1,.1,0>,<.1,-.15,7>
     rotate -9*y
     translate 14.5*y}
box {<-.1,.1,0>,<.1,-.15,7.5>
     rotate <18,-9,0>
     translate 16.9*y}
box {<-.1,.1,0>,<.1,-.15,7.5>
     rotate <-18,-9,0>
     translate 14.5*y}
     texture {T_Wood12}
     translate <19.85,0,0>
     rotate (circleitc*18)*y}
#declare circleitc=circleitc+1
#end

// *********************************************************************
// Wind Sail Code
// *********************************************************************

union {
union {
cylinder {<0,0,2>,<0,0,-4>,2
          texture {T_Chrome_4D}}
sphere {<0,0,0>,2
          texture {T_Chrome_4D}}

union {
cylinder {<0,0,0>,<-4,0,0>,2.5}
cone {<-4,0,0>,1.5,<-50,0,0>,1}
union {
torus {1.5,.25
      rotate 90*z}
torus {1.4,.25
      rotate 90*z
      translate -5.75*x}
torus {1.3,.25
      rotate 90*z
      translate -11.5*x}
torus {1.25,.25
      rotate 90*z
      translate -17.25*x}
torus {1.2,.25
      rotate 90*z
      translate -23*x}
torus {1.15,.25
      rotate 90*z
      translate -28.75*x}
torus {1.1,.25
      rotate 90*z
      translate -34.5*x}
torus {1.05,.25
      rotate 90*z
      translate -40.25*x}
torus {1,.25
      rotate 90*z
      translate -46*x}
      translate -4*x}
sphere {<0,0,0>,1
       scale <1.5,1,1.5>
       translate -50*x}
pigment {color Gray90}}

difference {
union {
torus {8,.25
      rotate 90*z}
torus {8,.25
      rotate 90*z
      translate -5.75*x}
torus {8,.25
      rotate 90*z
      translate -11.5*x}
torus {8,.25
      rotate 90*z
      translate -17.25*x}
torus {8,.25
      rotate 90*z
      translate -23*x}
torus {8,.25
      rotate 90*z
      translate -28.75*x}
torus {8,.25
      rotate 90*z
      translate -34.5*x}
torus {8,.25
      rotate 90*z
      translate -40.25*x}
torus {8,.25
      rotate 90*z
      translate -46*x}
      translate -4*x
      scale <1,1,.05>}
box {<-60,-60,0>,<60,60,-15>}
    translate -8*y
    pigment {color Gray90}}

difference {
cylinder {<-4,0,0>,<-50,0,0>,8
          scale <1,1,.1>}
cylinder {<0,0,0>,<-55,0,0>,7.95
          scale <1,1,.1>}
box {<-60,-60,0>,<60,60,-10>}
    texture {
    normal {bumps
           scale 2}
    pigment {color rgbf <.98,.98,.98,.5>}}
    translate -8*y}
}

union {
cylinder {<0,0,2>,<0,0,-4>,2
          texture {T_Chrome_4D}}
sphere {<0,0,0>,2
          texture {T_Chrome_4D}}

union {
cylinder {<0,0,0>,<-4,0,0>,2.5}
cone {<-4,0,0>,1.5,<-50,0,0>,1}
union {
torus {1.5,.25
      rotate 90*z}
torus {1.4,.25
      rotate 90*z
      translate -5.75*x}
torus {1.3,.25
      rotate 90*z
      translate -11.5*x}
torus {1.25,.25
      rotate 90*z
      translate -17.25*x}
torus {1.2,.25
      rotate 90*z
      translate -23*x}
torus {1.15,.25
      rotate 90*z
      translate -28.75*x}
torus {1.1,.25
      rotate 90*z
      translate -34.5*x}
torus {1.05,.25
      rotate 90*z
      translate -40.25*x}
torus {1,.25
      rotate 90*z
      translate -46*x}
      translate -4*x}
sphere {<0,0,0>,1
       scale <1.5,1,1.5>
       translate -50*x}
pigment {color Gray90}}

difference {
union {
torus {8,.25
      rotate 90*z}
torus {8,.25
      rotate 90*z
      translate -5.75*x}
torus {8,.25
      rotate 90*z
      translate -11.5*x}
torus {8,.25
      rotate 90*z
      translate -17.25*x}
torus {8,.25
      rotate 90*z
      translate -23*x}
torus {8,.25
      rotate 90*z
      translate -28.75*x}
torus {8,.25
      rotate 90*z
      translate -34.5*x}
torus {8,.25
      rotate 90*z
      translate -40.25*x}
torus {8,.25
      rotate 90*z
      translate -46*x}
      translate -4*x
      scale <1,1,.05>}
box {<-60,-60,0>,<60,60,-15>}
    translate -8*y
    pigment {color Gray90}}

difference {
cylinder {<-4,0,0>,<-50,0,0>,8
          scale <1,1,.1>}
cylinder {<0,0,0>,<-55,0,0>,7.95
          scale <1,1,.1>}
box {<-60,-60,0>,<60,60,-10>}
    texture {
    normal {bumps
           scale 2}
    pigment {color rgbf <.98,.98,.98,.5>}}
    translate -8*y}
rotate 90*z}


union {
cylinder {<0,0,2>,<0,0,-4>,2
          texture {T_Chrome_4D}}
sphere {<0,0,0>,2
          texture {T_Chrome_4D}}

union {
cylinder {<0,0,0>,<-4,0,0>,2.5}
cone {<-4,0,0>,1.5,<-50,0,0>,1}
union {
torus {1.5,.25
      rotate 90*z}
torus {1.4,.25
      rotate 90*z
      translate -5.75*x}
torus {1.3,.25
      rotate 90*z
      translate -11.5*x}
torus {1.25,.25
      rotate 90*z
      translate -17.25*x}
torus {1.2,.25
      rotate 90*z
      translate -23*x}
torus {1.15,.25
      rotate 90*z
      translate -28.75*x}
torus {1.1,.25
      rotate 90*z
      translate -34.5*x}
torus {1.05,.25
      rotate 90*z
      translate -40.25*x}
torus {1,.25
      rotate 90*z
      translate -46*x}
      translate -4*x}
sphere {<0,0,0>,1
       scale <1.5,1,1.5>
       translate -50*x}
pigment {color Gray90}}

difference {
union {
torus {8,.25
      rotate 90*z}
torus {8,.25
      rotate 90*z
      translate -5.75*x}
torus {8,.25
      rotate 90*z
      translate -11.5*x}
torus {8,.25
      rotate 90*z
      translate -17.25*x}
torus {8,.25
      rotate 90*z
      translate -23*x}
torus {8,.25
      rotate 90*z
      translate -28.75*x}
torus {8,.25
      rotate 90*z
      translate -34.5*x}
torus {8,.25
      rotate 90*z
      translate -40.25*x}
torus {8,.25
      rotate 90*z
      translate -46*x}
      translate -4*x
      scale <1,1,.05>}
box {<-60,-60,0>,<60,60,-15>}
    translate -8*y
    pigment {color Gray90}}

difference {
cylinder {<-4,0,0>,<-50,0,0>,8
          scale <1,1,.1>}
cylinder {<0,0,0>,<-55,0,0>,7.95
          scale <1,1,.1>}
box {<-60,-60,0>,<60,60,-10>}
    texture {
    normal {bumps
           scale 2}
    pigment {color rgbf <.98,.98,.98,.5>}}
    translate -8*y}
rotate 180*z}


union {
cylinder {<0,0,2>,<0,0,-4>,2
          texture {T_Chrome_4D}}
sphere {<0,0,0>,2
          texture {T_Chrome_4D}}

union {
cylinder {<0,0,0>,<-4,0,0>,2.5}
cone {<-4,0,0>,1.5,<-50,0,0>,1}
union {
torus {1.5,.25
      rotate 90*z}
torus {1.4,.25
      rotate 90*z
      translate -5.75*x}
torus {1.3,.25
      rotate 90*z
      translate -11.5*x}
torus {1.25,.25
      rotate 90*z
      translate -17.25*x}
torus {1.2,.25
      rotate 90*z
      translate -23*x}
torus {1.15,.25
      rotate 90*z
      translate -28.75*x}
torus {1.1,.25
      rotate 90*z
      translate -34.5*x}
torus {1.05,.25
      rotate 90*z
      translate -40.25*x}
torus {1,.25
      rotate 90*z
      translate -46*x}
      translate -4*x}
sphere {<0,0,0>,1
       scale <1.5,1,1.5>
       translate -50*x}
pigment {color Gray90}}

difference {
union {
torus {8,.25
      rotate 90*z}
torus {8,.25
      rotate 90*z
      translate -5.75*x}
torus {8,.25
      rotate 90*z
      translate -11.5*x}
torus {8,.25
      rotate 90*z
      translate -17.25*x}
torus {8,.25
      rotate 90*z
      translate -23*x}
torus {8,.25
      rotate 90*z
      translate -28.75*x}
torus {8,.25
      rotate 90*z
      translate -34.5*x}
torus {8,.25
      rotate 90*z
      translate -40.25*x}
torus {8,.25
      rotate 90*z
      translate -46*x}
      translate -4*x
      scale <1,1,.05>}
box {<-60,-60,0>,<60,60,-15>}
    translate -8*y
    pigment {color Gray90}}

difference {
cylinder {<-4,0,0>,<-50,0,0>,8
          scale <1,1,.1>}
cylinder {<0,0,0>,<-55,0,0>,7.95
          scale <1,1,.1>}
box {<-60,-60,0>,<60,60,-10>}
    texture {
    normal {bumps
           scale 2}
    pigment {color rgbf <.98,.98,.98,.5>}}
    translate -8*y}
rotate 270*z}
rotate -36*z
translate <0,68,17>
rotate -45*y}


//  **********************************************************************
//  Secondary Sail Fin
// ***********************************************************************

#declare fins=
union {
difference {
cylinder {<-.05,0,0>,<.05,0,0>,7}
box {<-3,-10,0>,<3,10,-10>
    rotate 22.5*x}
box {<-3,-10,0>,<3,10,10>
    rotate -22.5*x }}
rotate -10*y
texture {
normal {bumps
       scale .75}
pigment {color White}
finish {F_MetalA}}}


union {
object {fins}
object {fins
       rotate 45*x}
object {fins
       rotate 90*x}
object {fins
       rotate 135*x}
object {fins
       rotate 180*x}
object {fins
       rotate 225*x}
object {fins
       rotate 270*x}
object {fins
       rotate 315*x}
cylinder {<-1,0,0>,<1,0,0>,.5
         texture {T_Chrome_4D}}
cylinder {<-.5,0,0>,<.5,0,0>,1
         texture{
         pigment {color White}
         finish {F_MetalA}}}
translate <0,80,-22>
rotate -45*y}

union {
box {<-3,63,-17>,<3,62.8,0>
     texture {
     normal {dents
            scale .5}
     pigment {color White}}}
union {
cylinder {<-3,63,-17>,<-3,66,-17>,.1}
cylinder {<3,63,-17>,<3,66,-17>,.1}
cylinder {<-3,66,-17>,<3,66,-17>,.1}
cylinder {<-3,65,-17>,<3,65,-17>,.1}
cylinder {<-3,64,-17>,<3,64,-17>,.1}
cylinder {<-3,64,-17>,<-3,64,-5>,.1}
cylinder {<-3,65,-17>,<-3,65,-5>,.1}
cylinder {<-3,66,-17>,<-3,66,-5>,.1}
cylinder {<3,64,-17>,<3,64,-5>,.1}
cylinder {<3,65,-17>,<3,65,-5>,.1}
cylinder {<3,66,-17>,<3,66,-5>,.1}
     texture {
     pigment {color White}
     finish {F_MetalA}}}

cylinder {<-.75,80,-22>,<-3,63,-16>,.5
         texture {
         pigment {color White}
         finish {F_MetalA}}}
cylinder {<.75,80,-22>,<3,63,-16>,.5
         texture {
         pigment {color White}
         finish {F_MetalA}}}
cylinder {<-.75,80,-22>,<-.75,75,0>,.5
         texture {
         pigment {color White}
         finish {F_MetalA}}}


rotate -45*y}

// ***********************************************************
//  Tree and Landscape
// ***********************************************************

#declare SD1=seed(35)
object {
#declare BarkTexture=2
#declare LeafShape=3
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale 3
translate <25,0,100>
}

#declare SD1=seed(245)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
translate <-15,0,-90>
}

#declare SD1=seed(35)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale 3
rotate 180*y
translate <18.75,-.75,-100>
}





#declare SD1=seed(.254)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <15,-1,-19>
}


#declare SD1=seed(3)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <20,-1,-24>
}


#declare SD1=seed(18)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <25,-1,-29>
}


#declare SD1=seed(555)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <30,-1,-34>
}


#declare SD1=seed(456)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <35,-1,-39>
}
/*
#declare SD1=seed(33)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,1.2,1>
translate <18,0,-60>
}
*/

#declare SD1=seed(3)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.15
#include "trees.inc"
scale <1,.5,1>
translate <-3,-1,-18>
}



#declare SD1=seed(12312135)
#declare SD2=seed(554)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.1
#include "trees.inc"
scale <1,.5,1>
translate <-30,-1,50>
}


#declare SD1=seed(15485)
#declare SD2=seed(336)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.1
#include "trees.inc"
scale <1,.5,1>
translate <-40,-1,50>
}


#declare SD1=seed(1585)
#declare SD2=seed(754)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.1
#include "trees.inc"
scale <1,.5,1>
translate <-50,-1,50>
}


#declare SD1=seed(354)
#declare SD2=seed(8854)
object {
#declare BarkTexture=0
#declare LeafShape=6
#declare LeafTexture=5
#declare MinXDeg=35
#declare MaxXDeg=60
#declare LengthInc=1.25
#declare IncSplits=1.1
#include "trees.inc"
scale <1,.5,1>
translate <-60,-1,50>
}



