//Stair at entrance

#declare ST_Color = color srgb 1;
#declare ST_Texture = texture{ pigment{ ST_Color } finish{ specular 0.1 roughness 0.1 } }

#declare ST_Width = EntSas_Width;
#declare ST_Depth = 0.5;
#declare ST_StepThickness = 0.025;
#declare ST_HoleRadius = 0.05;
#declare ST_TorusSmallRadius = 0.01;
#declare ST_OnZHolesNumber = 3;
#declare ST_OnXHolesNumber = 8;

#declare ST_Torus = torus{ ST_HoleRadius, ST_TorusSmallRadius sturm }
#declare ST_CylinderHole = cylinder{< 0, -1, 0 >, < 0, 1, 0 >, ST_HoleRadius }
#declare ST_StepsNumber = 6;
#declare ST_SideStalkRadius = 0.1;
#declare ST_BottomStepZCoord = -ST_Depth * 1.1 * 5 - EB_SideLength / 2 - EntSas_Radius * 2 * ( EntSas_ModulesNumber - 1 ) - ST_Depth * 1.5;
#declare ST_TopStepZCoord = -ST_Depth * 1.1 * 0 - EB_SideLength / 2 - EntSas_Radius * 2 * ( EntSas_ModulesNumber - 1 ) - ST_Depth * 1.5;

#declare ST_Step = union{
	difference{
		box{< 0, 0, 0 >, < ST_Width, ST_StepThickness, ST_Depth > }
		#for( ZIt, 0, ST_OnZHolesNumber - 1 )
			#for( XIt, 0, ST_OnXHolesNumber - 1 )
				object{ ST_CylinderHole 
					translate < ( XIt + 1 ) * ST_Width / ( ST_OnXHolesNumber + 1 ), 
								0, 
								( ZIt + 1 ) * ST_Depth / ( ST_OnZHolesNumber + 1 ) > }
			#end
		#end
	}
		#for( ZIt, 0, ST_OnZHolesNumber - 1 )
			#for( XIt, 0, ST_OnXHolesNumber - 1 )
				object{ ST_Torus 
					translate < ( XIt + 1 ) * ST_Width / ( ST_OnXHolesNumber + 1 ), ST_StepThickness, 
								( ZIt + 1 )* ST_Depth / ( ST_OnZHolesNumber + 1 ) > }
			#end
		#end
		texture{ ST_Texture }
	}

#declare ST_SideStalk = union{
	cylinder{ < 0, -5 * 0.2, ST_BottomStepZCoord >, 
			< 0 , 0 * 0.2, ST_TopStepZCoord >, 
			ST_SideStalkRadius }
	cylinder{ < 0, -5 * 0.2, ST_BottomStepZCoord >,
			< 0, -10, ST_BottomStepZCoord >,
			ST_SideStalkRadius }
	cylinder{ < 0, -15 * 0.2, ST_TopStepZCoord >,
			< 0, 0 * 0.2, ST_TopStepZCoord >,
			ST_SideStalkRadius }
	sphere{ < 0, -5 * 0.2, ST_BottomStepZCoord >, ST_SideStalkRadius }
	sphere{ < 0, 0 * 0.2, ST_TopStepZCoord >, ST_SideStalkRadius }
	
	texture{ ST_Texture }
}

#declare ST_CompleteStair = union{
	object{ ST_SideStalk translate -ST_Width / 2 * x }
	object{ ST_SideStalk translate ST_Width / 2 * x }
	object{ ST_SideStalk translate < ST_Width / 2, 1.2, 0 > }
	object{ ST_SideStalk translate < -ST_Width / 2, 1.2, 0 > }
	
	#for( It, 0, ST_StepsNumber - 1 )
		//From top step to bottom step
		object{ ST_Step 
			translate < -ST_Width / 2, 
						-It * 0.2, 
						-ST_Depth * 1.1 * It - EB_SideLength / 2 - EntSas_Radius * 2 * ( EntSas_ModulesNumber - 1 ) - ST_Depth * 2
						> 
		}
	#end
	translate EntranceBuildingMove
}
							