// beach scene

#declare Beach_Slope	= -2;
#declare Beach_Height	= -.03;
#declare Beach_Y_Scale	= .02;  

#declare Water_Height 	= -.03;

#declare Beach1 = 
height_field {gif "sand.gif" smooth
texture { 
	material_map
	{
  		gif "sandtex2.gif"
  		map_type 0
  		interpolate 2

  		texture{T_Sand1 scale .05}  		// texture for color index # 0
  		texture{T_Sand2 scale .05}  		// texture for color index # 1
  		texture{T_Sand3 scale .05}	  		// texture for color index # 2 
  		texture{T_Sand4 scale .05}	  		// texture for color index # 3   
  		texture{T_Sand5 scale .01}	  		// texture for color index # 4
	} 
	rotate x*90 
}
translate <-.5,0,-.5>
}
 
#declare Beach1a = height_field {gif "sand1.gif" smooth translate <-.5,0,-.5> texture{T_Sand1 scale .1}}

#declare Beach2 =
union {
	object {Beach1}
	object {Beach1 scale <1,1,-1> translate <0,0,1>}
	object {Beach1a scale <-1,1,1> translate <-1,0,0>}
	object {Beach1a scale <-1,1,-1> translate <-1,0,1>} 
	object {Beach1a translate <-2,0,>}
	object {Beach1a scale <1,1,-1> translate <-2,0,1>}
	box {<.5,0,.5><1.5,-.1,-.5> texture{T_Sand3 scale .05}} 
	box {<0,0,.5><5,-.1,-.5> rotate <0,0,-45> translate <1.5,0,0> texture{T_Sand3 scale .05}}
}

#declare Water1 = 
height_field {gif "waves.gif" 
texture { 
	material_map
	{
  		gif "wavestex.gif"
  		map_type 0
  		interpolate 2

  		texture{T_Water2 scale .5}  		// texture for color index # 0
  		texture{T_Water3 scale .5}  		// texture for color index # 1
  		texture{T_Water1 scale .5}	  		// texture for color index # 2 
	} 
	rotate x*90 
}
translate <-.5,0,-.5> 
} 

#declare Water2 =
union {
	object {Water1}
	object {Water1 scale <1,1,-1> translate <0,0,1>}
	object {Water1 scale <-1,1,1> translate <1,0,1>}
	object {Water1 scale <-1,1,-1> translate <1,0,1>}
}



#declare Beach_Length = 30;
#declare Count1 = 0;

#while (Count1 < Beach_Length)

	object {Beach2 scale <2,Beach_Y_Scale,1> rotate <0,0,Beach_Slope> translate <0,Beach_Height,(-.5 + (Count1 * 1))>}

	#if (Switch_Water = on)
		object {Water2 scale <4,.1,2> translate <2.25,(Water_Height + Beach_Height),(-.5 + (Count1 * 2))>}   
	#end
	
	#declare Count1 = (Count1 + 1);

#end