// ------------------------------------------------------------------- // a gear (gear.pov) // // This scene has a simple gear. Its image is in gear.gif. // ------------------------------------------------------------------- #include "colors.inc" // for color definitions #include "textures.inc" // for texture definitions #declare OuterRadius = 4 #declare InnerRadius = 3.5 #declare HoleRadius = 0.5 #declare AxisOuterRadius = 1.6 #declare AxisInnerRadius = 1 #declare Thickness = 1 #declare Offset = 1.6 #declare HoleCenter = 2.5*x // ------------------------------------------------------------------- // Spokes // // Six scaled and rotated boxes serve as spokes. // ------------------------------------------------------------------- #declare OneSpoke = box { < -0.5, -Thickness, -5 >, < 0.5, Thickness, 5 > } #declare Spokes = union { #declare Angle = 0 #while (Angle <= 150) object { OneSpoke rotate Angle*y } #declare Angle = Angle + 30 #end } // ------------------------------------------------------------------- // Body_Primitive // // A primitive body of a gear consists of spokes and a disk. // ------------------------------------------------------------------- #declare Body_Primitive = union { object { Spokes } cylinder { -(Thickness + 0.1)*y, (Thickness + 0.1)*y, OuterRadius } } // ------------------------------------------------------------------- // Remove // // This disk is used for cutting a concave part of the central disk. // ------------------------------------------------------------------- #declare Remove = cylinder { -Thickness*y, Thickness*y, InnerRadius } // ------------------------------------------------------------------- // Body_Without_Holes // // Now using Remove to cut off a disk-like part from the top and // bottom of the central disk. // ------------------------------------------------------------------- #declare Body_Without_Holes = difference { object { Body_Primitive } object { Remove translate Offset*y } object { Remove translate -Offset*y } } // ------------------------------------------------------------------- // Hole_Puncher // ------------------------------------------------------------------- #declare Hole_Puncher = cylinder { HoleCenter - Thickness*y, HoleCenter + Thickness*y, HoleRadius } // ------------------------------------------------------------------- // Body_With_Holes // // Punch eight holes. // ------------------------------------------------------------------- #declare Body_With_Holes = difference { object { Body_Without_Holes } #declare Angle = 0 #while (Angle < 360) object { Hole_Puncher rotate Angle*y } #declare Angle = Angle + 45 #end } // ------------------------------------------------------------------- // Body_With_Axis_Base // // The body, with holes punched, is added with an axis base. // ------------------------------------------------------------------- #declare Body_With_Axis_Base = union { object { Body_With_Holes } cylinder { -Thickness*y, Thickness*y, AxisOuterRadius } } // ------------------------------------------------------------------- // Body // // Now punch a hole in the center for a possible axis. // ------------------------------------------------------------------- #declare Body = difference { object { Body_With_Axis_Base } cylinder { -2*Thickness*y, 2*Thickness*y, AxisInnerRadius } } // camera camera { location < 8, 10, -3 > direction z up y right 4/3*x look_at -y } // The gear object. The object is bounded_by a box to accelerate object { Body texture { Chrome_Metal } scale 0.5*y } // a light source light_source { 10*(y+z) color White }