home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / examples / firtree.lsy < prev    next >
Text File  |  1992-11-02  |  5KB  |  172 lines

  1. /*
  2.  * This L-system description file generates a firtree.
  3.  *
  4.  * Copyright (C) 1992, Stephan Amann (amann@iam.unibe.ch)
  5.  * All rights reserved.
  6.  *
  7.  * Hint: Execution and interpretation of the L-system takes
  8.  *       some time. Be patient. Best to use the rayshade driver
  9.  *       because of the library objects used.
  10.  *
  11.  * The file needle.ray.lib is the library object file used by 
  12.  * the rayshade driver. 
  13.  */
  14.  
  15. lsystem firtree;
  16.  
  17. const Age             = 4;
  18.       Start_Length    = 1.8;
  19.       Main_Length     = 2.0;
  20.       Side_Length     = 1.4;
  21.       Start_Width     = 0.1;
  22.       Side_Factor_W   = 0.8;
  23.       Side_Factor_L   = 0.5;
  24.       Width_Growth_A  = 1.05;
  25.       Length_Growth_A = 1.2;
  26.       Width_Growth_S  = 1.15;
  27.       Length_Growth_S = 1.4;
  28.       Angle_Growth    = 1.2;
  29.       Angle_Growth2   = 1.04;
  30.       Side_Angle      = 35;
  31.       Stamm_Factor_W  = 1.3;
  32.       Stamm_Factor_L  = 1.15;
  33.       Part_Length_A   = 0.4;
  34.       Part_Length_S   = 0.5;
  35.  
  36. table Spross_Def {
  37.   Spross(n,l) : n==0  -> co("ForestGreen")
  38.                          Branch_PartStamm_L(l, Start_Width*Stamm_Factor_W, n) 
  39.                      [ 
  40.                ro(60) Endpart
  41.                ro(60) Endpart
  42.                ro(60) Endpart
  43.                ro(60) Endpart
  44.                ro(60) Endpart
  45.                ro(60) Endpart
  46.              ];
  47.   Spross(n,l) : n>0   -> Branch_PartStamm_L(l, Start_Width*Stamm_Factor_W, n) 
  48.                          [
  49.                ro(72) Astansatz(n)
  50.                ro(72) Astansatz(n)
  51.                ro(72) Astansatz(n)
  52.                ro(72) Astansatz(n)
  53.                ro(72) Astansatz(n)
  54.              ]
  55.              Spross(n-1,l);
  56.   Astansatz(n)        -> [ pt(-70,n) xm("branch" + n) ];
  57.  
  58.   Branch_PartStamm_L(l,w,a) : a==0 -> Branch_PartStamm(l,w,a);
  59.   Branch_PartStamm_L(l,w,a) : a>=1 -> 
  60.     Branch_PartStamm_L(l*Length_Growth_S, w*Width_Growth_S, a-1);
  61.  
  62.   pt(a,n) : n==0 -> pt(a);
  63.   pt(a,n) : n>=1 -> pt(a*Angle_Growth2, n-1);
  64. };
  65.  
  66. table branch {
  67.     Branch(n,l): n==1 -> Branch_PartAst_L(l, Start_Width, n) Knospe;
  68.     Branch(n,l): n>1  -> Branch_PartAst_L(l, Start_Width, n)
  69.                         [ tu( Side_Angle,n) Branch(n-1,Side_Factor_L*l) ]
  70.                        [ tu(-Side_Angle,n) Branch(n-1,Side_Factor_L*l) ]
  71.                        Branch(n-1,l);
  72.  
  73.     Branch_PartAst_L(l,w,a) : a==0 -> Branch_PartAst(l,w,a);
  74.     Branch_PartAst_L(l,w,a) : a>=1 -> 
  75.     Branch_PartAst_L(l*Length_Growth_A, w*Width_Growth_A, a-1);
  76.  
  77.     tu(a,n) : n==0 -> tu(a);
  78.     tu(a,n) : n>=1 -> tu(a*Angle_Growth, n-1);
  79. };
  80.  
  81. table Knospen_Def {
  82.   Knospe -> co("ForestGreen")
  83.             [ 
  84.           tu(Side_Angle) 
  85.           Branch_PartAst(Side_Length, Start_Width*Side_Factor_W, 1) 
  86.           Endpart
  87.         ]
  88.             [ 
  89.           tu(-Side_Angle) 
  90.           Branch_PartAst(Side_Length, Start_Width*Side_Factor_W, 1) 
  91.           Endpart
  92.         ]
  93.         Branch_PartAst(Main_Length, Start_Width, 1)
  94.          Endpart;
  95. };
  96.  
  97. table Branch_Part_Def {
  98.   Branch_PartStamm(l,w,a) : l>0 -> 
  99.        wi(w) F(Part_Length_S/3) 
  100.        [
  101.             [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  102.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  103.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  104.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  105.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  106.        ]
  107.        F(Part_Length_S/3) 
  108.        [
  109.             [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  110.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  111.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  112.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  113.      pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
  114.        ]
  115.        F(Part_Length_S/3) 
  116.        Branch_PartStamm(l-Part_Length_S,w,a);
  117.  
  118.   Branch_PartAst(l,w,a) : l>0 -> 
  119.        wi(w) F(Part_Length_A/3) 
  120.        [
  121.      [ tu(-90) G(w) tu( Side_Angle) pt(Side_Angle) Needle ]
  122.      [ tu( 90) G(w) tu(-Side_Angle) pt(Side_Angle) Needle ]
  123.        ]
  124.        F(Part_Length_A/3) 
  125.        [
  126.      [ tu(-90) G(w) tu( Side_Angle) pt(Side_Angle) Needle ]
  127.      [ tu( 90) G(w) tu(-Side_Angle) pt(Side_Angle) Needle ]
  128.        ]
  129.        F(Part_Length_A/3) 
  130.        Branch_PartAst(l-Part_Length_A,w,a);
  131. };
  132.  
  133. table needles {
  134.   Endpart -> [ 
  135.               [tu( 4*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  136.               [tu( 3*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  137.               [tu( 2*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  138.               [tu( 1*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  139.               [tu( 0*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  140.               [tu(-1*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  141.               [tu(-2*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  142.               [tu(-3*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  143.               [tu(-4*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
  144.         ];
  145.   Needle  -> lib("needle", 0.01);
  146. };
  147.  
  148. table generateMacros {
  149.   generateMacros(age) : age > 0 ->  
  150.     sm("branch" + age) [ co("SaddleBrown") t(1,0,0,0.005) 
  151.                          Branch(age, Start_Length) 
  152.                ] em
  153.         generateMacros(age-1);
  154. };
  155.  
  156. attributes {
  157.   axiom co("SaddleBrown") 
  158.         generateMacros(Age)
  159.     Spross(Age, Start_Length*Stamm_Factor_L); 
  160.   derivation generateMacros(infinity),
  161.              Spross_Def(infinity), 
  162.          branch(infinity), 
  163.          Knospen_Def, 
  164.           Branch_Part_Def(infinity), 
  165.          needles;
  166.  
  167.   eye     40, 0, 12;
  168.   lookat   0, 0, 12;
  169. };
  170.  
  171.  
  172.