Class Lsystem

java.lang.Object
  |
  +--Lsystem

public class Lsystem
extends java.lang.Object

This class provides a front-end interface for creating a BranchGroup by interpreting a 2-D FRACTINT-type L-system stored in a file. (Currently, it's only been tested on the file "weed.lsys", but hey, that's a start.) For more information on L-systems, see: http://spanky.triumf.ca/www/fractint/lsys/plants.html

Example usage:

   Lsystem lsystem = new Lsystem();   // construct an L-system object
   lsystem.initLsys (initPoint, lineLength, initAngle);
                                      // init. starting Lsystem parameters
   lsystem.initDraw (thk, mult, cylEdges, debug);
                                      // initialize drawing settings
   lsystem.readLsystem(filename);     // read rules from an L-system file
   lsystem.setAppearance(branchApp, leafApp);   // set branch/leaf appearance
   BranchGroup lsysBg = lsystem.execute(depth);
                                      // interpret L-system to depth "depth,"
                                      // returning a BranchGroup
 


Constructor Summary
Lsystem()
          Constructs an L-system object with default parameters.
 
Method Summary
 javax.media.j3d.BranchGroup execute(int depth)
          Interprets the L-system.
 void initDraw(double thk, double mult, int cylEdges, boolean debug)
          Initialization parameters affecting the L-system's geometry.
 void initLsys(javax.vecmath.Point3d initPoint, double lineLength, double initAngle)
          Initialization parameters of the L-system.
 boolean readLsystem(java.lang.String filename)
          Reads an L-system contained in a file.
 void setAppearance(javax.media.j3d.Appearance branchApp, javax.media.j3d.Appearance leafApp)
          Sets the Appearance of the branches and leaves of the L-system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lsystem

public Lsystem()
Constructs an L-system object with default parameters.
Method Detail

execute

public javax.media.j3d.BranchGroup execute(int depth)
Interprets the L-system.
Parameters:
depth - Number of recursive iterations of the L-system rules.

setAppearance

public void setAppearance(javax.media.j3d.Appearance branchApp,
                          javax.media.j3d.Appearance leafApp)
Sets the Appearance of the branches and leaves of the L-system. The leaves are simply the line segments added during the final iteration.
Parameters:
branchApp - Appearance of the branches
leafApp - Appearance of the leaves

initLsys

public void initLsys(javax.vecmath.Point3d initPoint,
                     double lineLength,
                     double initAngle)
Initialization parameters of the L-system.
Parameters:
initPoint - starting point of L-system interpreter in 3-D space
lineLength - initial line length
initAngle - initial orientation in 2-D space

initDraw

public void initDraw(double thk,
                     double mult,
                     int cylEdges,
                     boolean debug)
Initialization parameters affecting the L-system's geometry.
Parameters:
thk - minimum radius of the cylinders (line segments)
mult - multiplier for making longer line segments thicker (cylinder radius = thickness + mult * lineLength)
cylEdges - number of edges (resolution) of the cylinders
debug - flag to turn on debugging messages

readLsystem

public boolean readLsystem(java.lang.String filename)
Reads an L-system contained in a file.
Parameters:
filename - the name of the file.