home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / scripts / pov / legoka / legobits.inc next >
Encoding:
Text File  |  1994-05-13  |  21.5 KB  |  579 lines

  1. /*********************************************************************
  2.                             LEGOBITS.INC
  3.  
  4. Usage:  A Persistence of Vision 2.0 include file.
  5.         #include "legobits.inc"
  6.         This file provides a variety of basic LEGO Technic objects,
  7.         plus the subsections needed to build up new ones of your own.
  8.         Now you can have a 5x1 block, or purple LEGO, or whatever.
  9.  
  10. Author: Peter Middlestorb
  11.         CIS:100065,3267
  12.         May 1994
  13.  
  14. Status: Public domain. Fold, spindle or mutilate as you see fit.
  15.  
  16. Acknowledgements:
  17.  
  18.         LEGO is a registered trademark of LEGO Group.
  19.         Much kudos to the POV-Ray Team for producing the excellent
  20.         and freely available Persistence of Vision Raytracer.
  21. *********************************************************************/
  22.  
  23. /*********************************************************************
  24.                             INFORMATION
  25.  
  26. All objects are based on real LEGO Technic blocks at 1 POV unit / mm.
  27. Some dimensions have been idealised a bit. The "gap" has been built
  28. into the objects. Thus to get proper gappy LEGO, you just use the
  29. blocks with a displacement or pitch of 8 units in X and Z, and 9.6
  30. units in Y (3.2 units for the thin slabs). If you make your own object
  31. with a base of blocks or slabs then you may need to translate it by
  32. Y=-0.2, otherwise it will not quite reach the floor due to the
  33. built-in gap at the bottom. The block axle channel centre is Y=5.9.
  34.  
  35. Every non-trivial object, even the ones that are only used to build 
  36. up more complex objects, has a bounding box. This seems to improve
  37. rendering times.
  38. *********************************************************************/
  39.  
  40. /*********************************************************************
  41. a basic 2x1 block
  42.  
  43.       +--------------b
  44.      /              /|
  45.     +--------------+ |
  46.     |              | +
  47.     |              |/   Cell dimensions for positioning blocks:
  48.     a--------------+    a=<0.0, 0.0, 0.0> b=<16.0, 9.6, 8.0)
  49.  
  50. *********************************************************************/
  51.  
  52. //========== former for 2x1 block ==========
  53. #declare objUnionBlock2x1 = union {
  54.     box {< 0.2, 0.2, 0.2>, <15.8, 9.4, 1.5>}            // front
  55.     box {< 0.2, 0.2, 0.2>, < 1.5, 9.4, 7.8>}            // left
  56.     box {<14.5, 0.2, 0.2>, <15.8, 9.4, 7.8>}            // right
  57.     box {< 0.2, 0.2, 6.5>, <15.8, 9.4, 7.8>}            // back
  58.     box {< 0.2, 8.1, 0.2>, <15.8, 9.4, 7.8>}            // top
  59.     cylinder {< 8.0, 5.9, 0.2>, < 8.0,  5.9, 7.8>, 3.5} // axle channel (unbored)
  60.     cylinder {< 8.0, 0.2, 4.0>, < 8.0,  3.0, 4.0>, 1.5} // underside inter-stud pip
  61.     cylinder {< 4.0, 9.4, 4.0>, < 4.0, 11.4, 4.0>, 2.5} // top left stud (unbored)
  62.     cylinder {<12.0, 9.4, 4.0>, <12.0, 11.4, 4.0>, 2.5} // top right stud (unbored)
  63.     bounded_by {
  64.         box {<0.0, 0.0, 0.0>, <16.0, 11.4, 8.0>}
  65.     }
  66. }
  67.  
  68. //========== 2x1 block ==========
  69. #declare objBlock2x1 = difference {
  70.     object {objUnionBlock2x1}
  71.     cylinder {< 8.0, 5.9, 0.1>, < 8.0,  5.9, 7.9>, 2.4}  // axle channel bore
  72.     cylinder {< 8.0, 5.9, 0.1>, < 8.0,  5.9, 0.8>, 3.0}  // front axle channel bezel
  73.     cylinder {< 8.0, 5.9, 7.2>, < 8.0,  5.9, 7.9>, 3.0}  // back axle channel bezel
  74.     cylinder {< 4.0, 9.4, 4.0>, < 4.0, 11.5, 4.0>, 1.7}  // top left stud bore
  75.     cylinder {<12.0, 9.4, 4.0>, <12.0, 11.5, 4.0>, 1.7}  // top tight stud bore
  76.     bounded_by {
  77.         box {<0.0, 0.0, 0.0>, <16.0, 11.4, 8.0>}
  78.     }
  79. }
  80.  
  81. /*********************************************************************
  82. block construction units (cut from the basic 2x1 block)
  83. *********************************************************************/
  84.  
  85. //========== block left cap ==========
  86. #declare objBlockLeftCapx1 = intersection {
  87.     object {objBlock2x1}
  88.     plane {x, 4}
  89.     bounded_by {
  90.         box {<0.0, 0.0, 0.0>, <4.0, 11.4, 8.0>}
  91.     }
  92. }
  93.  
  94. //========== block right cap ==========
  95. #declare objBlockRightCapx1 = intersection {
  96.     object {objBlock2x1
  97.         translate <-12, 0, 0>
  98.     }
  99.     plane {-x, 0}
  100.     bounded_by {
  101.         box {<0.0, 0.0, 0.0>, <4.0, 11.4, 8.0>}
  102.     }
  103. }
  104.  
  105. //========== block body ==========
  106. #declare objBlockBodyx1 = intersection {
  107.     object {objBlock2x1
  108.         translate <-4, 0, 0>
  109.     }
  110.     plane {x, 8}
  111.     plane {-x, 0}
  112.     bounded_by {
  113.         box {<0.0, 0.0, 0.0>, <8.0, 11.4, 8.0>}
  114.     }
  115. }
  116.  
  117. /*********************************************************************
  118. composite blocks made from the block construction units
  119. *********************************************************************/
  120.  
  121. //========== 4x1 block ==========
  122. #declare objBlock4x1 = union {
  123.     object {objBlockLeftCapx1   translate < 0, 0, 0>}   // left cap, stud 1
  124.     object {objBlockBodyx1      translate < 4, 0, 0>}   // studs 1/2
  125.     object {objBlockBodyx1      translate <12, 0, 0>}   // studs 2/3
  126.     object {objBlockBodyx1      translate <20, 0, 0>}   // studs 3/4
  127.     object {objBlockRightCapx1  translate <28, 0, 0>}   // right cap, stud 4
  128.     bounded_by {
  129.         box {<0.0, 0.0, 0.0>, <32.0, 11.4, 8.0>}
  130.     }
  131. }
  132.  
  133. //========== 6x1 block ==========
  134. #declare objBlock6x1 = union {
  135.     object {objBlockLeftCapx1   translate < 0, 0, 0>}   // left cap, stud 1
  136.     object {objBlockBodyx1      translate < 4, 0, 0>}   // studs 1/2
  137.     object {objBlockBodyx1      translate <12, 0, 0>}   // studs 2/3
  138.     object {objBlockBodyx1      translate <20, 0, 0>}   // studs 3/4
  139.     object {objBlockBodyx1      translate <28, 0, 0>}   // studs 4/5
  140.     object {objBlockBodyx1      translate <36, 0, 0>}   // studs 5/6
  141.     object {objBlockRightCapx1  translate <44, 0, 0>}   // right cap, stud 6
  142.     bounded_by {
  143.         box {<0.0, 0.0, 0.0>, <48.0, 11.4, 8.0>}
  144.     }
  145. }
  146.  
  147. //========== 16x1 block ==========
  148. #declare objBlock16x1 = union {
  149.     object {objBlockLeftCapx1   translate < 0,  0, 0>}  // left cap, stud 1
  150.     object {objBlockBodyx1      translate < 4,  0, 0>}  // studs 1/2
  151.     object {objBlockBodyx1      translate < 12, 0, 0>}  // studs 2/3
  152.     object {objBlockBodyx1      translate < 20, 0, 0>}  // studs 3/4
  153.     object {objBlockBodyx1      translate < 28, 0, 0>}  // studs 4/5
  154.     object {objBlockBodyx1      translate < 36, 0, 0>}  // studs 5/6
  155.     object {objBlockBodyx1      translate < 44, 0, 0>}  // studs 6/7
  156.     object {objBlockBodyx1      translate < 52, 0, 0>}  // studs 7/8
  157.     object {objBlockBodyx1      translate < 60, 0, 0>}  // studs 8/9
  158.     object {objBlockBodyx1      translate < 68, 0, 0>}  // studs 9/10
  159.     object {objBlockBodyx1      translate < 76, 0, 0>}  // studs 10/11
  160.     object {objBlockBodyx1      translate < 84, 0, 0>}  // studs 11/12
  161.     object {objBlockBodyx1      translate < 92, 0, 0>}  // studs 12/13
  162.     object {objBlockBodyx1      translate <100, 0, 0>}  // studs 13/14
  163.     object {objBlockBodyx1      translate <108, 0, 0>}  // studs 14/15
  164.     object {objBlockBodyx1      translate <116, 0, 0>}  // studs 15/16
  165.     object {objBlockRightCapx1  translate <124, 0, 0>}  // right cap, stud 16
  166.     bounded_by {
  167.         box {<0.0, 0.0, 0.0>, <128.0, 11.4, 8.0>}
  168.     }
  169. }
  170.  
  171. /*********************************************************************
  172. a basic 2x2 slab
  173.  
  174.        +--------------b
  175.       /              /+
  176.      /              //
  177.     +--------------+/   Cell dimensions for positioning slabs:
  178.     a--------------+    a=<0.0, 0.0, 0.0> b=<16.0, 3.2, 16.0>
  179.  
  180. *********************************************************************/
  181. //========== former for 2x2 slab ==========
  182. #declare objUnionSlab2x2 = union {
  183.     box {< 0.2, 0.2,  0.2>, <15.8, 3.0,  1.5>}              // front
  184.     box {< 0.2, 0.2,  0.2>, < 1.5, 3.0, 15.8>}              // left
  185.     box {<14.5, 0.2,  0.2>, <15.8, 3.0, 15.8>}              // right
  186.     box {< 0.2, 0.2, 14.5>, <15.8, 3.0, 15.8>}              // back
  187.     box {< 0.2, 1.7,  0.2>, <15.8, 3.0, 15.8>}              // top
  188.     cylinder {< 8.0, 0.2,  8.0>, < 8.0, 3.0,  8.0>, 3.2}    // axle channel (unbored)
  189.     cylinder {< 4.0, 3.0,  4.0>, < 4.0, 5.0,  4.0>, 2.5}    // top left front stud
  190.     cylinder {<12.0, 3.0,  4.0>, <12.0, 5.0,  4.0>, 2.5}    // top right front stud
  191.     cylinder {< 4.0, 3.0, 12.0>, < 4.0, 5.0, 12.0>, 2.5}    // top left back stud
  192.     cylinder {<12.0, 3.0, 12.0>, <12.0, 5.0, 12.0>, 2.5}    // top right back stud
  193.     bounded_by {
  194.         box {<0.0, 0.0, 0.0>, <16.0, 5.0, 16.0>}
  195.     }
  196. }
  197.  
  198. //========== 2x2 slab ==========
  199. #declare objSlab2x2 = difference {
  200.     object {objUnionSlab2x2}
  201.     cylinder {< 8.0, 0.1,  8.0>, < 8.0, 3.1,  8.0>, 2.4}   // axle channel bore
  202.     cylinder {< 4.0, 1.6,  4.0>, < 4.0, 3.7,  4.0>, 1.3}   // top left front stud underpip
  203.     cylinder {<12.0, 1.6,  4.0>, <12.0, 3.7,  4.0>, 1.3}   // top right front stud underpip
  204.     cylinder {< 4.0, 1.6, 12.0>, < 4.0, 3.7, 12.0>, 1.3}   // top left back stud underpip
  205.     cylinder {<12.0, 1.6, 12.0>, <12.0, 3.7, 12.0>, 1.3}   // top right back stud underpip
  206.     bounded_by {
  207.         box {<0.0, 0.0, 0.0>, <16.0, 5.0, 16.0>}
  208.     }
  209. }
  210.  
  211. /*********************************************************************
  212. slab construction units (cut from the basic 2x2 slab)
  213. *********************************************************************/
  214.  
  215. //========== slab left cap ==========
  216. #declare objSlabLeftCapx2 = intersection {
  217.     object {objSlab2x2}
  218.     plane {x, 4}
  219.     bounded_by {
  220.         box {<0.0, 0.0, 0.0>, <4.0, 5.0, 16.0>}
  221.     }
  222. }
  223.  
  224. //========== slab right cap ==========
  225. #declare objSlabRightCapx2 = intersection {
  226.     object {objSlab2x2
  227.         translate <-12, 0, 0>
  228.     }
  229.     plane {-x, 0}
  230.     bounded_by {
  231.         box {<0.0, 0.0, 0.0>, <4.0, 5.0, 16.0>}
  232.     }
  233. }
  234.  
  235. //========== slab body ==========
  236. #declare objSlabBodyx2 = intersection {
  237.     object {objSlab2x2
  238.         translate <-4, 0, 0>
  239.     }
  240.     plane {x, 8}
  241.     plane {-x, 0}
  242.     bounded_by {
  243.         box {<0.0, 0.0, 0.0>, <8.0, 5.0, 16.0>}
  244.     }
  245. }
  246.  
  247. /*********************************************************************
  248. composite slabs made from the slab construction units
  249. *********************************************************************/
  250.  
  251. //========== 4x2 slab ==========
  252. #declare objSlab4x2 = union {
  253.     object {objSlabLeftCapx2    translate < 0, 0, 0>}   // left cap, stud 1
  254.     object {objSlabBodyx2       translate < 4, 0, 0>}   // studs 1/2
  255.     object {objSlabBodyx2       translate <12, 0, 0>}   // studs 2/3
  256.     object {objSlabBodyx2       translate <20, 0, 0>}   // studs 3/4
  257.     object {objSlabRightCapx2   translate <28, 0, 0>}   // right cap, stud 4
  258.     bounded_by {
  259.         box {<0.0, 0.0, 0.0>, <32.0, 5.0, 16.0>}
  260.     }
  261. }
  262.  
  263. //========== 6x2 slab ==========
  264. #declare objSlab6x2 = union {
  265.     object {objSlabLeftCapx2    translate < 0, 0, 0>}   // left cap, stud 1
  266.     object {objSlabBodyx2       translate < 4, 0, 0>}   // studs 1/2
  267.     object {objSlabBodyx2       translate <12, 0, 0>}   // studs 2/3
  268.     object {objSlabBodyx2       translate <20, 0, 0>}   // studs 3/4
  269.     object {objSlabBodyx2       translate <28, 0, 0>}   // studs 4/5
  270.     object {objSlabBodyx2       translate <36, 0, 0>}   // studs 5/6
  271.     object {objSlabRightCapx2   translate <44, 0, 0>}   // right cap, stud 6
  272.     bounded_by {
  273.         box {<0.0, 0.0, 0.0>, <48.0, 5.0, 16.0>}
  274.     }
  275. }
  276.  
  277. //========== 8x2 slab ==========
  278. #declare objSlab8x2 = union {
  279.     object {objSlabLeftCapx2    translate < 0, 0, 0>}   // left cap, stud 1
  280.     object {objSlabBodyx2       translate < 4, 0, 0>}   // studs 1/2
  281.     object {objSlabBodyx2       translate <12, 0, 0>}   // studs 2/3
  282.     object {objSlabBodyx2       translate <20, 0, 0>}   // studs 3/4
  283.     object {objSlabBodyx2       translate <28, 0, 0>}   // studs 4/5
  284.     object {objSlabBodyx2       translate <36, 0, 0>}   // studs 5/6
  285.     object {objSlabBodyx2       translate <44, 0, 0>}   // studs 6/7
  286.     object {objSlabBodyx2       translate <52, 0, 0>}   // studs 7/8
  287.     object {objSlabRightCapx2   translate <60, 0, 0>}   // right cap, stud 8
  288.     bounded_by {
  289.         box {<0.0, 0.0, 0.0>, <64.0, 5.0, 16.0>}
  290.     }
  291. }
  292.  
  293. /*********************************************************************
  294. wheel - built up in three stages (tyres are separate)
  295.  
  296. Cell dimensions: If you think of the wheel as facing you then the
  297. centre of the axle channel at the front of the wheel is at <0, 0, 0>.
  298. The axle axis is +Z. The radius is 8.5.
  299.  
  300. *********************************************************************/
  301.  
  302. //========== subtract the wheel centre ==========
  303. #declare objDifferenceWheel = difference {
  304.     cylinder {<0.0, 0.0,  0.0>, <0.0, 0.0, 7.2>, 8.5}
  305.     cylinder {<0.0, 0.0, -0.1>, <0.0, 0.0, 7.3>, 6.0}
  306.     bounded_by {
  307.         box {<-8.5, -8.5, 0.0>, <8.5, 8.5, 7.2>}
  308.     }
  309. }
  310.  
  311. //========== put in the wheel hub and spokes ==========
  312. #declare objUnionWheel = union {
  313.     object {objDifferenceWheel}
  314.     cylinder {<0.0, 0.0, 0.0>, <0.0, 0.0, 7.2>, 3.8}
  315.     box {<-6.0, -0.9, 0.0>, <6.0, 0.9, 7.2>}            // spokes l-r
  316.     bounded_by {
  317.         box {<-8.5, -8.5, 0.0>, <8.5, 8.5, 7.2>}
  318.     }
  319. }
  320.  
  321. //========== subtract the axle slots ==========
  322. #declare objWheel = difference {
  323.     object {objUnionWheel}
  324.     box {<-2.4, -0.9, -0.1>, <2.4, 0.9, 7.3>}            // short slot l-r
  325.     box {<-0.9, -4.0, -0.1>, <0.9, 4.0, 7.3>}            // long slot u-d
  326.     bounded_by {
  327.         box {<-8.5, -8.5, 0.0>, <8.5, 8.5, 7.2>}
  328.     }
  329. }
  330.  
  331. /*********************************************************************
  332. small tyre - built up in four stages
  333.  
  334. Cell dimensions: A small tyre has the same face centre as a wheel. It
  335. has the same thickness (Z dimension), and a radius of 12.5.
  336.  
  337. *********************************************************************/
  338.  
  339. //========== small tread lump ==========
  340. #declare objSmallTreadLump = intersection {
  341.     box {<-0.9, 8.5, 0.0>, <0.9, 12.5, 3.6>}
  342.     cylinder {<0.0, 0.0, 0.0>, <0.0, 0.0, 3.6>, 12.5}
  343. }
  344.  
  345. //========== small tread ring ==========
  346. #declare nSmallTreadAngle = 360 / 22
  347. #declare objSmallTreadRing = union {
  348.     object {objSmallTreadLump rotate <0, 0,  1 * nSmallTreadAngle>}
  349.     object {objSmallTreadLump rotate <0, 0,  2 * nSmallTreadAngle>}
  350.     object {objSmallTreadLump rotate <0, 0,  3 * nSmallTreadAngle>}
  351.     object {objSmallTreadLump rotate <0, 0,  4 * nSmallTreadAngle>}
  352.     object {objSmallTreadLump rotate <0, 0,  5 * nSmallTreadAngle>}
  353.     object {objSmallTreadLump rotate <0, 0,  6 * nSmallTreadAngle>}
  354.     object {objSmallTreadLump rotate <0, 0,  7 * nSmallTreadAngle>}
  355.     object {objSmallTreadLump rotate <0, 0,  8 * nSmallTreadAngle>}
  356.     object {objSmallTreadLump rotate <0, 0,  9 * nSmallTreadAngle>}
  357.     object {objSmallTreadLump rotate <0, 0, 10 * nSmallTreadAngle>}
  358.     object {objSmallTreadLump rotate <0, 0, 11 * nSmallTreadAngle>}
  359.     object {objSmallTreadLump rotate <0, 0, 12 * nSmallTreadAngle>}
  360.     object {objSmallTreadLump rotate <0, 0, 13 * nSmallTreadAngle>}
  361.     object {objSmallTreadLump rotate <0, 0, 14 * nSmallTreadAngle>}
  362.     object {objSmallTreadLump rotate <0, 0, 15 * nSmallTreadAngle>}
  363.     object {objSmallTreadLump rotate <0, 0, 16 * nSmallTreadAngle>}
  364.     object {objSmallTreadLump rotate <0, 0, 17 * nSmallTreadAngle>}
  365.     object {objSmallTreadLump rotate <0, 0, 18 * nSmallTreadAngle>}
  366.     object {objSmallTreadLump rotate <0, 0, 19 * nSmallTreadAngle>}
  367.     object {objSmallTreadLump rotate <0, 0, 20 * nSmallTreadAngle>}
  368.     object {objSmallTreadLump rotate <0, 0, 21 * nSmallTreadAngle>}
  369.     object {objSmallTreadLump rotate <0, 0, 22 * nSmallTreadAngle>}
  370.     bounded_by {
  371.         box {<-12.5, -12.5, 0.0>, <12.5, 12.5, 3.6>}
  372.     }
  373. }
  374.  
  375. //========== small tyre body ==========
  376. #declare objSmallTyreBody = difference {
  377.     cylinder {<0.0, 0.0, 0.0>, <0.0, 0.0, 7.2>, 9.5}
  378.     cylinder {<0.0, 0.0, -0.1>, <0.0, 0.0, 7.3>, 8.5}
  379.     bounded_by {
  380.         box {<-9.5, -9.5, 0.0>, <9.5, 9.5, 7.2>}
  381.     }
  382. }
  383.  
  384. //========== small tyre ==========
  385. #declare objSmallTyre = union {
  386.     object {objSmallTyreBody}
  387.     object {objSmallTreadRing}
  388.     object {objSmallTreadRing
  389.         rotate <0, 0, 0.5 * nSmallTreadAngle>
  390.         translate <0.0, 0.0, 3.6>
  391.     }
  392.     bounded_by {
  393.         box {<-12.5, -12.5, 0.0>, <12.5, 12.5, 7.2>}
  394.     }
  395. }
  396.  
  397. /*********************************************************************
  398. large tyre - built up in five stages
  399.  
  400. Cell dimensions: A large tyre is thicker than a wheel. It should be
  401. translated by <0.0, 0.0, -3.6> when fitting to a wheel, as it
  402. overhangs at the front. The radius is 15.0.
  403.  
  404. *********************************************************************/
  405.  
  406. //========== large tread lump ==========
  407. #declare objLargeTreadLump = intersection {
  408.     box {<-1.2, 12.0, 0.0>, <1.2, 15.0, 5.4>}
  409.     cylinder {<0.0, 0.0, 0.0>, <0.0, 0.0, 5.4>, 15.0}
  410. }
  411.  
  412. //========== large tread ring ==========
  413. #declare nLargeTreadAngle = 360 / 20
  414. #declare objLargeTreadRing = union {
  415.     object {objLargeTreadLump rotate <0, 0,  1 * nLargeTreadAngle>}
  416.     object {objLargeTreadLump rotate <0, 0,  2 * nLargeTreadAngle>}
  417.     object {objLargeTreadLump rotate <0, 0,  3 * nLargeTreadAngle>}
  418.     object {objLargeTreadLump rotate <0, 0,  4 * nLargeTreadAngle>}
  419.     object {objLargeTreadLump rotate <0, 0,  5 * nLargeTreadAngle>}
  420.     object {objLargeTreadLump rotate <0, 0,  6 * nLargeTreadAngle>}
  421.     object {objLargeTreadLump rotate <0, 0,  7 * nLargeTreadAngle>}
  422.     object {objLargeTreadLump rotate <0, 0,  8 * nLargeTreadAngle>}
  423.     object {objLargeTreadLump rotate <0, 0,  9 * nLargeTreadAngle>}
  424.     object {objLargeTreadLump rotate <0, 0, 10 * nLargeTreadAngle>}
  425.     object {objLargeTreadLump rotate <0, 0, 11 * nLargeTreadAngle>}
  426.     object {objLargeTreadLump rotate <0, 0, 12 * nLargeTreadAngle>}
  427.     object {objLargeTreadLump rotate <0, 0, 13 * nLargeTreadAngle>}
  428.     object {objLargeTreadLump rotate <0, 0, 14 * nLargeTreadAngle>}
  429.     object {objLargeTreadLump rotate <0, 0, 15 * nLargeTreadAngle>}
  430.     object {objLargeTreadLump rotate <0, 0, 16 * nLargeTreadAngle>}
  431.     object {objLargeTreadLump rotate <0, 0, 17 * nLargeTreadAngle>}
  432.     object {objLargeTreadLump rotate <0, 0, 18 * nLargeTreadAngle>}
  433.     object {objLargeTreadLump rotate <0, 0, 19 * nLargeTreadAngle>}
  434.     object {objLargeTreadLump rotate <0, 0, 20 * nLargeTreadAngle>}
  435.     bounded_by {
  436.         box {<-15.0, -15.0, 0.0>, <15.0, 15.0, 5.4>}
  437.     }
  438. }
  439.  
  440. //========== large tyre body ==========
  441. #declare objLargeTyreBody = difference {
  442.     cylinder {<0.0, 0.0, 0.0>, <0.0, 0.0, 10.8>, 13.0}
  443.     cylinder {<0.0, 0.0, -0.1>, <0.0, 0.0, 10.9>, 8.5}
  444.     cone {<0.0, 0.0, -0.1>, 10.0, <0.0, 0.0, 3.6>, 8.5}
  445.     bounded_by {
  446.         box {<-13.0, -13.0, 0.0>, <13.0, 13.0, 10.8>}
  447.     }
  448. }
  449.  
  450. //========== large tyre ==========
  451. #declare objLargeTyre = union {
  452.     object {objLargeTyreBody}
  453.     object {objLargeTreadRing}
  454.     object {objLargeTreadRing
  455.         rotate <0, 0, 0.5 * nLargeTreadAngle>
  456.         translate <0.0, 0.0, 5.4>
  457.     }
  458.     bounded_by {
  459.         box {<-15.0, -15.0, 0.0>, <15.0, 15.0, 10.8>}
  460.     }
  461. }
  462.  
  463. /*********************************************************************
  464. rods - for axles etc.
  465.  
  466. Cell dimensions: Rods are centred on the +X axis. Rods have an
  467. effective radius of 2.4, to fit into a block or slab axle channel.
  468.  
  469. *********************************************************************/
  470.  
  471. //========== rod - 3 long ==========
  472. #declare objRodx3 = union {
  473.     box {<0.0, -2.4, -0.9>, <24.0, 2.4, 0.9>}   // x/y
  474.     box {<0.0, -0.9, -2.4>, <24.0, 0.9, 2.4>}   // x/z
  475.     bounded_by {
  476.         box {<0.0, -2.4, -2.4>, <24.0, 2.4, 2.4>}
  477.     }
  478. }
  479.  
  480. //========== rod - 4 long ==========
  481. #declare objRodx4 = union {
  482.     box {<0.0, -2.4, -0.9>, <32.0, 2.4, 0.9>}   // x/y
  483.     box {<0.0, -0.9, -2.4>, <32.0, 0.9, 2.4>}   // x/z
  484.     bounded_by {
  485.         box {<0.0, -2.4, -2.4>, <32.0, 2.4, 2.4>}
  486.     }
  487. }
  488.  
  489. //========== rod - 6 long ==========
  490. #declare objRodx6 = union {
  491.     box {<0.0, -2.4, -0.9>, <48.0, 2.4, 0.9>}   // x/y
  492.     box {<0.0, -0.9, -2.4>, <48.0, 0.9, 2.4>}   // x/z
  493.     bounded_by {
  494.         box {<0.0, -2.4, -2.4>, <48.0, 2.4, 2.4>}
  495.     }
  496. }
  497.  
  498. /*********************************************************************
  499. right angle rod joint and lock
  500.  
  501. Cell dimensions: A untranslated joint would normally join two rods
  502. which were positioned thus:
  503.  
  504. object {objRod                          // X rod
  505.     translate <4.0. 0.0. 0.0>
  506. }
  507. object {objRod                          // Z rod
  508.     rotate <0, -90, 0>
  509.     translate <0.0. 0.0. -4.0>
  510. }
  511.  
  512. It may help to visualise a joint cell as the following box:
  513.  
  514.              // <- Z rod
  515.             //
  516.         +------------b
  517.        /  //        /|
  518.      /   //        / |
  519.     +-------------+  |
  520.     |  //  =======|========== <- X rod
  521.     |  O          | /
  522.     |             |/   
  523.     a-------------+    a=<-4.0, -4.0, -4.0> b=<12.0, 4.0, 4.0)
  524.  
  525. The joint lock goes as the front part of the Z rod channel, and should
  526. be omitted if the Z rod is free to rotate in the joint.
  527.  
  528. *********************************************************************/
  529.  
  530. //========== joint core for z and x axles (x locked) ==========
  531. #declare objUnionRod90Joint = union {
  532.     cylinder {< 0.0, 0.0, 0.0>, < 0.0, 0.0, 3.8>, 3.8}  // z axle core
  533.     cylinder {< 0.0, 0.0, 0.0>, < 5.4, 0.0, 0.0>, 3.8}  // z/x joiner
  534.     cylinder {< 5.4, 0.0, 0.0>, <10.6, 0.0, 0.0>, 2.9}  // x axle core
  535.     cylinder {<10.6, 0.0, 0.0>, <12.0, 0.0, 0.0>, 3.8}  // x axle flange
  536.     bounded_by {
  537.         box {<-3.8, -3.8, -3.8>, <12.0, 3.8, 4.0>}
  538.     }
  539. }
  540.  
  541. //========== subtract axle channels and stuff from joint core ==========
  542. #declare objRod90Joint = difference {
  543.     object {objUnionRod90Joint}
  544.     cylinder {<0.0, 0.0, -0.1>, <0.0, 0.0, 3.9>, 2.4}   // z axle channel (free)
  545.     box {<-0.1, -3.9, -3.9>, < 4.0, 3.9, 0.0>}          // z/x joiner cutout for part 2
  546.     box {< 3.9, -2.4, -0.9>, <12.1, 2.4, 0.9>}          // x axle channel x/y axis
  547.     box {< 3.9, -0.9, -2.4>, <12.1, 0.9, 2.4>}          // x axle channel x/z axis
  548.     bounded_by {
  549.         box {<-3.8, -3.8, -3.8>, <12.0, 3.8, 4.0>}
  550.     }
  551. }
  552.  
  553. //========== lock for z axle ==========
  554. #declare objRod90Lock = difference {
  555.     cylinder {<0.0, 0.0, -3.8>, <0.0, 0.0, 0.0>, 3.8}   // main part
  556.     box {<-2.4, -0.9, -3.9>, <2.4, 0.9, 0.1>}           // z axle channel z/x axis
  557.     box {<-0.9, -2.4, -3.9>, <0.9, 2.4, 0.1>}           // z axle channel z/y axis
  558.     torus {3.8, 0.9                                     // outer lock channel
  559.         rotate <90, 0, 0>
  560.         translate <0.0, 0.0, -1.9>
  561.     }
  562.     bounded_by {
  563.         box {<-3.8, -3.8, -4.0>, <3.8, 3.8, 0.0>}
  564.     }
  565. }
  566.  
  567. //========== joint for z and x axles with both axles locked ==========
  568. #declare objRod90LockJoint = union {
  569.     object {objRod90Joint}
  570.     object {objRod90Lock}
  571.     bounded_by {
  572.         box {<-3.8, -3.8, -4.0>, <12.0, 3.8, 4.0>}
  573.     }
  574. }
  575.  
  576. /*********************************************************************
  577. End of LEGOBITS.INC
  578. *********************************************************************/
  579.