//The hangar into the background

#declare YellowColor = color srgb < 1, 1, 0 >;
#declare BlackColor = color srgb 0;
#declare Transparent = color srgbt 1 filter 0;

#declare HangarMetalTexture =
texture{ pigment{ color srgb 0.65 } finish{ specular 0.1 roughness 0.001 } }

#declare TakeOffTrackStoneTexture =
texture{ pigment{ color srgb 0.5 } normal{ granite 0.04 scale 4 } finish{ specular 0.001 roughness 0.001 } }

#declare YellowBlackStripe = 
texture{ pigment{ gradient < 1, 1, 1 > color_map{ [0.0 YellowColor ][0.5 YellowColor ][ 0.5 BlackColor ][1.0 BlackColor ] } scale 1} 
		finish{ specular 0.1 roughness 0.01 } 
}

#declare PlanetDirtPigment =
pigment{ bozo color_map{ [0 PlanetColor][0.4 PlanetColor ][ 0.4 Transparent ][1 Transparent] } scale 0.05 / 8 }

#declare PlanetDirtFinalPigment =
pigment{ wrinkles pigment_map{ [0 PlanetDirtPigment][0.35 PlanetDirtPigment][0.35 Transparent][1.0 Transparent] } scale 4 }

#declare HangarDeepness = 60;
#declare HangarWidth = 50;
#declare HangarYRotate = -108;

#declare HangarBack =
prism{ conic_sweep linear_spline
	1, 0.75, 7
	< HangarWidth / 2, 0 >, < HangarWidth / 2, 15 >, < HangarWidth / 2 - 5, 20 >, < -HangarWidth / 2 + 5, 20 >, < -HangarWidth / 2, 15 >,  < -HangarWidth / 2, 0 >, < HangarWidth / 2, 0 >
	rotate 180 * x
	translate y
	rotate 180 * y
	scale < 1, 10, 1 >
	translate HangarDeepness * y
	texture{ HangarMetalTexture }
}

#declare HangarCenter =
prism{ linear_sweep linear_spline
	0, HangarDeepness, 13
	< HangarWidth / 2, 0 >, < HangarWidth / 2, 15 >, < HangarWidth / 2 - 5, 20 >, < -HangarWidth / 2 + 5, 20 >, < -HangarWidth / 2, 15 >,  < -HangarWidth / 2, 0 >, 
	< -HangarWidth / 2 + 2, 0 >,
	< -HangarWidth / 2 + 2, 15 >, < -HangarWidth / 2 + 5, 18 >, < HangarWidth / 2 - 5, 18 >, < HangarWidth / 2 - 2, 15 >, < HangarWidth / 2 - 2, 0 >, < HangarWidth / 2, 0 >,
	texture{ HangarMetalTexture }
}

#declare HangarTakeOffTrack =
box{ < -20, 0, -HangarDeepness >, < 20, 0.5, 160 > 
	texture{ TakeOffTrackStoneTexture }
	texture{ pigment{ PlanetDirtFinalPigment } }
}

#declare TakeOffTrackMileStone =
prism{ linear_sweep linear_spline
	-0.2, 0.2, 5
	< 0, 0 >, < -2, 0 >, < -1, 1 >, < 0, 1 >, < 0, 0 >
	rotate -90 * x
	scale 1.25
	texture{ YellowBlackStripe }
}

#declare HangarLightSpot =
union{
	superellipsoid{ < 0.2, 0.2 > scale < 0.5, 0.5, 1 > 
		material{
			texture{ pigment{ color srgbt < 1, 1, 1, 0.9 > } finish{ specular 0.5 roughness 0.01 } }
			interior{ ior 1.5 }
		}
		hollow
		no_shadow
	}
	light_source{ < 0, 0, 0 > color srgb 1 fade_distance 30 fade_power 2 }
}

#declare HangarStructure =
union{
	object{ HangarCenter rotate -90 * x }
	object{ HangarBack rotate -90 * x }
	object{ HangarTakeOffTrack }
	#for( ItZ, 0, 150, 20 )
		object{ TakeOffTrackMileStone translate < -19, 0.25, ItZ > }
		object{ TakeOffTrackMileStone rotate 180 * y translate < 19, 0.25, ItZ > }
	#end
	object{ HangarLightSpot translate < 0, 18 - 1 * 0.5, -50 > }
	object{ HangarLightSpot translate < 0, 18 - 1 * 0.5, -30 > }
	object{ HangarLightSpot translate < 0, 18 - 1 * 0.5, -10 > }
	
	scale 0.475
	rotate HangarYRotate * y
}
