This project is focused on drawing two-dimensional fractal plants. Part of the project is implementing and using your own transformation matrices; this way you'll understand how they are used in OpenGL and other graphics systems. The basic project described below is worth 85%. To get 100% or more, you'll need to implement some additional features.

**Project Specifications**

Carefully read the lecture notes on L-systems.
Next understand the purpose and use of the MODELVIEW
and PROJECTION matrices in OpenGL. You may refer to the reference
book mentioned below or to
some online
OpenGL tutorial.

Your plant should be defined using recursive functions corresponding to a simple L-system. Consult the lecture notes 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 like flowers and fruits 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 ']') and turning (`+' and `-'). Give the definition of your L-system in your documentation.

You must specify the transformations used by your L-system by
specifying
your own matrices, and loading them into the OpenGL MODELVIEW matrix.
The
OpenGL commands you may **NOT** use this time are glRotate,
glScale,
glTranslate, glMultMatrix, glPushMatrix and glPopMatrix. Instead, you
should
keep track of your own 2D version of the MODELVIEW matrix, and modify
it
by left-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. ***NEW*** You will also need to
write a more generalized version of this function where you can set
additional elements in the 3rd row and 3rd column of the matrix.
Name this more general function load3DMatrix().
***END NEW*** Your
program
should
be able to take depth of the L-system as an
input
parameter. You should include this in your user interface. Set
the default depth be 1, and set 'a'
to increase the depth of your
L-system and 's' to decrease
the depth of the L-system. Naturally, make sure the depth cannot
be negative.

The starter code contains 2-D versions of the branch and leaf
drawing primitives, but you will extend these to 3-D. Using the
2-D version of the leaf (this will be like the silhouette of the leaf
in x and y
coordinates), create a 3-D extrusion by giving the
2-D silhouette a uniform thickness in the z dimension. GL_QUADS
and
GL_TRIANGLES may be helpful when you are creating the extrusion.
Do the same with the 2-D branch.

'/' - rotates the plant
about its y-axis counterclockwise (i.e. when you are looking at the
trunk of the plant from the top down, the plant rotates
counterclockwise).

'?' - rotates the plant about
its y-axis clockwise.

Note that to implement these full-plant rotations, you should only
need to perform
one matrix multiply and one matrix load before you begin drawing the
plant.

Your code should also be able to switch between using a perspective
projection matrix and an orthographic projection matrix. Assign 'p' to toggle between these two
projection modes, and make sure you print to stdout the projection mode
that is currently in use. You may use the built-in OpenGL matrix
functions for this part of the assignment and this part only.
Some helpful functions to look at: glFrustum(), glOrtho() and
gluPerspective(). Use reasonable parameters.

Finally, answer the 2 questions for report.txt that are listed in
the "What and How to Submit" section.

Additional Features

If you successfully complete everything up to this point, your score
for the project will be an 85%. Select some additional features
from the following list to receive 100% or more.

- up to 5 pts. Vary the colors and use color interpolation on your polygons to get a more natural effect.
- up to 5 pts. Make a simple animation of your plant growing, by
showing
each level of recursion, with a pause between each image (you can get a
pause with the unix
*sleep*function; you have to include*unistd.h*). - up to 5 pts. Use randomness (
*man random*for more on generating random numbers) in your drawing functions, to get more interesting and realistic looking plants. - up to 7 pts. Include flowers or fruits.
- up to 7 pts. Improve the 3-D extrusion of the branch so that it
looks less blocky and more realistic.

- up to 7 pts. Use splines to get curved leaves, stems, fruit, or flowers.
- up to 7 pts. Put your plants in context - read in an image of a
landscape,
still-life, etc, and draw your plant over it. You can use the
file readppm.c in the
starter code to read in
*.ppm*format, or you may write your own image loader. - up to 12 pts. Use a different L-system to get interesting plants. Look at the real plants outside for ideas. Use buds, conditional rules, random rules, etc.
- up to 15 pts. Animate your plant. One idea is to make it blow in the wind. Another is to make it grow smoothly, so that at each frame, twigs and leaves should grow and move a little bit. See the simple animation example on pages 24-25 in the OpenGL book to get started.
- up to 15 pts. Use a 3D L-system to draw a three dimensional plant
(with 3D branching rules). One method of expressing the 3D
branching is to specify the Euler angles of each turning symbol in the
L-system. The Euler angles are the 3 angles of rotation about the
x, y, and z
axes.

- up to ?? pts. Anything else that you think is interesting
and/or neat looking.

Getting Started

Here is the starter code which brings up a window and draws a leaf and branch. It includes a function to load a 2D transformation matrix into the 3D OpenGL MODELVIEW matrix properly. To compile it, type "

Look here for some suggestions about getting
started.

**Written Questions for Each Team Member **(20% of the project
grade)

1. What is the difference an orthographic projection and a perspective projection? What is the difference between glFrustum() and glOrtho()? Between glFrustum() and gluPerspective()? If you were given the parameters to glFrustum(), how would you make an equivalent call using gluPerspective()? ***NEW*** For the last question, you may assume that in the call to glFrustum(), top == -bottom and right == -left. ***END NEW***

2. ***NEW*** What changes would be
needed in order to express and then draw a leaf as a fractal? ***END NEW*** Provide some
pseudocode and mention any changes that would be needed in the L-system.

3. If you know a 3-D fruit
has
rotational symmetry about an axis and you were
given a triangulation of the 2-D cross-section (this cross section is
spanned by the axis of symmetry), how would you go about creating a
triangulation for the surface of the 3-D fruit? Provide
pseudocode. ***NEW*** Assume
that the triangulation of the 2-D cross-section is itself symmetric
about the axis of symmetry and has one top and one bottom vertex that
lies on the axis of symmetry.***END
NEW***

**What and How to Submit**

Your program should compile and run on the Taylor or Painter basement
machines. Then submit the following files:

- Source code
- README
- report.txt
- Image of the best plant you generated
- Makefile

The report (report.txt) should also be a plain text file which
should contain the
description of the L-system you implemented (in the form of rules and
the initial axiom). In
the
report, please mention all the extra features that you have implemented
or
else we may fail to notice and hence credit them. As a group,
answer the following two questions in the report:

1) How does the plant change visually when you switch between a
perspective projection and an orthographic projection?

2) Why is this?

Also, in report.txt, you may write about what new ideas you came up with, what design decisions you took etc; please keep such a discussion short and to the point.

You should grab the image of the best plant you generated by using*
xv *command on Taylor/Painter basement machines. Save it
as
gif or jpeg file. Here is a note
on how to grab a window using xv.

Each group member also needs to turn in his or her own version of
the answers to the 3 written questions. Put the answers to these
questions in a file called project2.txt.

Use the turnin
program to submit your files. Just like in Project 1, you have to
turnin to:

** djeu cs354_project2_code** per group for all code-related
files and

Here is a short note on how to use the turnin program.

Start early, and good luck!

References

A great coffee table book is The Algorithmic Beauty of Plants, by
Przemyslaw Prusinkiewicz, Aristid Lindenmayer. Also you can learn more
advanced concepts from
this
tutorial.

OpenGl Reference book.

Neider, Davis and Woo, "OpenGL Programming Guide" Second Edition,
Addison-Wesley