Fractal Plants Project
ECS175: Computer Graphics


Due 11:30 pm Friday April 30


A lupine, by Karoline Hayes, UT Austin.

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 85 points. To do A-level work, you'll need to go beyond the basic project in some way, to make a more interesting, attractive or realistic plant drawing. There are some suggestions below.

You may work with a partner on this project.

Requirements

Your plant should be defined using recursive functions. For instance, in class we used the following pseudo-code to draw a vine:

drawVineSegment {
drawStem
translate(5,0)
drawleaf
}


drawVine(i) {
if (i==0) drawVineSegment
else {
drawVineSegment
reflectX
drawVine(i-1)
}

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 (and you probably should) use glPushMatrix and glPopMatrix to manipulate the matrix stack.

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, for obvious reasons) into the 3D OpenGL MODELVIEW matrix properly, and load Turtle from the MODELVIEW matrix.
  • Makefile
  • plant.c
  • drawPlant.c
  • drawPlant.h
  • Look here for some advice about getting started.

    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. There are instructions for taking a snapshot of a window on the TA's Web page (follow the pointer to the TA Web page from the old class).

    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, using handin. Thanks!

    Ideas for extensions

    Anything that the reader 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.
  • up to 15 pts. Vary the recursive functions to get interesting plants. Look at the real plants outside for ideas. Think about generating flowers and fruit as well as leaves. Use alternating branching, add small rotations to make curves, use randomness to get variety (type man random for more on generating random numbers), etc.
  • up to 10 pts. Use a Bezier curve to get curved leaves, stems, fruit, or flowers.
  • up to 10 points. Read in an image (see instructions from last project), display it, and use it as a background for your plant drawings. You could display it pixel-by-pixels, or you could call glDrawPixels
  • up to 5 pts. Make a few different kinds of plants and group them together to make a landscape.
  • up to 3 pts. Use color interpolation on your polygons to get a more natural effect.