/* --- settings --- */
#local MitSonnenTau = 0;
#local MitGras = 0;
#local MitHalmen = 1;
#local MitBluete = 0;
#local MitPflanzen = 1;
#local MitGaenseBlume = 0;
#local MitSteinen = 1;
#local MitSchnecken = 0;
#local MitFLiegenpilz = 0;
#local MitBaum = 1;
#local MitBuddha = 1;

global_settings {
 adc_bailout 0.003922
 ambient_light <1.0,1.0,1.0>
 assumed_gamma 1.8
 hf_gray_16 off
 irid_wavelength <0.25,0.18,0.14>
 max_intersections 64
 max_trace_level 10
 number_of_waves 10
 /* radiosity {
 brightness       3.3
 count            100
 distance_maximum 0.0
 error_bound      0.4
 gray_threshold   0.5
 low_error_factor 0.8
 minimum_reuse    0.015
 nearest_count    6
 recursion_limit  1
 }
 */
}

#declare Dummy = sphere { <0,0,0> 0 pigment { color rgb<0,0,0> } }

/* --- includes --- */
#include "colors.inc"
#include "textures.inc"
#include "woods.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "functions.inc"
#include "math.inc"
#include "transforms.inc"
#include "woodmaps.inc"

/* --- wiesen elemente --- */
// #include "glockenblume.pov"

/* --- akteure --- */
#include "hummel2.pov"  // object Bee
#include "vogel-v3.pov"

/* --- sun --- */
#declare Sonne = light_source {
 <0,2500,-200> color White
}

/* --- sky --- */
#declare Himmel = plane {
 <0,1,0>,1 hollow
 texture {
   pigment {
     bozo turbulence 0.92
     color_map {
       [0.00 rgb <0.2, 0.2, 1>*0.9]
       [0.50 rgb <0.2, 0.2, 1>*0.9]
       [0.70 rgb <1,1,1>]
       [0.85 rgb <0.25,0.25,0.25>]
       [1.0 rgb <0.5,0.5,0.5>]
     }
     scale<1,1,1.5>*2.5
     translate<1.0,0,-1>
   }
   finish {
     ambient 1 diffuse 0
   }
 }
 scale 10000
}

/* --- ground --- */
#declare Untergrund = plane {
 <0,1,0>, 0
 texture {
   pigment {
     color rgb<0.35,0.65,0.0>*0.8
   }
   normal {
     bumps 0.75 scale 0.015
   }
   finish {
     ambient 0.1 diffuse 0.8
   }
 }
}


/* --- zaun elemente --- */
#declare Zaun = merge {

 box { <0,0,1>,<1,3,1.2> }

 prism {
   0.00, 0.2, 4
   <-1.00, 0.00>,
   < 0, 0.00>,
   < -0.5, 0.20>,
   <-1.00, 0.00>
   rotate<-90,0,0>
   translate<1,3,1.2>
 }

 texture {
   Yellow_Pine
   normal {
     bumps 0.5 scale 0.08
   }
   finish {
     ambient 0.1 diffuse 0.9 phong 1.0
   }
 } //Ende der Texturbeschreibung

 scale 0.97  // 0.5
}

#declare ZaunMitLoch = merge {
 difference {
   box { <0,0,1>,<1,3,1.2> }

   sphere {
     <0,0,0>,0.2 translate <0.25,1.2,1.1>
     texture {
       pigment {
         color Black
       }
     }
   }


   prism {
     0.00, 0.2, 4
     <-1.00, 0.00>,
     < 0, 0.00>,
     < -0.5, 0.20>,
     <-1.00, 0.00>
     rotate<-90,0,0>
     translate<1,3,1.2>
   }

   texture {
     Yellow_Pine
     normal {
       bumps 0.5 scale 0.08
     }
     finish {
       ambient 0.1 diffuse 0.9 phong 1.0
     }
   }


 } // difference

 box {
   <0,0.8,1.2>, <0.7,1.5,1.25>          //<--- Farbe hinter dem Loch - kann man auch weglassen dann is halt der Himmer dahinter
   texture {
     pigment {
       color Black
     }
   }
 } // Ende der Zaunelemente
 scale 0.97
}

#declare Random_1 = seed (1153); // Zufall f�r Zaun krmm und schief
#declare Random_2 = seed (9153); // Zufall f�r Zaun krmm und schief

//---------------------------------------------------------------------
//-.------------------------Variab------------------------------------

