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
your own matrices, and loading them into the OpenGL MODELVIEW matrix.
OpenGL commands you may NOT use this time are glRotate,
glTranslate, glMultMatrix, glPushMatrix and glPopMatrix. Instead, you
keep track of your own 2D version of the MODELVIEW matrix, and modify
by left-multiplying it by translation matrices, rotation matrices, etc.
You can use the function load2DMatrix() in the starter code to
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
be able to take depth of the L-system as an
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
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
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
'?' - 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
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.
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.
Look here for some suggestions about getting
Written Questions for Each Team Member (20% of the project
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
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
What and How to Submit
Your program should compile and run on the Taylor or Painter basement machines. Then submit the following files:
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
report, please mention all the extra features that you have implemented
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
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
djeu cs354_project2_code per group for all code-related files and
djeu cs354_project2_written per person for each person's project2.txt.
Here is a short note on how to use the turnin program.
Start early, and good luck!
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