#version 3.7;

#declare Radiosity = true;
#declare IncludeAbramsTank = true;
#declare IncludeFlore = true;
#declare IncludeSwamp = true;
#declare SkySphere = true;
#declare ZodiacBoatPresence = true;

global_settings{ assumed_gamma 1.0 
	#if( Radiosity )
		#default{ finish{ ambient 0 } }
		radiosity{
			pretrace_start 64 / image_width
			pretrace_end   2 / image_width
			error_bound 0.2
			minimum_reuse 0.01
			nearest_count 9
			count 800
			recursion_limit 1
			always_sample off
			low_error_factor 0.5
			gray_threshold 0.6
			brightness 1
			normal on
			media on
			adc_bailout 0.01/2
		}
	#end
}

#declare ArialPath = "fonts/arial.ttf"

//#include "woods.inc"
#include "arrays.inc" //Useful to resize array of little flore
#include "includes2/debugMacros.inc"
#include "includes2/colorsMercenaires.inc"
#include "includes2/texturesMercenaires.inc"
#include "includes2/radiositySky.inc"
#include "includes/textures.inc"
#include "includes/ground.inc"
#include "includes/tent_obj.inc"
#include "includes/campShelter_obj.inc"
#include "includes2/barrelObj.inc"
#include "includes2/ammoCrate.inc"
#include "includes2/woodCrate.inc"
#include "includes/woodDock.inc"
#include "includes/florePlacing.inc"
#include "includes2/affineFunctionSetter.inc"
#include "includes2/customArraysMacros.inc"


#if( ZodiacBoatPresence )
	#include "includes2/zodiacBoat.inc"
#end

#if( IncludeSwamp )
	#include "customFlore/reedObj.inc"
	#include "customFlore/highGrassBlade.inc"
	#include "customFlore/swampFlorePlacing.inc"
#end

#if( IncludeAbramsTank )
    #declare transY = 0.192453; //So the Abrams Bottom (y) is equal to '0' units
    #declare scaleAbrams = 5;
    
    #declare CompleteAbramsDir = "includes2/completeAbrams/";
    #include concat( CompleteAbramsDir, "Abrams_geom.inc" )
#end

#if( IncludeFlore )
	#include "customFlore/plant1.inc"
    #include "povtree/colibri.inc"           					//Load 'Colibri' object
    #include "povtree/flatLeavesPour.inc"    					//Load 'FlatLeavesPour' object
    #include "povtree/flatLeavesUpright.inc" 					//Load 'FlatLeavesUpright' object
    #include "povtree/greenPlant.inc"						 	//Load 'GreenPlant' object
    #include "povtree/kapokTree1.inc"		 					//Load 'KapokTree' object
    #include "povtree/kapokTree2.inc"		 					//Load 'KapokTree' object
    #include "povtree/littleFlore.inc"		 	//Load 'LittleFlore' object
    #include "povtree/wavedBranches.inc"	 					//Load 'WavedBranches' object
    #include "povtree/bush1.inc"
    #include "povtree/birch1.inc"
	#include "povtree/sawedTrunk.inc" 							//Load 'SawedTrunk' object
    #include "includes/florePlantingMacros.inc"
    #include "includes/placeBushes.inc"
    #include "includes/woodBlock.inc"
#end

#declare CamLoc = <0, 34, -80>;
#declare CamLookAt = <0, 22, -2>;
#declare LookVect = CamLookAt - CamLoc;

camera{
	location CamLoc
	look_at CamLookAt
	right image_width / image_height * x
	sky y
	up y
}
	  
light_source{ < 2.5, 7, -5 > * 2400 color srgb < 1.0, 0.9, 0.78 > * 1.65 }

MakeSky( color srgb < 0.8, 0.8, 1 >, 
		color srgb < 143 / 255, 195 / 255, 251 /255 >, 
		3 )

union{
	object{ RiverBankSurroundings 
		texture{ T_brown2 }
		texture{ ScatteredGrassTexture }
	}
	object{ HF_RiverBank 
		texture{ T_brown2 }
		texture{ ScatteredGrassTexture }
		texture{ Pig_RiverStrate scale < 0.1, 1, 0.1 >}
	}
}