#declare zAbstand = -25;      // immer negativen Wert nehmen sonst.......
//Zaungr��e ist immer doppelt so gro� wie zAbstand
#declare W = 0;     // zus�tzlicher Z-Abstabnd nach hinten

#declare zufall=2;

/* --- gras --- */
#if (MitGras)
 #include "gras_2.inc"
 #include "gras.inc"
#end
#macro GrasBueschel(anz_halme,anz_blaetter) object {
 #if (MitGras)
   grasbueschel (anz_halme,anz_blaetter)
 #else
   Dummy
 #end
}
#end

//------------------------------------------------------
//.....---------------------------------------------------------
#declare ZaunAlles = union {
 // Der komplette Zaun ist eine Union
 // Bretter hinten
 #declare NrA = zAbstand+1;     // start
 #declare EndNrA = zAbstand*-1;   // end

 #while (NrA < EndNrA+1)
   object {
     Zaun rotate <rand(Random_2)*3,0,0> translate < NrA,-rand(Random_1)/4,-zAbstand+W>
   }
   #declare NrA = NrA + 1;  //next Nr
 #end

 //Bretter rechts
 #declare NrX = zAbstand;     // start
 #declare EndNrX = -zAbstand;   // end

 #while (NrX < EndNrX+1)
   object {
     Zaun rotate <0,90,rand(Random_2)*6> translate <-zAbstand,-rand(Random_2)/2,NrX+W+1>
   }
   object { GrasBueschel (2,4) scale 0.09 translate <-zAbstand-0.8,-rand(Random_2)/3,NrX+W+1> }
   #declare NrX = NrX + 1;  //next Nr
 #end

 // Bretter Links
 #declare NrY = zAbstand;     // start
 #declare EndNrY = -zAbstand;   // end

 #while (NrY < EndNrY+1)
   object {
     Zaun rotate <0,90,rand(Random_1)*4> translate <zAbstand,-rand(Random_1)/3,NrY+W+1>
   }
   // object { GrasBueschel (2,4) scale 0.15 translate <zAbstand+2,-rand(Random_1)/3,NrY+W+1> }
   #declare NrY = NrY + 1;  //next Nr
 #end


 //Bretter vorne
 #declare NrB = zAbstand+1;     // start
 #declare EndNrB = -zAbstand;   // end

 #while (NrB < EndNrB+1)
   object {
     Zaun rotate <rand(Random_1)*8,0,rand(Random_1)> translate < NrB,-rand(Random_2)/3,zAbstand+W-1>
   }
   #declare NrB = NrB + 1;  //next Nr
 #end

 //Zaun mit Loch mu� �ber ein bereits vorhandenes Dr�bergelegt werden

 object { ZaunMitLoch translate <2,0,-zAbstand+W-0.1> }
}

// Lasst uns die Wiese ergr�nen und mit viel Schwachsinn f�llen!
// Howto : while schleifen mit seed werten

// Kugel 1 - ist Grasb�schel
#declare Kugel_X_Random = seed (59873); // Zufall f�r Kugel 1 X- Achse
#declare Kugel_Z_Random = seed (1971); // Zufall f�r Kugel 1 Z - Achse
#declare Kugel_Y_Random = seed (7865); // Zufall f�r Kugel 1 Y - Achse
#declare Kugel_W_Random = seed (579); // Zufall f�r Kugel 1 W- Achse

#declare KugelA = sphere {
 <0, 1, 0>, 0.6 translate <0,0,0>
 texture {
   pigment {
     color Red
   }
 }
}

//Kugel1_Random verteilung in X und Z richtung

#declare KuX = zAbstand-1;     // start
#declare KuEnd = -zAbstand+1;   // end
#while (KuX < KuEnd)          // der Wert der von KuEnd Abgezogen wird ver�ndert die Anzahl der Dinge Im Verh�ltnis zur gr��e des Gartens!!!!
 // 4 verschiedene Grasb�schel

 object { GrasBueschel (7,4) scale 0.09 translate < KuX,0,zAbstand*(-1+2*rand(Kugel_Z_Random))> }
 object { GrasBueschel (4,2) scale 0.08 translate < KuX,0,zAbstand*(-1+2*rand(Kugel_X_Random))> }
 object { GrasBueschel (2,1) scale 0.06 translate < KuX,0,zAbstand*(-1+2*rand(Kugel_Y_Random))> }
 object { GrasBueschel (4,1) scale 0.07 translate < KuX,0,zAbstand*(-1+2*rand(Kugel_W_Random))> }

 #declare KuX = KuX + 0.02;  //next Nr

