## Fractal Plants Project ECS175: Computer Graphics Due 7 pm Mon May 1

 A lupine, by Karoline Hayes. In this project we will draw two-dimensional fractal plants. Part of the project is implementing and using your own transformation matrices; this is so that you'll understand how they are used in OpenGL and other graphics systems. The basic project described below is worth a B, if done well. A program which draws something interesting, attractive or realistic is worth an A. You should aim to have the basic program done by Fri 28, so that you have time to do something interesting by Monday.

You may work with a partner on this project.

### Requirements

Your plant should be defined using an L-system defined by recursive functions.

Here are lecture notes covering L-systems and how to implement them as recursive functions.

The plant should include at least leaves and stems, and its structure should include branching as well as rotation and translation.

You may use any of the OpenGL functions for drawing primitives: glBegin(GL_POLYGON), glBegin(GL_TRIANGLES), etc., and you can set colors using glColor3f.

You must specify the transformations used by specifying your own 2D transformation matrices, and loading them into the OpenGL MODELVIEW matrix using the function loadTurtle in the program below. If you need to get the 2D matrix corresponding to the current MODELVIEW matrix (after popping the matrix stack, say) you can use the function getTurtle, also part of the program below.

By loading your matrix into the MODELVIEW matrix, you allow OpenGL to use it to produce the correct world coordinates for each vertex. The OpenGL commands you may NOT use this time are glRotate, glScale, glTranslate, and glMultMatrix. You may NOT use glPushMatrix and glPopMatrix. You should implement your own matrix stack, or you can avoid using a stack by using recursion.

Your program should take the recursion depth as an integer input on the command line. For example,
plant 5
should put up a window and draw the plant corresponding to five levels of recursion.

### Getting started

Here is some code which brings up an OpenGL window and draws a leaf. It includes a function to load a 2D transformation matrix, called Turtle, nto the 3D OpenGL MODELVIEW matrix properly, and load Turtle from the MODELVIEW matrix.
• Makefile
• plant.c
• drawPlant.c
• drawPlant.h

### Deliverables

Please provide a Makefile which will allow us to compile your project on the machines in 67 Kemper.

Please take a picture of your best plant, suitable for framing or for display on the class Web page, and save it as a .gif. We will post the nicer pictures on the Web page, so try to make something that people will want to look at!

Turn in all the source files of your program, the executable, the Makefile, any input data files, your .gif file, and a plain text documentation file called README, using handin. Thanks!

### Ideas for extensions

Anything that the TA and I think is interesting and/or neat looking will get credit, so don't feel constrained by this list. If you have a good idea, go for it! If you're wondering if it's a good idea, ask.

One obvious idea is to try and make realistic looking plants. Go outside and walk around. It's beautiful out. Look at all those plants. How would you describe their structures using L-systems?

For inspiration from the computer, here is a link to the on-line book on L-systems by the premier research group in Calgary. You should look at Section 8, and maybe other sections as well. The movies are great.

Another good idea is to use other technical features we've been studying. How should you choose the vertex colors? Could that be part of your L-system? Would texture mapping make your plant more realistic? Could using Bezier curves to draw your leaves make your images more attractive? Don't just try to use the techniques, try to use them to make your project better.