plane{ y, 1.8 texture{ WaterTexture } }

object{ MountainA }
object{ MountainB }
object{ MountainC }
object{ MountainD }
object{ MountainE }

object{CamoufledBuilding translate <-14, Y_Ground, 18> }

#declare TentScale = 6;
object{Tent_Main scale TentScale rotate 120*y translate <-2.5, Y_Ground, -1.5>}
object{Tent_Main scale TentScale translate <-2, Y_Ground, 16.5> }

#if( IncludeAbramsTank )
    object{ M1Abrams rotate -90*y translate <-14, Y_Ground, 9*2> }
    object{ M1Abrams rotate 140*y translate <-14, Y_Ground, 2*2> }
#end

union{//This is the second camoufled building at the foreground
	object{CamoufledBuilding translate <8, Y_Ground, 2> }
	#declare BarrilScale = 0.85;
	MakeBlueBarrel(BarrilScale, <2.5*2, Y_Ground, -1.5*2>)
	MakeBlueBarrel(BarrilScale, <3*2, Y_Ground, -1.5*2>)
	MakeBlueBarrel(BarrilScale, <2.6*2, Y_Ground, -0.5*2>)
	MakeBlueBarrel(BarrilScale, <3.1*2, Y_Ground, -0.5*2>)

	#declare WoodCrateScale = 0.75;
	#declare AmmoCrateScale = 0.75;
	//foreground crates
	object{ CrateObj scale WoodCrateScale translate < 4.2 * 2, Y_Ground, 0.5 * 2 > }
	object{ CrateObj scale WoodCrateScale translate < 4.2 * 2, Y_Ground + 2 * WoodCrateScale, 0.5 * 2 > }
	object{ CrateObj scale WoodCrateScale translate < 5 * 2, Y_Ground, 0.5 * 2 > }

	//back crates
	object{ CrateObj scale WoodCrateScale translate < 3.2 * 2, Y_Ground, 2.5 * 2 > }
	object{ CrateObj scale WoodCrateScale translate < 3.2 * 2, Y_Ground + 2 * WoodCrateScale, 2.5 * 2 > }
	object{ CrateObj scale WoodCrateScale translate < 4 * 2, Y_Ground, 2.5 * 2 > }
	
	//foreground ammo crates
	object{ AmmoCrate rotate 180*y scale AmmoCrateScale translate <3.75 * 2, Y_Ground, -1 * 2 >} 
	object{ AmmoCrate rotate 180*y scale AmmoCrateScale translate <4.75 * 2, Y_Ground, -1 * 2 >} 
	translate -2*z
}

object{WoodDock}

#if( ZodiacBoatPresence )
	#declare BoatScale = 4/300;
	object{ ZodiacBoat translate -150*x rotate 90*y scale BoatScale translate < -9.75, 1.8 + FloaterRadius / 2 * BoatScale, -28> }
#end

#if( IncludeSwamp )
	PlaceSwampFlore()
#end

//Flore and trees scene count
#declare GreatTreesNumber = 0;
#declare LittleFloreNumber = 0;
#declare WithGrassLittleFloreNumber = 0; //The little flore that will have grass blades near it
#declare BushesNum = 0;

#if( IncludeFlore )
	#declare LFPArray = array[800]; //LFP stands for 'LittleFlorePosition'
	#declare LFPArrayIndex = 0;
	
	#debug "Placing deep forest elements.\n"
	LoopOverSquares(ForestMin, ForestMax, GreatTreesNumber, LittleFloreNumber, LFPArray, LFPArrayIndex, false)
	
	LoopOverSquares(<32,0,2>,<132,0,24>, GreatTreesNumber, WithGrassLittleFloreNumber, LFPArray, LFPArrayIndex, true) //Trees and plants to east at the foreground
	LoopOverSquares(<-125,0,2>,<-40,0,24>, GreatTreesNumber, WithGrassLittleFloreNumber, LFPArray, LFPArrayIndex, true) //Trees and plants to west at the foreground

	PlaceMountainTrees(BushesNum)

//Placing the sawed Trunks at the foreground
#declare SawedTrunkPositions = array[4]{<8, 0, 21>, <-22, 0, 22>, <-26, 0, 16>, <12, 0, 16> }