#end // ------------ end of loop --


/* --- fliegenpilz --- */
#if (MitFLiegenpilz)
 #include "fliegenpilz.pov"
 #declare KugelB_X_Random = seed (73); // Zufall f�r Kugel2 X- Achse
 #declare KugelB_Z_Random = seed (171); // Zufall f�r Kugel2 Z - Achse
 #declare KugelB = sphere {
   <0, 1, 0>, 0.5
   translate <0,0,0>
   texture {
     pigment {
       color Blue
     }
   }
 }
 //Kugel2_Random verteilung in X und Z richtung

 #declare Ku2 = zAbstand;     // start
 #declare Ku2End = -zAbstand;   // end
 #while (Ku2 < Ku2End)
   object {
     pilz
     rotate <-90,0,0>
     scale 0.1
     translate < Ku2,0.5,Ku2*(-1+2*rand(KugelB_Z_Random))>
   }
   #declare Ku2 = Ku2 + 2;  //next Nr
 #end
#end

/* --- bluete --- */
#if (MitBluete)
 #include "bluete.pov"
 #declare KugelC_X_Random = seed (1833); // Zufall f�r Kugel3 X- Achse
 #declare KugelC_Z_Random = seed (1748); // Zufall f�r Kugel3 Z - Achse
 #declare Bedingung = seed (5679); // Zufall f�r Kugel3 Z - Achse
 #declare KugelC = sphere {
   <0, 1, 0>,0.7 translate <0,0,0>            //hier m�sste dann das Ding kommen
   texture {
     pigment {
       color Black
     }}
 }

 //Kugel2_Random verteilung in X und Z richtung

 #declare Ku3 = zAbstand+1;     // start
 #declare Ku3End = -zAbstand;   // end
 #while (Ku3 < Ku3End)
   #if (-1+2*rand(Bedingung) < -0.8)
     #declare drei = union {
       object {
         bluete rotate <-90,-90/*rand(KugelC_X_Random)*/,-8> scale 0.24
       }
       object {
         bluete rotate <-90,90/*rand(KugelC_X_Random)*/,1> scale 0.23
       }
       object {
         bluete rotate <-90,45/*rand(KugelC_X_Random)*/,-15> scale 0.21
       }
     }

     object {
       drei rotate <0,10*rand(KugelC_X_Random),0> translate < Ku3,0,zAbstand*(-1+2*rand(KugelC_Z_Random))>
     }

   #end
   #if (-1+2*rand(Bedingung) > 0.8)
     #declare zwei = union {
       object {
         bluete
         rotate <-90,-45/*rand(KugelC_X_Random)*/,1>
         scale 0.2
       }
       object {
         bluete
         rotate <-90,95/*rand(KugelC_X_Random)*/,-2>
         scale 0.19
       }
     }
     object {
       zwei
       rotate <0,-10*rand(KugelC_X_Random),0>
       translate < Ku3,0,zAbstand*(-1+2*rand(KugelC_Z_Random))>
     }
   #end

   #if (-1+2*rand(Bedingung) > 0.4)
     object {
       bluete rotate <-90,100*rand(KugelC_X_Random),1> scale 0.22 translate < Ku3,0,zAbstand*(-1+2*rand(KugelC_Z_Random))>
     }
     #declare Ku3 = Ku3 + 0.5;  //next Nr
   #end
 #end
#end

/* --- Glockenblume --- */
#declare Kugel4_X_Random = seed (767); // Zufall f�r Kugel3 X- Achse
#declare Kugel4_Z_Random = seed (7513); // Zufall f�r Kugel3 Z - Achse
// Verteilung in X und Z richtung
#declare Ku4 = zAbstand+1;     // start
#declare Ku4End = -zAbstand-1;   // end

/* FIXME: povray kennt "glockenblume" nicht
#while (Ku4 < Ku4End)
 object {
   glockenblume
   scale 0.07
   rotate <-90,90*rand(Kugel4_X_Random),0>
   translate < Ku4,1.5,zAbstand*(-1+2*rand(Kugel4_Z_Random))>
 }
 #declare Ku4 = Ku4 +1;  //next Nr
#end
*/


