home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
oct93
/
graphics
/
graphtal.lha
/
Graphtal
/
Examples
/
firtree.lsys
< prev
next >
Wrap
Text File
|
1992-11-17
|
5KB
|
172 lines
/*
* This L-system description file generates a firtree.
*
* Copyright (C) 1992, Stephan Amann (amann@iam.unibe.ch)
* All rights reserved.
*
* Hint: Execution and interpretation of the L-system takes
* some time. Be patient. Best to use the rayshade driver
* because of the library objects used.
*
* The file needle.ray.lib is the library object file used by
* the rayshade driver.
*/
lsystem firtree;
const Age = 4;
Start_Length = 1.8;
Main_Length = 2.0;
Side_Length = 1.4;
Start_Width = 0.1;
Side_Factor_W = 0.8;
Side_Factor_L = 0.5;
Width_Growth_A = 1.05;
Length_Growth_A = 1.2;
Width_Growth_S = 1.15;
Length_Growth_S = 1.4;
Angle_Growth = 1.2;
Angle_Growth2 = 1.04;
Side_Angle = 35;
Stamm_Factor_W = 1.3;
Stamm_Factor_L = 1.15;
Part_Length_A = 0.4;
Part_Length_S = 0.5;
table Spross_Def {
Spross(n,l) : n==0 -> co("ForestGreen")
Branch_PartStamm_L(l, Start_Width*Stamm_Factor_W, n)
[
ro(60) Endpart
ro(60) Endpart
ro(60) Endpart
ro(60) Endpart
ro(60) Endpart
ro(60) Endpart
];
Spross(n,l) : n>0 -> Branch_PartStamm_L(l, Start_Width*Stamm_Factor_W, n)
[
ro(72) Astansatz(n)
ro(72) Astansatz(n)
ro(72) Astansatz(n)
ro(72) Astansatz(n)
ro(72) Astansatz(n)
]
Spross(n-1,l);
Astansatz(n) -> [ pt(-70,n) xm("branch" + n) ];
Branch_PartStamm_L(l,w,a) : a==0 -> Branch_PartStamm(l,w,a);
Branch_PartStamm_L(l,w,a) : a>=1 ->
Branch_PartStamm_L(l*Length_Growth_S, w*Width_Growth_S, a-1);
pt(a,n) : n==0 -> pt(a);
pt(a,n) : n>=1 -> pt(a*Angle_Growth2, n-1);
};
table branch {
Branch(n,l): n==1 -> Branch_PartAst_L(l, Start_Width, n) Knospe;
Branch(n,l): n>1 -> Branch_PartAst_L(l, Start_Width, n)
[ tu( Side_Angle,n) Branch(n-1,Side_Factor_L*l) ]
[ tu(-Side_Angle,n) Branch(n-1,Side_Factor_L*l) ]
Branch(n-1,l);
Branch_PartAst_L(l,w,a) : a==0 -> Branch_PartAst(l,w,a);
Branch_PartAst_L(l,w,a) : a>=1 ->
Branch_PartAst_L(l*Length_Growth_A, w*Width_Growth_A, a-1);
tu(a,n) : n==0 -> tu(a);
tu(a,n) : n>=1 -> tu(a*Angle_Growth, n-1);
};
table Knospen_Def {
Knospe -> co("ForestGreen")
[
tu(Side_Angle)
Branch_PartAst(Side_Length, Start_Width*Side_Factor_W, 1)
Endpart
]
[
tu(-Side_Angle)
Branch_PartAst(Side_Length, Start_Width*Side_Factor_W, 1)
Endpart
]
Branch_PartAst(Main_Length, Start_Width, 1)
Endpart;
};
table Branch_Part_Def {
Branch_PartStamm(l,w,a) : l>0 ->
wi(w) F(Part_Length_S/3)
[
[ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
]
F(Part_Length_S/3)
[
[ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
pt(72) [ tu(-90) G(w) tu(90-Side_Angle/3) Needle ]
]
F(Part_Length_S/3)
Branch_PartStamm(l-Part_Length_S,w,a);
Branch_PartAst(l,w,a) : l>0 ->
wi(w) F(Part_Length_A/3)
[
[ tu(-90) G(w) tu( Side_Angle) pt(Side_Angle) Needle ]
[ tu( 90) G(w) tu(-Side_Angle) pt(Side_Angle) Needle ]
]
F(Part_Length_A/3)
[
[ tu(-90) G(w) tu( Side_Angle) pt(Side_Angle) Needle ]
[ tu( 90) G(w) tu(-Side_Angle) pt(Side_Angle) Needle ]
]
F(Part_Length_A/3)
Branch_PartAst(l-Part_Length_A,w,a);
};
table needles {
Endpart -> [
[tu( 4*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu( 3*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu( 2*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu( 1*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu( 0*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu(-1*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu(-2*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu(-3*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
[tu(-4*Side_Angle/5) pt(Side_Angle) lib("needle", 0.01)]
];
Needle -> lib("needle", 0.01);
};
table generateMacros {
generateMacros(age) : age > 0 ->
sm("branch" + age) [ co("SaddleBrown") t(1,0,0,0.005)
Branch(age, Start_Length)
] em
generateMacros(age-1);
};
attributes {
axiom co("SaddleBrown")
generateMacros(Age)
Spross(Age, Start_Length*Stamm_Factor_L);
derivation generateMacros(infinity),
Spross_Def(infinity),
branch(infinity),
Knospen_Def,
Branch_Part_Def(infinity),
needles;
eye 40, 0, 12;
lookat 0, 0, 12;
};