PlaceObject( SawedTrunk, SawedTrunkScale + rand(ScaleNoiseSeed) * 0.5, rand(LittleFloreYRotate) * 360, SawedTrunkPositions[0] )
PlaceObject( SawedTrunk, SawedTrunkScale + rand(ScaleNoiseSeed) * 0.5, rand(LittleFloreYRotate) * 360, SawedTrunkPositions[1] )
PlaceObject( SawedTrunk, SawedTrunkScale + rand(ScaleNoiseSeed) * 0.5, rand(LittleFloreYRotate) * 360, SawedTrunkPositions[2] )
PlaceObject( SawedTrunk, SawedTrunkScale + rand(ScaleNoiseSeed) * 0.5, rand(LittleFloreYRotate) * 360, SawedTrunkPositions[3] )

#declare MakeRoomPositions = array[4]{ <-14, 0, 3>, <-14, 0, -5>, <-14, 0, -13>, <-14, 0, -21>}

//Center little flore near most close camouflage structure
PlaceLittleFloreAroundObject( MakeRoomPositions, < -3, 0, -16>, < 25, 0, -9>, WithGrassLittleFloreNumber, <4, 0, 4>, LFPArray, LFPArrayIndex )

PlaceLittleFloreAroundObject( MakeRoomPositions, < -20, 0, -15 >, < -8, 0, -7 >, WithGrassLittleFloreNumber, <4, 0, 24>, LFPArray, LFPArrayIndex )

//Left most little flore
PlaceLittleFloreAroundObject( MakeRoomPositions, < -125, 0, -16>, < -22, 0, -12>, WithGrassLittleFloreNumber, <4, 0, 4>, LFPArray, LFPArrayIndex )

#declare BirchsPositions = array[4]{< 69, 0, -13.5 >, < 56, 0, -4.5 >, < 42, 0, -14 >, < 33, 0, -7 > } 

PlaceObject( Birch1, BirchScale + rand(ScaleNoiseSeed) * 4, rand(LittleFloreYRotate) * 360, BirchsPositions[0] )
PlaceObject( Birch1, BirchScale + rand(ScaleNoiseSeed) * 4, rand(LittleFloreYRotate) * 360, BirchsPositions[1] )
PlaceObject( Birch1, BirchScale + rand(ScaleNoiseSeed) * 4, rand(LittleFloreYRotate) * 360, BirchsPositions[2] )
PlaceObject( Birch1, BirchScale + rand(ScaleNoiseSeed) * 4, rand(LittleFloreYRotate) * 360, BirchsPositions[3] )

PlaceLittleFloreAroundObject( BirchsPositions, <28, 0, -14>, <132, 0, 0>, WithGrassLittleFloreNumber, < 3, 0, 3 >, LFPArray, LFPArrayIndex )

PlaceObject( KapokSawedTrunk1, KapokTreeScale, 0, < 20, - min_extent(KapokSawedTrunk1).y * KapokTreeScale, 26 > )
PlaceObject( KapokSawedTrunk2, KapokTreeScale, 0, < 20 + IntCylRadius * 2 * KapokTreeScale, - min_extent(KapokSawedTrunk2).y * KapokTreeScale, 21 > )
PlaceObject( KapokSawedTrunk1, KapokTreeScale, 0, < 20 + IntCylRadius * 2 * KapokTreeScale * 2.5, - min_extent(KapokSawedTrunk1).y * KapokTreeScale, 24 > )

PlaceGrassBladeAroundLittleFlore( LFPArray, 0.75, 3.1, 1 )

#debug concat("Placed ", str(GreatTreesNumber,0,0), " Trees\n")
#debug concat("Placed ", str(LittleFloreNumber,0,0), " standard little flore plants\n")
#debug concat("Placed ", str(WithGrassLittleFloreNumber,0,0), " with grass blades little flore plants\n")
#debug concat("Placed ", str(BushesNum,0,0), " flores over mountains\n")
#debug concat("LFPArray final size is: ", str( dimension_size( LFPArray, 1), 0, 0 ), " \n")
#debug concat("LFPArray index value is: ", str( LFPArrayIndex, 0, 0 ), " \n")

#end
