//An oxygen bottle (for space wallpapers)

#include "metals.inc"

#declare OxygBotBlue = color srgb < 0, 0.15, 0.9 >;
#declare OxygBotGray = color srgb 0.8;
#declare OxygBotBlueTexture = texture{ pigment{ OxygBotBlue } finish{ metallic specular 0.5 roughness 0.01 } }
#declare OxygBotMetal = texture{ pigment{ OxygBotGray } finish{ metallic specular 0.75 roughness 0.01 reflection{ 0.1 } } }
#declare OxygBotMitigerTexture = texture{ pigment{ OxygBotGray } 
									finish{ metallic specular 0.75 roughness 0.01 reflection{ 0.1 0.4 } } 
								}

#declare ScrewFacesNumber = 6;

#declare OxygenBottleContainer = 
merge{
	torus{ 0.175, 0.01 translate 3.625 * y texture{ OxygBotBlueTexture } }
	cylinder{ < 0, 3, 0 >, < 0, 3.625, 0 >, 0.175 texture{ OxygBotBlueTexture } }
	sphere{ < 0, 3, 0 >, 0.5 texture{ OxygBotBlueTexture } }
	cylinder{ 0, < 0, 3, 0 >, 0.5 texture{ OxygBotMetal } }
}

#declare Screw = 
prism{ linear_sweep linear_spline 3.97 4.05, ScrewFacesNumber + 1
	#for( It, 0, ScrewFacesNumber )
		< 	vrotate( < 0.13, 0, 0 >, < 0, 360 / ScrewFacesNumber * It, 0 >).x,
			vrotate( < 0.13, 0, 0 >, < 0, 360 / ScrewFacesNumber * It, 0 >).z >
	#end
}

#declare TopCylinder = 
difference{
	cylinder{ < 0, 4.15, 0 >, < 0, 4.25, 0 >, 0.22 }
	#for( It, 0, 64 )
		prism{ linear_sweep linear_spline 
			4.14, 4.26, 4,
			< -2, 0.3 >, < 2, 0.3 >, < 0, 0.21 >, <-2, 0.3 >
			rotate 360 / 64 * It * y
		}
	#end
}

#declare OxygBotMitiger = 
union{
	cylinder{ < 0, 3.65, 0 >, < 0, 3.8, 0 >, 0.12 }
	cylinder{ < 0, 3.8, 0 >, < 0, 3.815, 0 >, 0.13 }
	cylinder{ < 0, 3.8, 0 >, < 0, 3.95, 0 >, 0.12 }
	cylinder{ < 0, 3.95, 0 >, < 0, 4.15, 0 >, 0.10 }
	object{ Screw }
	object{ TopCylinder }
	cone{ < 0, 3.85, 0 >, 0.1, < 0.165, 3.85, 0 >, 0.11 }
	cylinder{ < 0.165, 3.85, 0 >, < 0.24, 3.85, 0 >, 0.14 }
	texture{ OxygBotMitigerTexture }
}

#declare OxygenBottle =
union{
	object{ OxygenBottleContainer }
	object{ OxygBotMitiger }
}