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

  1. /*
  2.  * This L-system description file generates a birchtree.
  3.  *
  4.  * Copyright (C) 1992, Andrey Collison (collison@iam.unibe.ch)
  5.  * All rights reserved.
  6.  */
  7.  
  8. lsystem birchtree;
  9.  
  10. const fact = 0.853;  // branch length decrease rate
  11.       fact1 = 0.903; // trunk length decrease rate
  12.       len  = 1.0;    
  13.  
  14. /*
  15.  *  Generate the trunk.
  16.  */
  17. table trunk {
  18.   S -> texture("texture bump .4 scale .15 .15 .025 " +
  19.                "texture bump .2 scale .01 .01 .01 " +
  20.                "texture fbm 0 16. .5 2. 6. 0 birchtrunk.map " +
  21.                "scale 0.2 0.2 0.04")
  22.        we(0) ro(-15) pt(6) co("AntiqueWhite") wi(len/8) 
  23.        F(len) pt(-3) F(len) 
  24.        T(len);
  25.  
  26.   T(l) : l > 0.48 -> [ 
  27.                        we(0.09) Bpitch Branch(l)
  28.                      ] Brot1 
  29.              [ 
  30.                    we(0.15) Bpitch Branch(l)
  31.              ] Brot2 wi(l/9) pt(-2) Trunk(l) T(l*fact1);
  32.  
  33.   T(l) : l <= 0.48 -> [
  34.                         we(0.12) Bpitch Branch(l)
  35.                       ] Brot1 
  36.               [
  37.                         we(0.15) Bpitch Branch(l)
  38.               ] Brot2
  39.                   G(-len/1.5) 
  40.                       [
  41.                 wi(l/12) [ pt(7)  B(l*fact1) ]
  42.                 ro(137)  [ pt(10) B(l*fact1) ]
  43.                 ro(70)   [ pt(3)  B(l*fact1) ]
  44.                   ];
  45.  
  46.   Bpitch -> (0.33) pt(33)
  47.      -> (0.33) pt(47)
  48.      -> (0.34) pt(42);
  49.  
  50.   Brot1 -> (0.33) ro(175)
  51.         -> (0.33) ro(190)
  52.         -> (0.34) ro(165);
  53.  
  54.   Brot2 -> (0.33) ro(105)
  55.         -> (0.33) ro(95)
  56.         -> (0.34) ro(77);
  57.  
  58.   Branch(l) -> (0.33) B(l)
  59.             -> (0.33) B(l*fact1)
  60.             -> (0.34) B(l*fact1*fact1);
  61.  
  62.   Trunk(l) -> (0.33) F(l*1.07)
  63.            -> (0.33) F(l)
  64.            -> (0.34) F(l*0.93);
  65. };
  66.  
  67. /*
  68.  *  Generate branches and prepare the leafs.
  69.  */
  70. table branches {
  71.   B(l) : l > 0.32 -> pt(3) wi(l/20) 
  72.                  texture("") co("SaddleBrown",l) F(l) 
  73.                [ we(0.15) BturnP Bpitch C(l*fact) ]
  74.                  [ we(0.15) BturnN Bpitch C(l*fact) ]
  75.              B(l*fact*fact);
  76.  
  77.   B(l) : l <= 0.32 -> pt(3) wi(l/20) 
  78.                       texture("") co("SaddleBrown",l) F(l) 
  79.               [ we(0.15) BturnP Bpitch C(l*fact) ]
  80.               [ we(0.15) BturnN Bpitch C(l*fact) ]
  81.               C(l*fact);
  82.  
  83.   C(l) : l > 0.18 -> wi(l/30) 
  84.                      texture("")  co("SaddleBrown",l) 
  85.              F(l*0.4) wi(fact*l/30) F(l*0.4) 
  86.              [ tu(30) C(l*fact*fact) ]
  87.              [ ro(120) tu(40) C(l*fact*fact)]
  88.              [ ro(240) tu(25) C(l*fact*fact*fact) ]
  89.              [ we(0.23) Leafs ];
  90.  
  91.   BturnN -> (0.5) tu(-67)
  92.          -> (0.5) tu(-82);
  93.   BturnP -> (0.5) tu(71)
  94.          -> (0.5) tu(80);
  95.   Bpitch -> (0.33) pt(-13)
  96.          -> (0.33) pt(-24)
  97.          -> (0.34) pt(-33);
  98. };
  99.   
  100. /*
  101.  *  Leafs
  102.  */
  103. table leafs {
  104.  
  105.   Leafs -> wi(0.007) F(0.1) 
  106.        Broll Leaf F(0.1) 
  107.        Broll Leaf F(0.1)
  108.        Broll Leaf 
  109.        [
  110.              co("SandyBrown") wi(0.011) F(0.1)
  111.        ];
  112.  
  113.   Leaf -> (0.25) [bpch lib("birchleaf1", 0.93)]
  114.        -> (0.25) [bpch lib("birchleaf2", 1.03)]
  115.        -> (0.25) [bpch lib("birchleaf3", 1.13)]
  116.        -> (0.25) ;
  117.  
  118.   Broll -> (0.33) ro(137)
  119.         -> (0.33) ro(-9)
  120.     -> (0.34) ro(267);
  121.  
  122.   bpch  -> (0.33) pt(-30)
  123.     -> (0.33) pt(-23)
  124.     -> (0.34) pt(-47);
  125. };
  126.  
  127. attributes {
  128.   axiom  t(0.5,0,-1,0) S;
  129.   derivation trunk(12), branches(10), leafs(2);
  130.  
  131.   randomize; 
  132. };
  133.