home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / examples / brchtrnm.lsy < prev    next >
Text File  |  1992-11-03  |  3KB  |  141 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.       xOffset = 2 - 4/numberOfFrames*iter;
  15.  
  16. /*
  17.  *  Generate the trunk.
  18.  */
  19. table trunk {
  20.   S -> texture("texture bump .4 scale .15 .15 .025 " +
  21.                "texture bump .2 scale .01 .01 .01 " +
  22.                "texture fbm 0 16. .5 2. 6. 0 birchtrunk.map " +
  23.                "scale 0.2 0.2 0.04")
  24.        ro(-15) pt(6) co("AntiqueWhite") wi(len/8) 
  25.        F(len) pt(-3) F(len) 
  26.        T(len);
  27.  
  28.   T(l) : l > 0.48 -> [ 
  29.                        Bpitch Branch(l)
  30.                      ] Brot1 
  31.              [ 
  32.                    Bpitch Branch(l)
  33.              ] Brot2 
  34.              wi(l/9) pt(-2) Trunk(l) T(l*fact1);
  35.  
  36.   T(l) : l <= 0.48 -> [
  37.                         Bpitch Branch(l)
  38.                       ] Brot1 
  39.               [
  40.                         Bpitch Branch(l)
  41.               ] Brot2
  42.                   G(-len/1.5) 
  43.                       [
  44.                 wi(l/12) [ pt(7)  B(l*fact1) ]
  45.                 ro(137)  [ pt(10) B(l*fact1) ]
  46.                 ro(70)   [ pt(3)  B(l*fact1) ]
  47.                   ];
  48.  
  49.   Bpitch -> (0.33) pt(33)
  50.      -> (0.33) pt(47)
  51.      -> (0.34) pt(42);
  52.  
  53.   Brot1 -> (0.33) ro(175)
  54.         -> (0.33) ro(190)
  55.         -> (0.34) ro(165);
  56.  
  57.   Brot2 -> (0.33) ro(105)
  58.         -> (0.33) ro(95)
  59.         -> (0.34) ro(77);
  60.  
  61.   Branch(l) -> (0.33) B(l)
  62.             -> (0.33) B(l*fact1)
  63.             -> (0.34) B(l*fact1*fact1);
  64.  
  65.   Trunk(l) -> (0.33) F(l*1.07)
  66.            -> (0.33) F(l)
  67.            -> (0.34) F(l*0.93);
  68. };
  69.  
  70. /*
  71.  *  Generate branches and prepare the leafs.
  72.  */
  73. table branches {
  74.   B(l) : l > 0.32 -> pt(3) wi(l/20) 
  75.              t(1,0,-0.5)
  76.                  texture("") co("SaddleBrown",l) F(l) 
  77.                [ BturnP Bpitch C(l*fact) ]
  78.                  [ BturnN Bpitch C(l*fact) ]
  79.              B(l*fact*fact);
  80.  
  81.   B(l) : l <= 0.32 -> pt(3) wi(l/20) 
  82.               t(1,0,-0.5)
  83.                       texture("") co("SaddleBrown",l) F(l) 
  84.               [ BturnP Bpitch C(l*fact) ]
  85.               [ BturnN Bpitch C(l*fact) ]
  86.               C(l*fact);
  87.  
  88.   C(l) : l > 0.18 -> wi(l/30) 
  89.                      texture("")  co("SaddleBrown",l) 
  90.              F(l*0.4) wi(fact*l/30) F(l*0.4) 
  91.              [ tu(30) C(l*fact*fact) ]
  92.              [ ro(120) tu(40) C(l*fact*fact)]
  93.              [ ro(240) tu(25) C(l*fact*fact*fact) ]
  94.              [ Leafs ];
  95.  
  96.   BturnN -> (0.5) tu(-67)
  97.          -> (0.5) tu(-82);
  98.   BturnP -> (0.5) tu(71)
  99.          -> (0.5) tu(80);
  100.   Bpitch -> (0.33) pt(-13)
  101.          -> (0.33) pt(-24)
  102.          -> (0.34) pt(-33);
  103. };
  104.   
  105. /*
  106.  *  Leafs
  107.  */
  108. table leafs {
  109.  
  110.   Leafs -> wi(0.007) F(0.1) 
  111.        Broll Leaf F(0.1) 
  112.        Broll Leaf F(0.1)
  113.        Broll Leaf 
  114.        [
  115.              co("SandyBrown") wi(0.011) F(0.1)
  116.        ];
  117.  
  118.   Leaf -> (0.25) [bpch lib("birchleaf1", 0.93)]
  119.        -> (0.25) [bpch lib("birchleaf2", 1.03)]
  120.        -> (0.25) [bpch lib("birchleaf3", 1.13)]
  121.        -> (0.25) ;
  122.  
  123.   Broll -> (0.33) ro(137)
  124.         -> (0.33) ro(-9)
  125.     -> (0.34) ro(267);
  126.  
  127.   bpch  -> (0.33) pt(-30)
  128.     -> (0.33) pt(-23)
  129.     -> (0.34) pt(-47);
  130. };
  131.  
  132. attributes {
  133.   axiom  t(0,0,0) S;
  134.   derivation trunk(12), branches(10), leafs(2);
  135.  
  136.   weight 0.2*M_E^(-((tx-xOffset)^2)/(2*0.1));
  137.  
  138.   eye    0, 12, 4;
  139.   lookat 0,  0, 4;
  140. };
  141.