/* --- Schneckenhaeuser --- */
#if (MitSchnecken)
 #include "schnecke3.pov"
 #declare Schne_X_Random = seed (123); //Zufall Schneckenhaus X
 #declare Schne_Z_Random = seed (7979); //Zufall ScheeZ
 #declare Schne = zAbstand;     // start
 #declare SchneEnd = -zAbstand-10;   // end

 #while (Schne < SchneEnd)
   object {
     schnecke
     scale 0.2
     rotate <-90,7*Schne_X_Random,0>
     translate <Schne*rand(Schne_X_Random)+14,0,Schne*rand(Schne_Z_Random)*-1+14>
   }
   #declare Schne = Schne + 4;  //next Nr
 #end
#end

/* --- Gaensebluemchen --- */
#if (MitGaenseBlume)
 #include "gbluete.pov"
 #declare Gans_Random = seed (1453); //Zufall Schneckenhaus X
 #declare Gans_Z_Random = seed (98546); //Zufall ScheeZ

 #declare goos = zAbstand;     // start
 #declare goosend = -zAbstand;   // end

 #while (goos < goosend)
   object {
     Gansblume scale 0.5 rotate <-90,90*rand(Gans_Random),0>translate < goos,0,zAbstand*(-1+2*rand(Gans_Random))>
   }
   #declare goos = goos + 0.05;  //next Nr
 #end
#end

/* --- Halme --- */
#if (MitHalmen)
 #include "halm.pov"
 #declare Halm_Random = seed (47964); //Zufall Schneckenhaus X
 #declare Halm_Z_Random = seed (7645); //Zufall ScheeZ
 #declare ha = zAbstand;
 #declare haend= -zAbstand;

 #while (ha < haend)
   object {
     Halm scale 0.23 rotate <-90,90*rand(Halm_Random),0>translate < ha,0,zAbstand*(-1+2*rand(Halm_Random))>
   }
   #declare ha = ha + 0.5;  //next Nr
 #end
#end

/* --- Steine ohne Kaefer --- */
#if (MitSteinen)
 #include "stein.pov"
 #declare Stein_Random = seed (7864); //Zufall Schneckenhaus X
 #declare ste = zAbstand;
 #declare steend= -zAbstand;

 #while (ste < steend)
   object {
     stein scale 1 rotate <-90,90*rand(Stein_Random),0>translate < ste+3,-0.5,zAbstand*(-1+2*rand(Stein_Random))>
   }
   #declare ste = ste + 10;  //next Nr
 #end
#end

/* --- Buddha --- */
#if (MitBuddha)
 #include "boudha.inc"
 #include "golds.inc"
#end
#declare Buddha = object {
 #if (MitBuddha)
   boudha scale 0.15 rotate <0,145,0> translate <zAbstand+4,0,-zAbstand-1>
   //texture { pov_default }
   texture { T_Gold_2C }
 #else
   Dummy
 #end
}


/* --- Verschiedene Pflanzen --- */
#if (MitSonnenTau)
 #include "sonnentau.inc"
#end
#declare SonnentauAngepasst = object {
 #if (MitSonnenTau)
   Sonnentau
   scale 0.2
   translate <3*rand(Kugel4_X_Random)*-1,0,rand(Kugel4_Z_Random)-15>
 #else
   Dummy
 #end
}

#if (MitBaum)
 #include "baumstamm.inc"
#end
#declare Baum = object {
 #if (MitBaum)
   Stamm
   scale 0.9
   translate<6,-10,4>
   pigment { color Brown }
 #else
   Dummy
 #end
}

/* --- hummel fuer spline flug --- */
#declare FixedBee = object {
 Bee                                     // extends in y-dir, located above origin
 scale 0.5                               // adjust size
 translate <0, -1, 0>                    // shift bee center into origin
 Axis_Rotate_Trans (<1,0,0>, 90)         // make z-axis vertical bee axis
 Axis_Rotate_Trans (<0,0,1>, 180)        // turn on belly
}

