/* LSystem.h * J Scott Cameron * * LSystems are a type of rewriting grammar. * Rules are given for various symbols so that * those symbols are replaced by strings of other symbols * during each iteration. * * This implementation takes a Lindenmayer system and uses a LOGO * style cursor in 3d space to create geometry. The symbol "F" will * cause the cursor to move forward one unti and draw a cylinder. * "f" will move forward without drawing. The symbols X,x,Y,y,Z, * and z all rotate the cursor by a predetermined angle in * that plane. "[" and "]" allow the cursor be pushed * down on a stack, this allows for branching meshes */ #include #include #include #include using namespace std; class LSystem { public: LSystem(); // default constructor string init; //initial string (string at iteration 0) map rules; // map of replacement rules int iterations; // number of iterations to descend through string output(); // returns the final LSystem string void addRule(char,string); //adds a rule to the map void setRules(string); /*sets rules to those placed in given * string of format: * "=" */ void emptyRules(); // empties rule map string getRulesString(); // complements setRules() for Dialog box void setInit(string);//sets the initial string void setIterations(int); // sets iterations string replace(string,map); /*used to rewrite a string for one iteration*/ D3DXVECTOR3 getCenter(); //not implemented - used to find Center of mesh };