home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / TREES_3A.ZIP / Trees.inc < prev    next >
Encoding:
Text File  |  1997-05-04  |  26.9 KB  |  957 lines

  1. // Persistence of Vision Ray Tracer INCLUDE File
  2. // File:    Trees.inc
  3. // Vers:    3.01 Watcom Win32
  4. // Desc:    Object Definition Code for Trees
  5. // Date:    April 1, 1997
  6. // Auth:    Sonya Roberts
  7.  
  8.  
  9. #debug "Creating Tree Elements...\n"
  10.  
  11.  
  12. // ==== Default Settings ====
  13. #debug " - Setting up default values\n"
  14.  
  15. #ifndef (True)        #declare True=1            #end
  16. #ifndef (False)        #declare False=0        #end
  17. #ifndef (MaxSplits)    #declare MaxSplits=4        #end    // Maximum number of forks in a section of Tree (minimum of 1)
  18. #ifndef (MinSplits)    #declare MinSplits=3        #end    // Minimum number of forks in a section of Tree (minimum of 1)
  19. #ifndef (IncSplits)    #declare IncSplits=1        #end    // To Increase Max. Splits near Branch Tips, Make > 1 - KEEP IT SMALL!
  20. #ifndef (BaseLen)    #declare BaseLen=1        #end    // Base Length (length of smallest twig - determines scale of tree)
  21. #ifndef (LengthInc)    #declare LengthInc=1.2        #end    // Factor By Which to Increase Base Length
  22. #ifndef (MinXDeg)    #declare MinXDeg=35        #end    // Minimum X-rotation of forks
  23. #ifndef (MaxXDeg)    #declare MaxXDeg=55        #end    // Maximum X-rotation of forks
  24. #ifndef (IncXDeg)    #declare IncXDeg=0        #end    // Number of degrees to increment X by at each level
  25. #ifndef (MinYDeg)    #declare MinYDeg=0        #end    // Minimum Y-rotation of forks
  26. #ifndef (MaxYDeg)    #declare MaxYDeg=360        #end    // Maximum Y-rotation of forks        // NOTE: 2nd-Level Branches always based on 360 degrees
  27. #ifndef (IncYDeg)    #declare IncYDeg=0        #end    // Number of degrees to increment Y by at each level
  28. #ifndef (MinZDeg)    #declare MinZDeg=0        #end    // Minimum Z-rotation of forks        // Z-rotations highly optional - not required at all
  29. #ifndef (MaxZDeg)    #declare MaxZDeg=0        #end    // Maximum Z-rotation of forks
  30. #ifndef (IncZDeg)    #declare IncZDeg=0        #end    // Number of degrees to increment Z by at each level
  31. #ifndef (PlusMinus)    #declare PlusMinus=20        #end    // Angle of change of terminal fork
  32. #ifndef (SD1)        #declare SD1=seed(2)        #end    // Seed for random numbers - changing only this will create a different tree of the same species
  33. #ifndef (SD2)        #declare SD2=seed(1997)        #end    // Seed for additional randum numbers - so tree shape won't change from optional code
  34. #ifndef (SD3)        #declare SD3=seed(1)        #end    // Seed for additional randum numbers - so tree shape won't change from optional code
  35. #ifndef (BallJoint)    #declare BallJoint=True        #end    // Turns on and off the spheres used to smooth intersections of the branches and trunks
  36. #ifndef (BallLevels)    #declare BallLevels=2        #end    // Maximum Number of Levels to smooth when BallJoint=True (integer from 1 to 5 inclusive)
  37. #ifndef (LeafNum)    #declare LeafNum=3        #end    // Number of Leaves (not counting leaf object at tip of twig)
  38. #ifndef (LeafRosette)    #declare LeafRosette=False    #end    // If true, leaves are arranged in rosette around twig rather than spiral up twig
  39. #ifndef (LeafRandRot)    #declare LeafRandRot=False    #end    // Rotate the leaves around the twig at random angles (cannot be combined with LeafRosette)
  40.  
  41. #ifndef (Tip)        #declare Tip=1            #end    // Select either 0=None, 1=Leaf, 2=Fruit, or 3=Flower
  42. #ifndef (TipPercent)    #declare TipPercent=1        #end    // Percentage of tips that should have a tip object
  43. #ifndef (TipOther)    #declare TipOther=1        #end    // Tip object to use when the remaining percent of the time
  44.  
  45. #ifndef (LeafShape)    #declare LeafShape=0        #end    // Select leaf: 0=Default Oval, 1=User (Leave), 2=Maple/Ivy, 3=Teardrop, 4=Bent Leaf, 5=Pine, 6=Oak Map, 7=Gingko Map, 8=Palmetto Map
  46. #ifndef (LeafTexture)    #declare LeafTexture=0        #end    // Select leaf texture: 0=Default PaleGreen, 1=User (Leaves), 2=Dark Green, 3=Lime Green, 4=YellowGreen, 5=Wheat
  47.  
  48. #ifndef (FruitShape)    #declare FruitShape=0        #end    // Select fruit: 0=Small Sphere, 1=User (Fruits), 2=Large Sphere, 3=Lemon, 4=Banana, 5=Three Berries
  49. #ifndef (FruitTexture)    #declare FruitTexture=0        #end    // Select fruit texture: 0=Default Red, 1=User (Fruity), 2=Orange, 3=Blackberry, 4=Peach/Yellow, 5=White
  50.  
  51. #ifndef (BarkTexture)    #declare BarkTexture=0        #end    // Select bark: 0=Default Brown, 1=User (Bark), 2=Birch, 3=Poplar, 4=Pine, 5=Lighter Brown
  52.  
  53. #ifndef (FlowerShape)    #declare FlowerShape=0        #end    // Select flower: 0=Default, 1=User (Flowers), 2=Trumpet, 3=Cup, 4=Spiky, 5=Arches
  54. #ifndef (FlowerTexture)    #declare FlowerTexture=0    #end    // Select flower texture: 0=Default (White/Orchid Gradient), 1=User (Bloom), 2=Red & White Radial, 3=White, 4=Orange=Yellow Gradient, 5=Purple-Violet Gradient
  55.  
  56. // ---- SET UP VARIABLES AND PIECES OF TREE
  57. #declare TreeBarkTexture=
  58. texture {
  59.     #switch (BarkTexture)
  60.         #case (0)                            // Default Bark
  61.             #debug " - Using default bark\n"
  62.             pigment {color Tan}
  63.             normal {
  64.                 bumps .6
  65.                 scale <.05,.1,.05>
  66.             }
  67.         #break
  68.  
  69.         #case (1)                            // User-defined Bark Texture
  70.             #ifndef (Bark)
  71.                 #debug " - You have not defined \"Bark\", using default bark in its place\n"
  72.                 pigment {color Tan}
  73.                 normal {
  74.                     bumps .6
  75.                     scale <.05,.1,.05>
  76.                 }
  77.                 #else
  78.                     #debug " - Using user-defined \"Bark\" texture\n"
  79.                 Bark
  80.             #end
  81.         #break
  82.  
  83.         #case (2)                            // Birch Bark (White and Black)
  84.             #debug " - Using birch bark texture\n"
  85.             pigment {
  86.                 agate
  87.                 color_map {
  88.                     [0.00 color rgb<0.000, 0.000, 0.000>]
  89.                     [0.17 color rgb<0.000, 0.000, 0.000>]
  90.                     [0.18 color rgb<1.000, 1.000, 1.000>]
  91.                     [0.57 color rgb<1.000, 1.000, 1.000>]
  92.                     [0.58 color rgb<0.000, 0.000, 0.000>]
  93.                     [0.63 color rgb<0.000, 0.000, 0.000>]
  94.                     [0.63 color rgb<1.000, 1.000, 1.000>]
  95.                     [1.00 color rgb<1.000, 1.000, 1.000>]
  96.                 }
  97.                 rotate <0.0, 0.0, 90.0>
  98.             }
  99.             finish {
  100.                 ambient 0.3
  101.             }
  102.             scale <2.0, 0.1, 2.0>
  103.         #break
  104.  
  105.         #case (3)                            // Poplar (Greenish Tan)
  106.             #debug " - Using poplar bark texture\n"
  107.             pigment {
  108.                 granite
  109.                 color_map {
  110.                     [0.00 color rgb<0.608, 0.596, 0.424>]
  111.                     [0.24 color rgb<0.514, 0.588, 0.392>]
  112.                     [0.51 color rgb<0.639, 0.651, 0.451>]
  113.                     [0.52 color rgb<0.506, 0.408, 0.071>]
  114.                     [0.59 color rgb<0.498, 0.396, 0.071>]
  115.                     [0.60 color rgb<0.710, 0.698, 0.490>]
  116.                     [1.00 color rgb<0.718, 0.706, 0.490>]
  117.                 }
  118.                 rotate <0.0, 0.0, 90.0>
  119.             }
  120.             finish {
  121.                 ambient 0.3
  122.             }
  123.             scale <2.0, 0.1, 2.0>
  124.         #break
  125.  
  126.         #case (4)                            // Pine (lots of greys & a touch of green)
  127.             #debug " - Using pine bark texture\n"
  128.             pigment {
  129.                 bozo
  130.                 turbulence 0.43
  131.                 color_map {
  132.                     [0.00 color rgb<0.612, 0.612, 0.612>]
  133.                     [0.21 color rgb<0.859, 0.859, 0.859>]
  134.                     [0.22 color rgb<0.310, 0.310, 0.310>]
  135.                     [0.28 color rgb<0.298, 0.298, 0.298>]
  136.                     [0.29 color rgb<0.859, 0.859, 0.859>]
  137.                     [0.40 color rgb<0.612, 0.612, 0.612>]
  138.                     [0.54 color rgb<0.459, 0.620, 0.573>]
  139.                     [0.76 color rgb<0.761, 0.761, 0.761>]
  140.                     [0.80 color rgb<0.267, 0.267, 0.267>]
  141.                     [0.84 color rgb<0.659, 0.659, 0.659>]
  142.                     [1.00 color rgb<0.800, 0.800, 0.800>]
  143.                 }
  144.             }
  145.             normal {
  146.                 wrinkles 0.37
  147.                 turbulence 0.27
  148.             }
  149.             finish {
  150.                 ambient 0.28
  151.                 phong 0.16
  152.             }
  153.             scale <0.1, 0.2, 0.1>
  154.         #break
  155.  
  156.         #case (5)                            // Lighter Brown Bark
  157.             #debug " - Using lighter brown bark\n"
  158.             pigment {color NewTan}
  159.             normal {
  160.                 bumps .6
  161.                 scale <.05,.1,.05>
  162.             }
  163.             finish {
  164.                 ambient .3
  165.                 phong .3
  166.             }
  167.         #break
  168.  
  169.     #end
  170. }
  171.  
  172. #if (Tip=2 | TipOther=2)
  173.     #if (FruitShape !=1)
  174.         #declare TreeFruitTexture=
  175.         texture {
  176.             #switch (FruitTexture)
  177.                 #case (0)                            // Default Red Texture
  178.                     #debug " - Using default red fruit texture\n"
  179.                     pigment {color Red}
  180.                     finish {
  181.                         ambient .5
  182.                         phong .3
  183.                     }
  184.                 #break
  185.  
  186.                 #case (1)                            // User defined fruit texture
  187.                     #ifndef (Fruity)
  188.                         #debug " - 'Fruity' not defined, using default fruit texture in its place\n"
  189.                         pigment {color Red}
  190.                         finish {
  191.                             ambient .5
  192.                             phong .3
  193.                         }
  194.                         #else
  195.                         Fruity
  196.                     #end
  197.                 #break
  198.  
  199.                 #case (2)                            // Orange texture
  200.                     #debug " - Using orange fruit texture\n"
  201.                     pigment {color Orange}
  202.                     normal {
  203.                         dents .8
  204.                         scale <.15,.15,.15>
  205.                     }
  206.                     finish {
  207.                         ambient .3
  208.                         phong .3
  209.                         phong_size 80
  210.                     }
  211.                 #break
  212.  
  213.                 #case (3)                            // Blackberry texture
  214.                     #debug " - Using blackberry fruit texture\n"
  215.                     pigment {color DarkSlateBlue}
  216.                     finish {
  217.                         ambient .15
  218.                         phong .25
  219.                     }
  220.                 #break
  221.  
  222.                 #case (4)                            // Peach and Yellow texture
  223.                     #debug " - Using peach and yellow fruit texture\n"
  224.                     pigment {
  225.                         bozo
  226.                         color_map {
  227.                             [0 color rgb <.78,.66,.49>]
  228.                             [1 color rgb <.96,.96,.75>]
  229.                         }
  230.                     }
  231.                     finish {
  232.                         ambient .3
  233.                         phong .25
  234.                     }
  235.                     scale <.005,.005,.005>
  236.                 #break
  237.  
  238.                 #case (5)                            // White texture
  239.                     #debug " - Using white fruit texture\n"
  240.                     pigment {color White}
  241.                     finish {
  242.                         ambient .3
  243.                         phong .25
  244.                         phong_size 120
  245.                     }
  246.                 #break
  247.             #end
  248.             scale <BaseLen,BaseLen,BaseLen>
  249.         }
  250.     #end
  251.  
  252.     #declare Fruit=
  253.     object {
  254.         #switch (FruitShape)
  255.             #case (0)                            // Small Sphere
  256.                 #debug " - Using small spherical fruit object\n"
  257.                 sphere {<0,.095,0>,.1}
  258.             #break
  259.  
  260.             #case (1)                            // User Defined Fruit Shape
  261.                 #ifndef (Fruits)
  262.                     #debug " - 'Fruits' not defined, using default fruit in its place\n"
  263.                     sphere {<0,.095,0>,.1}
  264.                     pigment {color Red}
  265.                     finish {
  266.                         ambient .5
  267.                         phong .3
  268.                     }
  269.                     #else
  270.                         Fruits
  271.                 #end
  272.             #break
  273.  
  274.             #case (2)                            // Large Sphere
  275.                 #debug " - Using large spherical fruit object\n"
  276.                 sphere {<0,.25,0>,.25}
  277.             #break
  278.  
  279.             #case (3)                            // Lemon
  280.                 #debug " - Using lemon-shaped fruit object\n"
  281.                 union {
  282.                     cone {<0,0,0>,.05,<0,.05,0>,.1}
  283.                     sphere {
  284.                         <0,.2,0>,.2
  285.                         scale <1,1.25,1>
  286.                         translate <0,.05,0>
  287.                     }
  288.                     cone {<0,.55,0>,.1,<0,.6,0>,.03}
  289.                 }
  290.             #break
  291.  
  292.             #case (4)                            // Banana
  293.                 #debug " - Using banana-like fruit object\n"
  294.                 superellipsoid {
  295.                     <.95,.15>
  296.                     rotate x*90
  297.                     scale <.075,.5,.075>
  298.                 }
  299.             #break
  300.  
  301.             #case (5)                            // Three Berries
  302.                 #debug " - Using three berries fruit object\n"
  303.                 union {
  304.                     sphere {<0,.095,0>,.1    translate <0,0,.095>}
  305.                     sphere {<0,.095,0>,.1    translate <0,0,.095>    rotate y*120}
  306.                     sphere {<0,.095,0>,.1    translate <0,0,.095>    rotate y*-120}
  307.                 }
  308.             #break
  309.  
  310.             #case (6)                            // Pear
  311.                 #debug " - Using pear-shaped fruit object\n"
  312.                 blob {
  313.                     threshold .2
  314.                     sphere {<0,.1,0>,.245,1}
  315.                     sphere {<0,.425,0>,.375,1}
  316.                 }
  317.             #break
  318.         #end
  319.  
  320.         #if (FruitShape!=1)
  321.             texture {TreeFruitTexture}
  322.         #end
  323.         scale <BaseLen,BaseLen,BaseLen>
  324.     }
  325. #end
  326.  
  327. #if (Tip=3 | TipOther=3)
  328.     #if (FlowerShape!=1)
  329.         #declare TreeFlowerTexture=
  330.         texture {
  331.             #switch (FlowerTexture)
  332.                 #case (0)
  333.                     #debug " - Using default flower texture (white & orchid gradient)\n"
  334.                     pigment {
  335.                         gradient y
  336.                         color_map {
  337.                             [0    color White]
  338.                             [.25    color White]
  339.                             [1    color Orchid]
  340.                         }
  341.                     }
  342.                     finish {
  343.                         ambient .25
  344.                     }
  345.                 #break
  346.  
  347.                 #case (1)
  348.                     #ifndef (Bloom)
  349.                         #debug " - 'Bloom' not defined, using default flower texture in its place\n"
  350.                         pigment {
  351.                             gradient y
  352.                             color_map {
  353.                                 [0    color White]
  354.                                 [.25    color White]
  355.                                 [1    color Orchid]
  356.                             }
  357.                         }
  358.                         finish {
  359.                             ambient .25
  360.                         }
  361.                         #else
  362.                         #debug " - Using user-defined flower texture\n"
  363.                         Bloom
  364.                     #end
  365.                 #break
  366.  
  367.                 #case (2)
  368.                     #debug " - Using red & white radial flower texture\n"
  369.                     pigment {
  370.                         radial
  371.                         color_map {
  372.                             [0    color White]
  373.                             [.1    color Red]
  374.                             [.2    color White]
  375.                             [.3    color Red]
  376.                             [.4    color White]
  377.                             [.5    color Red]
  378.                             [.6    color White]
  379.                             [.7    color Red]
  380.                             [.8    color White]
  381.                             [.9    color Red]
  382.                             [1    color White]
  383.                         }
  384.                     }
  385.                     finish {
  386.                         ambient .25
  387.                     }
  388.                 #break
  389.  
  390.                 #case (3)
  391.                     #debug " - Using white flower texture\n"
  392.                     pigment {color White}
  393.                     finish {
  394.                         ambient .35
  395.                     }
  396.                 #break
  397.  
  398.                 #case (4)
  399.                     #debug " - Using orange-yellow gradient\n"
  400.                     pigment {
  401.                         gradient y
  402.                         color_map {
  403.                             [0    color Orange]
  404.                             [1    color Yellow]
  405.                         }
  406.                     }
  407.                     finish {
  408.                         ambient .25
  409.                     }
  410.                 #break
  411.  
  412.                 #case (5)
  413.                     #debug " - Using purple-violet gradient\n"
  414.                     pigment {
  415.                         gradient y
  416.                         color_map {
  417.                             [0    color Very_Light_Purple]
  418.                             [1    color VioletRed]
  419.                         }
  420.                     }
  421.                     finish {
  422.                         ambient .3
  423.                     }
  424.                 #break
  425.             #end
  426.             scale <BaseLen,BaseLen,BaseLen>
  427.         }
  428.     #end
  429.  
  430.     #declare Flower=
  431.     object {
  432.         #switch (FlowerShape)
  433.  
  434.             #case (0)        // Default 5-Petalled Flower
  435.                 #debug " - Using default 5-petaled flower\n"
  436.                 #declare PetalNum=5
  437.  
  438.                 #declare FlowerPetal=
  439.                 object {
  440.                     sphere {<0,.095,0>,.1}
  441.                     texture {TreeFlowerTexture    scale <.2,.2,.2>}
  442.                     rotate x*90
  443.                     scale <4/PetalNum,.01,1.5>
  444.                 }
  445.  
  446.                 union {
  447.                     sphere {
  448.                         <0,0,0>,.075
  449.                         scale <1,.25,1>
  450.                         pigment {color Yellow}
  451.                     }
  452.                     #declare P1=1
  453.                     #while (P1<=PetalNum)
  454.                         object {
  455.                             FlowerPetal
  456.                             rotate z*25
  457.                             rotate x*-20
  458.                             translate <0,0,.04>
  459.                             rotate y*((360/PetalNum)*P1)
  460.                         }
  461.                         #declare P1=P1+1
  462.                     #end
  463.                 }
  464.             #break
  465.  
  466.             #case (1)        // User Defined (Flowers)
  467.                 #ifndef (Flowers)
  468.                     #debug " - 'Flowers' not defined, using default flower in its place\n"
  469.                     #declare PetalNum=5
  470.  
  471.                     #declare TreeFlowerTexture=
  472.                     pigment {
  473.                         gradient y
  474.                         color_map {
  475.                             [0    color White]
  476.                             [.25    color White]
  477.                             [1    color Orchid]
  478.                         }
  479.                     }
  480.                     finish {
  481.                         ambient .25
  482.                     }
  483.  
  484.                     #declare FlowerPetal=
  485.                     object {
  486.                         sphere {<0,0,.095>,.1}
  487.                         texture {TreeFlowerTexture    scale <.2,.2,.2>}
  488.                         scale <4/PetalNum,.01,1.5>
  489.                     }
  490.  
  491.                     union {
  492.                         sphere {
  493.                             <0,0,0>,.075
  494.                             scale <1,.25,1>
  495.                             pigment {color Yellow}
  496.                         }
  497.                         #declare P1=1
  498.                         #while (P1<=PetalNum)
  499.                             object {
  500.                                 FlowerPetal
  501.                                 rotate z*25
  502.                                 rotate x*-20
  503.                                 translate <0,0,.04>
  504.                                 rotate y*((360/PetalNum)*P1)
  505.                             }
  506.                             #declare P1=P1+1
  507.                         #end
  508.                     }
  509.                     #else
  510.                     #debug " - Using user-defined flower object\n"
  511.                         Flowers
  512.                 #end
  513.             #break
  514.  
  515.             #case (2)        // Trumpet Flower
  516.                 #debug " - Using trumpet-flower\n"
  517.                 lathe {
  518.                     quadratic_spline 7,
  519.                     <0,-.1>, <0,0>, <.1,.3>, <.3,.5>, <.5,.6>, <.8,.7>, <.9,.8>
  520.                     scale <.5,.75,.5>
  521.                 }
  522.                 texture {
  523.                     TreeFlowerTexture
  524.                     scale <.5,.75,.5>
  525.                 }
  526.             #break
  527.             
  528.             #case (3)        // Cup-shaped Flower
  529.                 #debug " - Using cup-shaped flower\n"
  530.                 union {
  531.                     difference {
  532.                         sphere {<0,.2,0>,.2}
  533.                         sphere {<0,.22,0>,.2}
  534.                         box {<-.25,.02,-.01>,<.25,.41,.01>}
  535.                         box {<-.25,.02,-.01>,<.25,.41,.01>    rotate y*120}
  536.                         box {<-.25,.02,-.01>,<.25,.41,.01>    rotate y*240}
  537.                         texture {
  538.                             TreeFlowerTexture
  539.                             scale <1,.3,1>
  540.                         }
  541.                         scale <1.5,1,1.5>
  542.                     }
  543.                     sphere {
  544.                         <0,0,0>,.05
  545.                         scale <1.5,.1,1.5>
  546.                         translate <0,.02,0>
  547.                         pigment {color Yellow}
  548.                     }
  549.                 }
  550.             #break
  551.  
  552.             #case (4)        // Spiky Flower
  553.                 #debug " - Using spiky flower\n"
  554.                 union {
  555.                     #declare CT=1
  556.                     #while (CT<=10)
  557.                         cone {
  558.                             <0,0,0>,.025,<0,.45,0>,.005
  559.                             texture {TreeFlowerTexture    scale <1,.46,1>}
  560.                             rotate x*(rand(SD3)*90)
  561.                             rotate y*(rand(SD3)*360)
  562.                         }
  563.                         #declare CT=CT+1
  564.                     #end
  565.                 }
  566.             #break
  567.             
  568.             #case (5)        // Cluster of Arches Flower
  569.                 #debug " - Using arches flower\n"
  570.                 union {
  571.                     #declare CT=1
  572.                     #while (CT<=6)
  573.                         difference {
  574.                             torus {
  575.                                 .25,.025
  576.                                 rotate x*90
  577.                                 translate <-.25,0,0>
  578.                             }
  579.                             box {
  580.                                 <-.55,-.7,-.05>,<.25,0,.05>
  581.                                 rotate z*20
  582.                             }
  583.                             texture {TreeFlowerTexture    scale <1,.3,1>}
  584.                             rotate y*(CT*60)
  585.                         }
  586.                         #declare CT=CT+1
  587.                     #end
  588.                 }
  589.             #break
  590.         #end
  591.         scale <BaseLen,BaseLen,BaseLen>
  592.     }
  593. #end
  594.  
  595. #if (LeafShape!=1)
  596.     #declare TreeLeafTexture=
  597.     texture {
  598.         #switch (LeafTexture)
  599.             #case (0)                                    // Default Texture
  600.                 #debug " - Using default pale green leaf texture\n"
  601.                 pigment {color PaleGreen}
  602.             #break
  603.  
  604.             #case (1)                                    // User Defined Texture
  605.                 #ifndef(Leaves)
  606.                     #debug " - 'Leaves' texture not defined, using default in its place\n"
  607.                     pigment {color PaleGreen}
  608.                     #else
  609.                     Leaves
  610.                     scale <BaseLen,BaseLen,BaseLen>
  611.                 #end
  612.             #break
  613.  
  614.             #case (2)                                    // Dark Shiny Green
  615.                 #debug " - Using shiny dark green leaf texture\n"
  616.                 pigment {SeaGreen}
  617.                 finish {
  618.                     ambient .15
  619.                     phong .3
  620.                     reflection .1
  621.                 }
  622.             #break
  623.  
  624.             #case (3)                                    // Lime Green
  625.                 #debug " - Using lime green leaf texture\n"
  626.                 pigment {color LimeGreen}
  627.             #break
  628.  
  629.             #case (4)                                    // Yellow Green
  630.                 #debug " - Using yellow green leaf texture\n"
  631.                 pigment {color YellowGreen}
  632.             #break
  633.  
  634.             #case (5)                                    // Wheat
  635.                 #debug " - Using wheat leaf texture\n"
  636.                 pigment {color Wheat}
  637.             #break
  638.         #end
  639.     }
  640. #end
  641.  
  642. #declare Leaf=
  643. object {
  644.     #switch (LeafShape)
  645.         #case (0)                                // Default Oval
  646.             #debug " - Using default leaf shape\n"
  647.             sphere {<0,0,.195>,.2}
  648.             scale <.75,.1,1.5>
  649.             texture {TreeLeafTexture}
  650.         #break
  651.  
  652.         #case (1)                                    // User Defined Leaf
  653.             #ifndef(Leave)
  654.                 #debug " - 'Leave' shape not defined, using default leaf in its place\n"
  655.                 sphere {<0,0,.195>,.2}
  656.                 scale <.75,.1,1.5>
  657.                 pigment {color Pale Green}
  658.                 #else
  659.                 Leave
  660.             #end
  661.         #break
  662.  
  663.         #case (2)                                 // "Maple" of three triangles
  664.             #debug " - Using maple leaf shape\n"
  665.             union {
  666.                 triangle {<0,0,0>,<0,0,.3>,<-.5,0,.3>}
  667.                 triangle {<0,0,0>,<0,0,.3>,<.5,0,.3>}
  668.                 triangle {<-.2,0,.3>,<0,0,.5>,<.2,0,.3>}
  669.                 texture {TreeLeafTexture}
  670.             }
  671.         #break
  672.  
  673.         #case (3)                                // Teardrop
  674.             #debug " - Using teardrop leaf shape\n"
  675.             union {
  676.                 cone {<0,0,0>,.015,<0,0,.3>,.15}
  677.                 sphere {<0,0,.3>,.15}
  678.                 scale <1,.1,1.5>
  679.                 texture {TreeLeafTexture}
  680.             }
  681.         #break
  682.  
  683.         #case (4)                                // Bent
  684.             #debug " - Using bent leaf shape\n"
  685.             union {
  686.                 cone {<0,0,0>,.015,<0,0,.35>,.15}
  687.                 sphere {<0,0,.35>,.15}
  688.                 cone {<0,0,.35>,.15,<0,-.35,.7>,.075}
  689.                 scale <1,.15,1.25>
  690.                 texture {TreeLeafTexture}
  691.             }
  692.         #break
  693.  
  694.         #case (5)                                // Pine Needles
  695.             #debug " - Using pine needles leaf shape\n"
  696.             union {
  697.                 cone {<0,0,0>,.025,<0,.1,.5>,.01}
  698.                 cone {<0,0,0>,.025,<-.05,-.05,.6>,.01}
  699.                 cone {<0,0,0>,.025,<.1,.02,.4>,.01}
  700.                 cone {<0,0,0>,.025,<-.05,-.03,.5>,.01}
  701.                 cone {<0,0,0>,.025,<-.1,.05,.6>,.01}
  702.                 texture {TreeLeafTexture}
  703.             }
  704.         #break
  705.  
  706.         #case (6)                                // Oak
  707.             box {
  708.             #debug " - Using oak leaf material map\n"
  709.                 <0,0,0>,<1,1,.01>
  710.                 texture {
  711.                     material_map {
  712.                         gif "oakleaf.gif"
  713.                         texture {pigment {color Clear}}
  714.                         texture {TreeLeafTexture}
  715.                     }
  716.                 }
  717.                 rotate x*90
  718.                 translate <-.5,0,0>
  719.                 scale <.4,1,.75>
  720.             }
  721.         #break
  722.  
  723.         #case (7)                                // Gingko
  724.             #debug " - Using gingko leaf material map\n"
  725.             box {
  726.                 <0,0,0>,<1,1,.01>
  727.                 texture {
  728.                     material_map {
  729.                         gif "gingko.gif"
  730.                         texture {pigment {color Clear}}
  731.                         texture {TreeLeafTexture}
  732.                     }
  733.                 }
  734.                 rotate x*90
  735.                 translate <-.5,0,0>
  736.                 scale <.5,1,.5>
  737.             }
  738.         #break
  739.  
  740.         #case (8)                                // Palmetto
  741.             #debug " - Using palmetto leaf material map\n"
  742.             box {
  743.                 <0,0,0>,<1,1,.01>
  744.                 texture {
  745.                     material_map {
  746.                         gif "palmetto.gif"
  747.                         texture {pigment {color Clear}}
  748.                         texture {TreeLeafTexture}
  749.                     }
  750.                 }
  751.                 rotate x*90
  752.                 translate <-.5,0,0>
  753.                 scale <.75,1,.75>
  754.             }
  755.         #break
  756.     #end
  757.  
  758.     scale <BaseLen,BaseLen,BaseLen>
  759. }
  760.  
  761. // ---- ASSEMBLE ELEMENTS OF TREE ----
  762. #debug "ASSEMBLING TREE "
  763. union {
  764.     cone {
  765.         <0,0,0>,BaseLen,<0,BaseLen*(LengthInc*5),0>,BaseLen/2
  766.         texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  767.     }
  768.     #if (BallJoint=True & BallLevels>=1)
  769.         sphere {
  770.             <0,BaseLen*(LengthInc*5),0>,BaseLen/2
  771.             texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  772.         }
  773.     #end
  774.     #declare Loop1=int((rand(SD1)*((MaxSplits-MinSplits-1)+.9999999999))+MinSplits)    // How many forks?
  775.     #declare Loop1Count=1
  776.     #while (Loop1Count <= Loop1)
  777.         #debug "1"
  778.         union {
  779.             cone {
  780.                 <0,0,0>,BaseLen/2,<0,BaseLen*(LengthInc*4),0>,BaseLen/4
  781.                 texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  782.             }
  783.             #if (BallJoint=True & BallLevels>=2)
  784.                 sphere {
  785.                     <0,BaseLen*(LengthInc*4),0>,BaseLen/4
  786.                     texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  787.                 }
  788.             #end
  789.             #declare Loop2=int((rand(SD1)*(((MaxSplits*IncSplits)-MinSplits-1)+.9999999999))+MinSplits)    // How many forks?
  790.             #declare Loop2Count=1
  791.             #while (Loop2Count <= Loop2)
  792.                 #debug "2"
  793.                 union {
  794.                     cone {
  795.                         <0,0,0>,BaseLen/4,<0,BaseLen*(LengthInc*3),0>,BaseLen/8
  796.                         texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  797.                     }
  798.                     #if (BallJoint=True & BallLevels>=3)
  799.                         sphere {
  800.                             <0,BaseLen*(LengthInc*3),0>,BaseLen/8
  801.                             texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  802.                         }
  803.                     #end
  804.                     #declare Loop3=int((rand(SD1)*(((MaxSplits*IncSplits*IncSplits)-MinSplits-1)+.9999999999))+MinSplits)
  805.                     #declare Loop3Count=1
  806.                     #while (Loop3Count <= Loop3)
  807.                         #debug "3"
  808.                         union {
  809.                             cone {
  810.                                 <0,0,0>,BaseLen/8,<0,BaseLen*(LengthInc*2),0>,BaseLen/16
  811.                                 texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  812.                             }
  813.                             #if (BallJoint=True & BallLevels>=4)
  814.                                 sphere {
  815.                                     <0,BaseLen*(LengthInc*2),0>,BaseLen/16
  816.                                     texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  817.                                 }
  818.                             #end
  819.                             #declare Loop4=int((rand(SD1)*(((MaxSplits*IncSplits*IncSplits*IncSplits)-MinSplits-1)+.9999999999))+MinSplits)
  820.                             #declare Loop4Count=1
  821.                             #while (Loop4Count <= Loop4)
  822.                                 #debug "4"
  823.                                 union {
  824.                                     cone {
  825.                                         <0,0,0>,BaseLen/16,<0,BaseLen*LengthInc,0>,BaseLen/32
  826.                                         texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  827.                                     }
  828.                                     #if (BallJoint=True & BallLevels>=5)
  829.                                         sphere {
  830.                                             <0,BaseLen*LengthInc,0>,BaseLen/32
  831.                                             texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  832.                                         }
  833.                                     #end
  834.                                     #declare Loop5=int((rand(SD1)*(((MaxSplits*IncSplits*IncSplits*IncSplits*IncSplits)-MinSplits-1)+.9999999999))+MinSplits)
  835.                                     #declare Loop5Count=1
  836.                                     #while (Loop5Count <= Loop5)
  837.                                         #debug "5"
  838.                                         union {
  839.                                             cone {
  840.                                                 <0,0,0>,BaseLen/32,<0,BaseLen,0>,BaseLen/64
  841.                                                 texture {TreeBarkTexture scale <BaseLen,BaseLen,BaseLen>}
  842.                                             }
  843.                                             #if (Tip > 0)
  844.                                                 #if (rand(SD3)<=TipPercent)
  845.                                                     #switch (Tip)
  846.                                                         #case (1)
  847.                                                             object {Leaf    rotate x*-90    translate <0,BaseLen,0>}
  848.                                                         #break
  849.                                                         #case (2)
  850.                                                             object {Fruit    translate <0,BaseLen,0>}
  851.                                                         #break
  852.                                                         #case (3)
  853.                                                             object {Flower    translate <0,BaseLen,0>}
  854.                                                         #break
  855.                                                     #end
  856.                                                     #else
  857.                                                     #switch (TipOther)
  858.                                                         #case (1)
  859.                                                             object {Leaf    rotate x*-90    translate <0,BaseLen,0>}
  860.                                                         #break
  861.                                                         #case (2)
  862.                                                             object {Fruit    translate <0,BaseLen,0>}
  863.                                                         #break
  864.                                                         #case (3)
  865.                                                             object {Flower    translate <0,BaseLen,0>}
  866.                                                         #break
  867.                                                     #end
  868.                                                 #end
  869.                                             #end
  870.                                             #declare LNum=1
  871.                                             #while (LNum<=LeafNum)
  872.                                                 object {
  873.                                                     Leaf
  874.                                                     rotate x*-MinXDeg
  875.                                                     rotate y*((MaxYDeg/LeafNum)*LNum)
  876.                                                     #if (LeafRosette)
  877.                                                         rotate y*((MaxYDeg/LeafNum)*LNum)
  878.                                                         translate <0,BaseLen*.6,0>
  879.                                                        #else
  880.                                                              #if (LeafRandRot)
  881.                                                             rotate y*(rand(SD2)*360)
  882.                                                            #else
  883.                                                             rotate y*((MaxYDeg/LeafNum)*LNum)
  884.                                                         #end
  885.                                                         translate <0,(BaseLen/(LeafNum+1))*LNum,0>
  886.                                                     #end
  887.                                                 }
  888.                                                 #declare LNum=LNum+1
  889.                                             #end
  890.                                             #if (Loop5Count<Loop5)
  891.                                                 rotate x*((rand(SD1)*((MaxXDeg+(IncXDeg*4))-(MinXDeg+(IncXDeg*4))))+(MinXDeg+(IncXDeg*4)))
  892.                                                 rotate y*((rand(SD1)*((MaxYDeg+(IncYDeg*4))-(MinYDeg+(IncYDeg*4))))+(MinYDeg+(IncYDeg*4)))
  893.                                                 rotate z*((rand(SD1)*((MaxZDeg+(IncZDeg*4))-(MinZDeg+(IncZDeg*4))))+(MinZDeg+(IncZDeg*4)))
  894.                                                #else
  895.                                                 rotate x*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  896.                                                 rotate y*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  897.                                                 rotate z*((rand(SD1)*(MinZDeg*2))-MinZDeg)
  898.                                             #end
  899.                                             translate <0,(BaseLen*LengthInc)*(Loop5Count/Loop5),0>
  900.                                         }
  901.                                         #declare Loop5Count = Loop5Count+1
  902.                                     #end
  903.                                     #if (Loop4Count<Loop4)
  904.                                         rotate x*((rand(SD1)*((MaxXDeg+(IncXDeg*3))-(MinXDeg+(IncXDeg*3))))+(MinXDeg+(IncXDeg*3)))
  905.                                         rotate y*((rand(SD1)*((MaxYDeg+(IncYDeg*3))-(MinYDeg+(IncYDeg*3))))+(MinYDeg+(IncYDeg*3)))
  906.                                         rotate z*((rand(SD1)*((MaxZDeg+(IncZDeg*3))-(MinZDeg+(IncZDeg*3))))+(MinZDeg+(IncZDeg*3)))
  907.                                        #else
  908.                                         rotate x*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  909.                                         rotate y*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  910.                                         rotate z*((rand(SD1)*(MinZDeg*2))-MinZDeg)
  911.                                     #end
  912.                                     translate <0,(BaseLen*(LengthInc*2))*(Loop4Count/Loop4),0>
  913.                                 }
  914.                                 #declare Loop4Count = Loop4Count+1
  915.                             #end
  916.                             #if (Loop3Count<Loop3)
  917.                                 rotate x*((rand(SD1)*((MaxXDeg+(IncXDeg*2))-(MinXDeg+(IncXDeg*2))))+(MinXDeg+(IncXDeg*2)))
  918.                                 rotate y*((rand(SD1)*((MaxYDeg+(IncYDeg*2))-(MinYDeg+(IncYDeg*2))))+(MinYDeg+(IncYDeg*2)))
  919.                                 rotate z*((rand(SD1)*((MaxZDeg+(IncZDeg*2))-(MinZDeg+(IncZDeg*2))))+(MinZDeg+(IncZDeg*2)))
  920.                                #else
  921.                                 rotate x*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  922.                                 rotate y*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  923.                                 rotate z*((rand(SD1)*(MinZDeg*2))-MinZDeg)
  924.                             #end
  925.                             translate <0,(BaseLen*(LengthInc*3))*(Loop3Count/Loop3),0>
  926.                         }
  927.                         #declare Loop3Count = Loop3Count+1
  928.                     #end
  929.                     #if (Loop2Count<Loop2)
  930.                         rotate x*((rand(SD1)*((MaxXDeg+IncXDeg)-(MinXDeg+IncXDeg)))+(MinXDeg+IncXDeg))
  931.                         rotate y*((rand(SD1)*((MaxYDeg+IncYDeg)-(MinYDeg+IncYDeg)))+(MinYDeg+IncYDeg))
  932.                         rotate z*((rand(SD1)*((MaxZDeg+IncZDeg)-(MinZDeg+IncZDeg)))+(MinZDeg+IncZDeg))
  933.                        #else
  934.                         rotate x*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  935.                         rotate y*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  936.                         rotate z*((rand(SD1)*(MinZDeg*2))-MinZDeg)
  937.                     #end
  938.                     translate <0,(BaseLen*(LengthInc*4))*(Loop2Count/Loop2),0>
  939.                 }
  940.                 #declare Loop2Count = Loop2Count+1
  941.             #end
  942.             #if (Loop1Count<Loop1)
  943.                 rotate x*((rand(SD1)*(MaxXDeg-MinXDeg))+MinXDeg)
  944.                 rotate y*(rand(SD1)*360)
  945.                 rotate z*((rand(SD1)*(MaxZDeg-MinZDeg))+MinZDeg)
  946.                #else
  947.                 rotate x*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  948.                 rotate y*((rand(SD1)*(PlusMinus*2))-PlusMinus)
  949.                 rotate z*((rand(SD1)*(MinZDeg*2))-MinZDeg)
  950.             #end
  951.             translate <0,(BaseLen*(LengthInc*5))*(Loop1Count/Loop1),0>
  952.         }
  953.         #declare Loop1Count = Loop1Count+1
  954.         #debug "\n"
  955.     #end
  956. }
  957.