/* --- camera splines --- */
#declare KameraFahrt_Garten1 = spline { // von Sven
 // Steuerpunkt, Startpunkt, ..., Endpunkt, Steuerpunkt
 linear_spline
 -0.20, < - 1.0, 1,    + 0.6 >,
 +0.00, < - 1.0, 1,    + 0.6 >,
 +0.20, < - 2,   2.0,  - 0   >,
 +0.40, < - 2,   1.5,    8   >,
 +0.60, < - 4,   0.5,   14   >,
 +0.80, < - 5,   1,     19   >,
 +1.00, < -12,   3.5,   25   >,
 +1.20, < - 2,   3.78,  26.1 >
}
#declare KameraFahrt_Garten2 = spline { // von Andre
 // Steuerpunkt, Startpunkt, ..., Endpunkt, Steuerpunkt
 natural_spline
 -0.03,  < -56.078542 / 2, 5.0, 8.746195 / 2 >,
 +0.00,  < -55.078542 / 2, 6.5, 10.746195 / 2 >,
 +0.03,  < -54.078542 / 2, 7.0, 12.246195 / 2 >,
 +0.06,  < -52.99165 / 2, 7.151988, 13.376533 / 2 >,
 +0.09,  < -49.904758 / 2, 8.586647, 20.0648 / 2 >,
 +0.12,  < -46.973683 / 2, 8.945312, 27.267548 / 2 >,
 +0.15,  < -40.332447 / 2, 9.303977, 37.042707 / 2 >,
 +0.18,  < -32.100734 / 2, 8.227983, 43.216491 / 2 >,
 +0.21,  < -22.419635 / 2, 6.793324, 48.361312 / 2 >,
 +0.24,  < -9.322434 / 2, 7.151988, 47.332348 / 2 >,
 +0.27,  < -2.057928 / 2, 10.379971, 39.100635 / 2 >,
 +0.30,  < 2.822288 / 2, 12.173295, 27.267548 / 2 >,
 +0.33,  < 2.728228 / 2, 12.173295, 21.093764 / 2 >,
 +0.36,  < 10.804123 / 2, 11.495231, 23.592046 / 2 >,
 +0.39,  < 18.521353 / 2, 9.662641, 26.753066 / 2 >,
 +0.42,  < 23.151692 / 2, 8.945312, 30.35444 / 2 >,
 +0.45,  < 24.180656 / 2, 6.434659, 39.100635 / 2 >,
 +0.48,  < 13.53235 / 2, 6.434659, 45.27442 / 2 >,
 +0.51,  < 1.543446 / 2, 5.358665, 44.245455 / 2 >,
 +0.54,  < -10.804123 / 2, 5.0, 26.753066 / 2 >,
 +0.57,  < -17.024937 / 2, 8.586647, 8.231713 / 2 >,
 +0.60,  < -16.104761 / 2, 9.662641, -8.746195 / 2 >,
 +0.63,  < -10.95994 / 2, 9.662641, -28.296512 / 2 >,
 +0.66,  < 3.601374 / 2, 9.662641, -36.528225 / 2 >,
 +0.69,  < 22.63721 / 2, 11.0973, -33.441333 / 2 >,
 +0.72,  < 23.354539 / 2, 10.738636, -33.441333 / 2 >,
 +0.75,  < 26.955914 / 2, 10.021306, -22.63721 / 2 >,
 +0.78,  < 28.810994 / 2, 8.227983, -10.804123 / 2 >,
 +0.81,  < 33.238485 / 2, 6.434659, 7.202749 / 2 >
}


/* --- Objekte --- */
object { Himmel }
object { ZaunAlles }
object { Sonne }
object { Untergrund }
object { SonnentauAngepasst }
object { GrasBueschel (1,7) scale 0.25 }
object { Baum }
object { Buddha }
object { vogel scale 0.5 rotate <-90,-70,-10> translate <-2,3.79,26.1> }

object {
 object { FixedBee scale 3 }
 // sphere { <0,0,0> 1 pigment { color Blue } }
 #local curve_ahead = 1; // >= 0.0000000000001
 #local tilt = 1;
 Spline_Trans (KameraFahrt_Garten2, clock, y, curve_ahead, tilt)
}
// object { Bee scale 0.71 rotate <-25,20,0> translate <0,1,-8> }


/* --- camera/view definition --- */
camera {
 angle (60 - clock * 40)
 translate KameraFahrt_Garten1 (clock)
 look_at KameraFahrt_Garten2 (clock)
}
fog {
 fog_type   2
 distance   150
 color      White
 fog_offset 0.1
 fog_alt    1.5
 turbulence 1.8
}


/* --- emacs editing helpers --- */
/*
(setq load-path (cons "/home/timj/tmp/" load-path))
(load "pov-mode.el")
(pov-mode)
(hotkeys-programming)
*/