home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / scripts / pov / bolt2 / bolt2.pov next >
Encoding:
Text File  |  1993-10-15  |  6.4 KB  |  229 lines

  1. // POV-Ray 2.0 scene, by Dan Farmer 1993
  2. // Requires "corkbump.gif" for both the floor and the metal surfs
  3. // Copyright POV-Team 1993, Uesable and distributable under the
  4. // Freeware Spirit of POV-Ray.
  5. //----------------------
  6. #include "colors.inc"
  7. #include "textures.inc"
  8. #include "shapes.inc"
  9.  
  10. // Modified copies of this base texture are used in some pieces
  11. #declare Bolt_Texture = texture {
  12.     pigment {
  13.         granite         // Going for a galvanized appearance
  14.         color_map {
  15.             [0.0 color Gray70]
  16.             [0.3 color Gray75]
  17.             [0.6 color Gray85]
  18.             [1.0 color Gray70]
  19.         }
  20.         scale <0.25, 0.25, 0.25>
  21.         turbulence 0.15
  22.     }
  23.     finish {
  24.         ambient 0.2
  25.         diffuse 0.6
  26.         reflection 0.1
  27.         brilliance 10
  28.         specular 0.35
  29.         roughness 0.05
  30.     }
  31.     // Fuzz the surface with tiny ripples
  32.     normal { ripples 0.25 frequency 2000 scale <0.05, 0.05, 0.05> }
  33. }
  34.  
  35. // Primitive used for the hex edges of the nut
  36. #declare ZPlane = plane {z,1
  37.     texture { Bolt_Texture
  38.         normal {
  39.             bump_map { gif "corkbump.gif"
  40.                 bump_size -0.75
  41.                 interpolate 0
  42.             }
  43.             translate <-0.5, -0.5, 0>
  44.             scale <2, 1, 2>
  45.         }
  46.     }
  47. }
  48.  
  49. // The end pieces are individually bumped
  50. #declare  Hexagon = intersection {
  51.     object { ZPlane }
  52.     object { ZPlane rotate < 60, 0, 0>}
  53.     object { ZPlane rotate <120, 0, 0>}
  54.     object { ZPlane rotate <180, 0, 0>}
  55.     object { ZPlane rotate <240, 0, 0>}
  56.     object { ZPlane rotate <300, 0, 0>}
  57.     plane {-x, 1
  58.         texture { Bolt_Texture
  59.             normal {
  60.                 bump_map { gif "corkbump.gif"
  61.                     bump_size -0.75
  62.                     interpolate 0
  63.                 }
  64.                 translate <-0.5, -0.5, 0>
  65.                 scale <2, 1, 2>
  66.                 rotate y*90
  67.             }
  68.         }
  69.     }
  70.     plane {x, 1
  71.         texture { Bolt_Texture
  72.             normal {
  73.                 bump_map { gif "corkbump.gif"
  74.                     bump_size -0.75
  75.                     interpolate 0
  76.                 }
  77.                 translate <-0.5, -0.5, 0>
  78.                 scale <2, 1, 2>
  79.             }
  80.                 rotate y*90
  81.         }
  82.     }
  83. }
  84.  
  85.  
  86.  
  87. // Rounded head with slot.  Bump mapped for distressed look
  88. #declare Bolt_Head = intersection {
  89.     difference {
  90.         sphere { <0,0,0>, 1
  91.             texture { Bolt_Texture
  92.                 normal {
  93.                     bump_map { gif "corkbump.gif"
  94.                         bump_size -0.5
  95.                         interpolate 0
  96.                         map_type Sphere_Map
  97.                     }
  98.                 }
  99.             }
  100.         }
  101.         // Slot.  x=depth, y = width
  102.         box { <-1.1, -0.15, -1.1> <-0.15, 0.15, 1.1> }
  103.     }
  104.     box {<-1,-1,-1><0.35, 1, 1>}
  105.     scale <0.75, 1.5, 1.5>
  106.     rotate -x*45
  107. }
  108.  
  109. // Filler for gaps between the threads, w/tapered end
  110. #declare Bolt_Shaft = union {
  111.     object { Disk_X scale <2.5, 0.75, 0.75 > }
  112.     cone { <2.5, 0,0>, 0.75, <2.65,0,0>,0.55 }
  113. }
  114.  
  115. #declare TW=0.5  // Thread width
  116. // Basic thread primitive
  117. #declare Thread = union {
  118.     cone { <-TW/2,0,0>, 0.75, <0,0,0>,1 }
  119.     cone { < 0.0,0,0>, 1.00, <TW/2,0,0>,0.75 }
  120.     rotate -z*7
  121. }
  122.  
  123. // Put it all together for the bolt object
  124. #declare Bolt = union {
  125.     object { Bolt_Head translate -x*2.5 }
  126.     intersection {
  127.         union {
  128.             object { Bolt_Shaft }
  129.             object { Thread translate  x * 4.5 * TW }
  130.             object { Thread translate  x * 4.0 * TW }
  131.             object { Thread translate  x * 3.5 * TW }
  132.             object { Thread translate  x * 3.0 * TW }
  133.             object { Thread translate  x * 2.5 * TW }
  134.             object { Thread translate  x * 2.0 * TW }
  135.             object { Thread translate  x * 1.5 * TW }
  136.             object { Thread translate  x * 1.0 * TW }
  137.             object { Thread translate  x * 0.5 * TW }
  138.             object { Thread translate  x * 0.0 * TW }
  139.             object { Thread translate -x * 0.5 * TW }
  140.             object { Thread translate -x * 1.0 * TW }
  141.             object { Thread translate -x * 1.5 * TW }
  142.             object { Thread translate -x * 2.0 * TW }
  143.             object { Thread translate -x * 2.5 * TW }
  144.             object { Thread translate -x * 3.0 * TW }
  145.             object { Thread translate -x * 3.5 * TW }
  146.             object { Thread translate -x * 4.0 * TW }
  147.             scale <1, 0.85, 0.85>
  148.         }
  149.     // Flatten the sharp edges on the thread, all in one fell-swoop
  150.     cylinder {<-3.5, 0, 0> <2.75, 0, 0>, 0.83  }
  151.     }
  152.     texture { Bolt_Texture }
  153.     bounded_by { cylinder {<-3.45, 0,0> <2.5,0,0>,1.5 } }
  154. }
  155.  
  156. // And now the nut
  157. #declare NutRaw = object { Hexagon scale <0.65, 1.65, 1.65>
  158.     bounded_by {  box { <-1.01, -1.2, -1.01> <1.01,1.2,1.01> }
  159.                   scale <0.651, 1.651, 1.651>
  160.                 }
  161. }
  162. #declare Nut = intersection {
  163.     object { NutRaw }
  164.     sphere { <0,0,0>, 1.9 }
  165.     texture { Bolt_Texture }
  166.     scale <0.65, 1, 1>
  167. }
  168.  
  169. // Place the bolt and nut
  170. #declare Nut_And_Bolt = union {
  171.     object { Bolt rotate y * 180 }
  172.     object { Nut rotate x * 30 translate <-1, 0, 0> }
  173. //    rotate z*90
  174. //    translate y*0.9
  175. //    rotate -z*45        // Fall over
  176. }
  177.  
  178. // "Distressed" cork surface on a plane
  179. #declare Floor = plane { y,-1.65
  180.     texture {
  181.         Cork
  182.         scale <3,3,3>
  183.         normal {
  184.             bump_map { gif "corkbump.gif"
  185.                 bump_size -0.25
  186.                 interpolate 0
  187.             }
  188.             translate <-0.5, -0.5, 0>
  189.             rotate x*90
  190.             scale <160, 1, 160>
  191.             translate <10,0,-320>   // Purely cosmetic.  Uses a better spot on the map
  192.         }
  193.     }
  194. }
  195.  
  196. //--------------------- Camera and lights -------------------
  197.  
  198. #declare StartCam =
  199. camera {
  200.    location <10, 5, -35>
  201.    direction <0, 0, 5.0>
  202.    right <1.3333, 0, 0>
  203.    look_at <0.5, 0 , 0>
  204. }
  205.  
  206. #declare EndCam =
  207. camera {
  208.    location <7, 5, -15>
  209.    direction <0, 0, 2.75>
  210.    right <1.3333, 0, 0>
  211.    look_at <0.5, 0 , 0>
  212. }
  213. //camera { StartCam }
  214. camera { EndCam }
  215.  
  216. light_source { <-15, 15,  -5> color Gray20 fill_light }
  217. light_source { < 10, 15,  -15> color Gray30 fill_light }
  218.  
  219. light_source { <15,  5,  -10> color Gray90
  220. //    area_light <0 10 0> <0 0 4> 4  4
  221. //    adaptive 1
  222. //    jitter
  223. }
  224.  
  225. background { color White }
  226.  
  227. object { Nut_And_Bolt }
  228. object { Floor }
  229.