Project 2
CS354: Computer Graphics

There is an error in Problem 4 on the homework distributed Wds! The normal vector should be: (-1,-3,-5), not (1,3,-6).


Due 11:30 PM Fri Feb 22


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 implement some additional features.

You may work with a partner on this project.

Requirements

Your plant should be defined using recursive functions corresponding to a simple L-system. Consult the handout on L-systems for detailed instructions. Your L-system should include at least branching, turning and scaling. The plant should include at least leaves and branches (other primitives line flowers and fruit are optional). So your L-system should include at least two character symbols, such as `F' for branch and `L' for leaf, and use branching (brackets `[]') and turning (`+' and `-'). Give the definition of your L-system in your documentation; stick to the notation we use in class unless you decide to add new operations (eg. color change, scaling).

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 your L-system by specifying your own matrices, and loading them into the OpenGL MODELVIEW matrix. 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, glMultMatrix, glPushMatrix and glPopMatrix - they are OpenGL's version of the matrix modification functions. Instead, you should keep track of your own 2D version of the MODELVIEW matrix, and modify it by post-multiplying it by translation matrices, rotation matrices, etc. You can use the function load2DMatrix in the starter code to put a 2D matrix into the OpenGL MODELVIEW matrix.

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

Check out these ideas for improvments you can make to the project. Anything else that I think is interesting and/or neat looking might get extra 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.

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 into the 3D OpenGL MODELVIEW matrix properly.
  • 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 Dell machines in the Taylor basement.

    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. On the Dell machines you can do this using the grab function of xv. Type xv to get started.

    What to turn in

    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 turnin. It should go to mjump cs354-project2. Thanks!