CS40 Lab 7: Procedural methods

Due 11:59pm Monday 18 April 2011
You may work with one partner on this assignment.
Procedural Methods
Draw two or more trees or some other plants using L-sytems and the procedural methods discussed in class. You may want to consult Algorithmic Botany and in particular chapter one of The Algorithmic Beauty of Plants. A local copy is also available.

This assignment is fairly open ended. Here are my requirements

Getting Started
First take a look at the input format for defining the grammar in myplant.txt. Each plant must begin from a start symbol/seed. Rules are specified by symbols separated by spaces. The first symbol is the symbol to be replaced. the remaining symbols are the replacement string. For symbols that can have multiple productions (e.g., F->FF or F->F), we can optionally assign a relative weight to the each production.

parseFile in growplants.cpp reads an input file as described above and stores the grammar as a small dictionary. The dictionary maps symbols to a vector of possible replacement productions. A production is simply the weight and a vector of replacement symbols. By storing the symbols in a vector and by separating symbols by spaces in the input file, you can have multi-character symbols, e.g., A1, B17.

The first task to complete is the function derive or a similar replacement. What this function does is derives a new vector of symbols by applying the grammar rules to the current vector of symbols (initially just the start symbol) complete this function and see that printPlant() displays the correct result.

Next, modify display to look at each symbol in the derived plant vector and assign a geometric interpretation using openGL commands. These could be drawing branches, leaves, rotating, pushing, popping, etc.

Things to Consider
The maximum model view matrix stack depth is 32, so if you try having more than 32 concurrent pushes, OpenGL will likely no longer draw what you want. This seems unlikely unless you are drawing very complicated plants.

You may want to apply a global scaling factor to keep you plant on the screen. Keyboard controls can help adjust this factor.

Once you are satisfied with your programs, hand them in by typing handin40 at the unix prompt. You may run handin40 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize after handing in some programs that you'd like to make a few more changes to them.