#include "transforms.inc"

#declare VolcanoIslandSize = 15;	
#declare IslandNum1Trans = transform{ translate <-40, 0, 29> }
#declare IslandNum2Trans = transform{ translate <4, 0, 34> }
#declare VolcanoIslandTrans = transform{ rotate -75*y translate <-VolcanoIslandSize * 12, 0, VolcanoIslandSize * 17> }

#declare SkySphere = sphere { 0, 1
                        texture{
                            pigment{ color srgb <59, 89, 149> / 255 }
                        }
                        scale 4000000 hollow no_shadow
                    }

#declare HelicoBeach_hf = height_field{
								png "heightFields/hf_beach.png" 
								smooth 
								water_level 0.001
								translate <-0.5, -0.001, -0.5>
								scale <32, 0.4, 32>
							    texture{SandTexture3}
							   }
							   
#declare IslandNum1_hf = height_field{
								png "heightFields/island1.png"
								smooth
								water_level 0.001
								translate <-0.5, -0.001, -0.5>
								scale <20, 0.4, 20>
								texture{SandTexture3}
							   }

#declare IslandNum2_hf = height_field{
								png "heightFields/island2.png"
								smooth
								water_level 0.001
								translate <-0.5, -0.001, -0.5>
								scale <20, 0.4, 20>
								texture{SandTexture3}
							   }						   

#declare VolcanoIsland_hf = height_field{
									 png "heightFields/hf_volcanoIsland.png"
									 smooth
									 water_level 0.001
									 translate <-0.5, -0.001, -0.5>
									 scale <20 * VolcanoIslandSize, 4, 20 * VolcanoIslandSize >
									 texture{SandTexture3}
									}

#declare Volcano_hf = height_field{
									png "heightFields/hf_volcano3.png"
									smooth
									water_level 0.001
									translate <-0.5, 0, -0.5>
									scale <20 * 8, 80, 20 * 8>
									translate <-20,0,-20>
									texture{pigment { color srgb < 94, 79, 45> / 255 } }
								}

#declare Ocean = plane{y, 0 texture{WaterTexture } }

#declare Heliport = prism{conic_sweep linear_spline 1, 0.8, 5 <-1,1>, <1,1>, <1,-1>, <-1,-1>, <-1,1> rotate 180*x translate y scale 4 
						  
					}

#declare H_letter = prism{linear_sweep linear_spline 0.8 , 0.81, 13, <-1.5, 2>, <-1, 2>, <-1,0.25>, <1, 0.25>, <1, 2>, <1.5, 2>, 
																 <1.5, -2>, <1, -2>, <1, -0.25>,<-1, -0.25>, <-1,-2>, <-1.5, -2>,
																 <-1.5, 2>
					}

#declare SeedPlace = seed(79);
#declare SeedColor = seed(79230);
#declare Spacing = 0.1;//Aussi increment de la boucle for : règle densité de l'herbe
#declare widthGrassBlade = 0.0075;
#declare GrassBladeFinish = finish{diffuse .8 specular .35 roughness 1e-2}
#declare GBDk = <63, 82, 12>/256; //Grass blade Dark color
#declare GBLg = <109, 130, 67>/256; //Grass blade light color
#declare GCoefDir = < GBLg.x - GBDk.x, GBLg.y - GBDk.y , GBLg.z - GBDk.z>; //Grass col coef dir

#macro GrassBlade(Position, Highness, BladeColor, normalBool, normalVect)
	cylinder{<0, 0, 0>, <0, Highness, 0>, widthGrassBlade scale <0.5, 1, 1>
			 pigment{color srgb BladeColor}
			 finish{GrassBladeFinish}
			 #if( normalBool = false )
				rotate <20 * rand(SeedPlace), 0, 20 * rand(SeedPlace)>
			 #else
				Reorient_Trans(y, Norm)
			 #end
			 translate Position
			}
#end

#macro MakeGrass(HF_Test, GrassBladeSpacing, HalfSize , GrassBladeHighness, MinHighness)
						#for(i, -HalfSize , HalfSize, GrassBladeSpacing)
							#for(j, -HalfSize, HalfSize, GrassBladeSpacing)
								#declare Norm = <0, 0, 0>;
									#declare Position = trace(HF_Test, <i + (rand(SeedPlace) - 0.5)*0.1 , 300, j +(rand(SeedPlace) -0.5) * 0.1>, -y , Norm);
									#if(Norm.x != 0 | Norm.y != 0 | Norm.z != 0)
										#if(rand(SeedPlace) >= 0.75 & Position.y >= MinHighness)
											GrassBlade(  Position, 
                                                        GrassBladeHighness + rand(SeedPlace) * 0.25, 
                                                        <GCoefDir.x*rand(SeedColor)+GBLg.x, GCoefDir.y*rand(SeedColor)+GBLg.y, GCoefDir.z*rand(SeedColor)+GBLg.z>, 
                                                        false, 
                                                        Norm) 
										#end
									#end
								
							#end
						#end
#end

#macro MakeVolcanoGrass(HF_Test, GrassBladeSpacing, HalfSize , GrassBladeHighness, MinHighness)
						#for(i, -HalfSize , HalfSize, GrassBladeSpacing)
							#for(j, -HalfSize, HalfSize, GrassBladeSpacing)
								#declare Norm = <0, 0, 0>;
									#declare Position = trace(HF_Test, <i + (rand(SeedPlace) - 0.5)*0.1 , 200,j +(rand(SeedPlace) -0.5) * 0.1>, -y , Norm);
									#if(Norm.x != 0 | Norm.y != 0 | Norm.z != 0)
										#if(rand(SeedPlace) >= 0.55 & Position.y >= MinHighness)
											GrassBlade(  Position, 
                                                        GrassBladeHighness + rand(SeedPlace) * 0.25, 
                                                        < rand(SeedColor) * 0.75, 0.65 + rand(SeedColor) / 8, 0>, 
                                                        true, 
                                                        Norm) 
										#end
									#end
								
							#end
						#end
#end

#macro PlacePalm(newSize, xpos, ypos, zpos)
	#if( Palms )
		#if( rand(SeedColor) < 0.5 )
			object{PalmA scale newSize translate <xpos*20, ypos, zpos*20> }
		#else
			object{PalmB scale newSize translate <xpos*20, ypos, zpos*20> }
		#end
	#end
#end
