#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
#include "metals.inc"
#include "stones.inc"

global_settings {
        assumed_gamma 1.0
        //ambient_light rgb<0.5, 0.5, 0.5>
        ambient_light rgb<0, 0, 0>
	radiosity {}
	max_intersections 128
}
background { color rgb<0.2, 0.4, 0.8>  }
light_source {
    <86E9, 86E9, -86E9>
    color White
}

camera {
	up <0, 4/3, 0>
	right <1, 0, 0>
        location <6000, 1.65, 10>
        look_at <0, 2500, -1000>	//ok
        //look_at <6000, 1.65, 0>
}

#include "sol.pov"
#include "../roboter/roboter.pov"

object {
    Sol
    translate <0, 3300, 0>
}

#include "bmpeople.inc"
#include "lft.cdf"

#declare i = 5900;
#declare rand1 = seed(0);
#while (i < 6000)
    #debug concat ("\nMensch: ", str(i, 0, 0))
    #declare Schritt = (rand(rand1) * 0.7 + 0.3) * 
                       ((rand(rand1) > 0.5) * 2 - 1);
    #declare MF = int(rand(rand1) * 1.5);	// Männer:Frauen = 2:1
    #declare Groesse = (rand(rand1) * 0.3 + 1.7) * (1 - 0.08 * MF);

    #declare BM_Neck_Rot = <-10,0,0>;   // Rotation vector for the neck
    #declare BM_Torso_Rot= <-10,0,0>;   // Rotation vector for the Upper Torso 

    #declare BM_RA_S2E   = <-20*Schritt,0,-8>;  // Right Upperarm
    #declare BM_RA_E2W   = <-20*Schritt+20,0,-3>;  // Right Forearm 
    #declare BM_RH_Rot   = <0,0,0>;  // Right Hand

    #declare BM_LA_S2E   = <20*Schritt,0,8>;  // Left Upperarm
    #declare BM_LA_E2W   = <20*Schritt+20,0,3>;  // Left Forearm 
    #declare BM_LH_Rot   = <0,0,0>;  // Left Hand

    #if (Schritt >= 0) 
	#declare BM_RL_H2K   = <30*Schritt,0,-5>;  // Right Thigh
	#declare BM_RL_K2A   = <15*Schritt,0,0>;  // Right Lower Leg
	#declare BM_RF_Rot   = <0,0,0>;  // Right Foot

	#declare BM_LL_H2K   = <0,0,5>;  // Left Thigh
	#declare BM_LL_K2A   = <-30*Schritt,0,0>;  // Left Lower Leg
	#declare BM_LF_Rot   = <15*Schritt,0,0>;  // Left Foot

	#declare BM_Toe_Angle  =<15,0,0>;  // x = Left Foot
    #else 
	#declare BM_LL_H2K   = <30*-Schritt,0,-5>;  // Right Thigh
	#declare BM_LL_K2A   = <15*-Schritt,0,0>;  // Right Lower Leg
	#declare BM_LF_Rot   = <0,0,0>;  // Right Foot

	#declare BM_RL_H2K   = <0,0,5>;  // Left Thigh
	#declare BM_RL_K2A   = <-30*-Schritt,0,0>;  // Left Lower Leg
	#declare BM_RF_Rot   = <15*-Schritt,0,0>;  // Left Foot

	#declare BM_Toe_Angle  =<0,0,15*-Schritt>;  // x = Left Foot
    #end

    #declare BM_Hair_On    = 1;
    #declare BM_Hair_Rot   = <0,0,0>;
    #declare BM_Hair_Arch  = 0;
    #declare BM_Hair_Thck  = 0.20;
    #declare BM_Hair_Line  = 4 * rand(rand1)*2;
    #declare BM_Hair_LDpth = rand(rand1) * (1-MF*0.7);
    #declare BM_Hair_Wght  = 0.015;
    #declare BM_Hair_Hght  = 1.5;
    #declare BM_Hair_Length= 5 + rand(rand1)*(5 + MF*5);
    #declare BM_Hair_Curl  = 0.01 * rand(rand1);
    #declare BM_Hair_Col  = <.6,.5,.4> * rand(rand1);

    Blob_Man(MF, Groesse)
    object {
	BlobMan
	#if (Schritt >= 0) 
	    transform BMO_Toe_L
	#else 
	    transform BMO_Toe_R
	#end
	    
	rotate <0, 90, 0>
	translate <i + rand(rand1)*0.8, 0, -0.5 + rand(rand1)*1>
    }
    #declare i = i + 1;
#end

#declare i = 4000;
#while (i < 6000)
    #debug concat ("\nRoboter: ", str(i, 0, 0))
    object {
	roboter
	rotate <0, 180, 0>
	translate <i, 0, -5>
    }
    object {
	roboter
	rotate <0, 0, 0>
	translate <i, 0, 5>
    }
    #declare i = i + 5;
#end

plane {
    <0, 1, 0>, 0.0
    pigment {
	color White*0.7
    }
}

#declare T_Beton = 
    texture {
	pigment {
	    color rgb <1, 1, 1>
	}
	finish {
	    ambient 0.6
	    diffuse 0.3
	    reflection .1
	    specular 0
	    roughness 0.1

	}
    }
#declare T_Fenster = 
    texture {
	pigment {
	    color rgb <0.2, 0.2, 0.5> 
	}
	finish {
	    ambient 0.1
	    diffuse 0.1
	    reflection .25
	    specular 1
	    roughness 0.001

	}
    }

#local ii = 0;
#declare rand2 = seed(1);
#while (ii < 360) 
    #local wm = rand(rand2)*1000;
    #local wd = (wm + 20) / (100000 * pi) * 360;
    #local hd = rand(rand2)*2000;

    box {
	<-50000, 0, 0>
	<-50100, hd, wm>
	texture {
	    quilted 
	    control0 0
	    control1 1
	    texture_map {
		[ 0.0 T_Fenster ]
		[ 0.3 T_Fenster ]
		[ 0.3 T_Beton ]
		[ 1.0 T_Beton ]
	    }
	    scale <10, 5, 10>
	}
	rotate <0, ii, 0>

    }
    #local ii = ii + wd;
#end
